diff --git a/packages/google-ads-admanager/google/ads/admanager/gapic_version.py b/packages/google-ads-admanager/google/ads/admanager/gapic_version.py index d1a1a883babd..558c8aab67c5 100644 --- a/packages/google-ads-admanager/google/ads/admanager/gapic_version.py +++ b/packages/google-ads-admanager/google/ads/admanager/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.2.2" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-ads-admanager/google/ads/admanager_v1/gapic_version.py b/packages/google-ads-admanager/google/ads/admanager_v1/gapic_version.py index d1a1a883babd..558c8aab67c5 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/gapic_version.py +++ b/packages/google-ads-admanager/google/ads/admanager_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.2" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-ads-admanager/google/ads/admanager_v1/services/ad_unit_service/client.py b/packages/google-ads-admanager/google/ads/admanager_v1/services/ad_unit_service/client.py index c33e7ac32dd8..e64a74862298 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/services/ad_unit_service/client.py +++ b/packages/google-ads-admanager/google/ads/admanager_v1/services/ad_unit_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.longrunning import operations_pb2 # type: ignore from google.protobuf import duration_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 `google.ads.admanager_v1.AdUnitServiceClient`.", + extra={ + "serviceName": "google.ads.admanager.v1.AdUnitService", + "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.ads.admanager.v1.AdUnitService", + "credentialsType": None, + }, + ) + def get_ad_unit( self, request: Optional[Union[ad_unit_service.GetAdUnitRequest, dict]] = None, @@ -697,7 +734,7 @@ def get_ad_unit( name: Optional[str] = None, retry: OptionalRetry = 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_unit_messages.AdUnit: r"""API to retrieve an AdUnit object. @@ -740,8 +777,10 @@ def sample_get_ad_unit(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ads.admanager_v1.types.AdUnit: @@ -797,7 +836,7 @@ def list_ad_units( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAdUnitsPager: r"""API to retrieve a list of AdUnit objects. @@ -842,8 +881,10 @@ def sample_list_ad_units(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ads.admanager_v1.services.ad_unit_service.pagers.ListAdUnitsPager: @@ -915,7 +956,7 @@ def list_ad_unit_sizes( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAdUnitSizesPager: r"""API to retrieve a list of AdUnitSize objects. @@ -960,8 +1001,10 @@ def sample_list_ad_unit_sizes(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ads.admanager_v1.services.ad_unit_service.pagers.ListAdUnitSizesPager: @@ -1045,7 +1088,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. @@ -1056,8 +1099,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-ads-admanager/google/ads/admanager_v1/services/ad_unit_service/pagers.py b/packages/google-ads-admanager/google/ads/admanager_v1/services/ad_unit_service/pagers.py index ebf38bec7995..c0915a0f9b5b 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/services/ad_unit_service/pagers.py +++ b/packages/google-ads-admanager/google/ads/admanager_v1/services/ad_unit_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 = ad_unit_service.ListAdUnitsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -155,8 +157,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = ad_unit_service.ListAdUnitSizesRequest(request) diff --git a/packages/google-ads-admanager/google/ads/admanager_v1/services/ad_unit_service/transports/rest.py b/packages/google-ads-admanager/google/ads/admanager_v1/services/ad_unit_service/transports/rest.py index 48fcd9510712..e82b2eb5f252 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/services/ad_unit_service/transports/rest.py +++ b/packages/google-ads-admanager/google/ads/admanager_v1/services/ad_unit_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, @@ -94,8 +102,10 @@ def post_list_ad_unit_sizes(self, response): def pre_get_ad_unit( self, request: ad_unit_service.GetAdUnitRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[ad_unit_service.GetAdUnitRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + ad_unit_service.GetAdUnitRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_ad_unit Override in a subclass to manipulate the request or metadata @@ -117,8 +127,10 @@ def post_get_ad_unit( def pre_list_ad_units( self, request: ad_unit_service.ListAdUnitsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[ad_unit_service.ListAdUnitsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + ad_unit_service.ListAdUnitsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_ad_units Override in a subclass to manipulate the request or metadata @@ -140,8 +152,10 @@ def post_list_ad_units( def pre_list_ad_unit_sizes( self, request: ad_unit_service.ListAdUnitSizesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[ad_unit_service.ListAdUnitSizesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + ad_unit_service.ListAdUnitSizesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_ad_unit_sizes Override in a subclass to manipulate the request or metadata @@ -163,8 +177,10 @@ def post_list_ad_unit_sizes( 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 @@ -304,7 +320,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> ad_unit_messages.AdUnit: r"""Call the get ad unit method over HTTP. @@ -314,8 +330,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.ad_unit_messages.AdUnit: @@ -325,6 +343,7 @@ def __call__( http_options = ( _BaseAdUnitServiceRestTransport._BaseGetAdUnit._get_http_options() ) + request, metadata = self._interceptor.pre_get_ad_unit(request, metadata) transcoded_request = ( _BaseAdUnitServiceRestTransport._BaseGetAdUnit._get_transcoded_request( @@ -339,6 +358,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.AdUnitServiceClient.GetAdUnit", + extra={ + "serviceName": "google.ads.admanager.v1.AdUnitService", + "rpcName": "GetAdUnit", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AdUnitServiceRestTransport._GetAdUnit._get_response( self._host, @@ -359,7 +405,29 @@ def __call__( pb_resp = ad_unit_messages.AdUnit.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_ad_unit(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ad_unit_messages.AdUnit.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ads.admanager_v1.AdUnitServiceClient.get_ad_unit", + extra={ + "serviceName": "google.ads.admanager.v1.AdUnitService", + "rpcName": "GetAdUnit", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAdUnits( @@ -396,7 +464,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> ad_unit_service.ListAdUnitsResponse: r"""Call the list ad units method over HTTP. @@ -407,8 +475,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.ad_unit_service.ListAdUnitsResponse: @@ -421,6 +491,7 @@ def __call__( http_options = ( _BaseAdUnitServiceRestTransport._BaseListAdUnits._get_http_options() ) + request, metadata = self._interceptor.pre_list_ad_units(request, metadata) transcoded_request = _BaseAdUnitServiceRestTransport._BaseListAdUnits._get_transcoded_request( http_options, request @@ -433,6 +504,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.AdUnitServiceClient.ListAdUnits", + extra={ + "serviceName": "google.ads.admanager.v1.AdUnitService", + "rpcName": "ListAdUnits", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AdUnitServiceRestTransport._ListAdUnits._get_response( self._host, @@ -453,7 +551,31 @@ def __call__( pb_resp = ad_unit_service.ListAdUnitsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_ad_units(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ad_unit_service.ListAdUnitsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ads.admanager_v1.AdUnitServiceClient.list_ad_units", + extra={ + "serviceName": "google.ads.admanager.v1.AdUnitService", + "rpcName": "ListAdUnits", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAdUnitSizes( @@ -490,7 +612,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> ad_unit_service.ListAdUnitSizesResponse: r"""Call the list ad unit sizes method over HTTP. @@ -501,8 +623,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.ad_unit_service.ListAdUnitSizesResponse: @@ -515,6 +639,7 @@ def __call__( http_options = ( _BaseAdUnitServiceRestTransport._BaseListAdUnitSizes._get_http_options() ) + request, metadata = self._interceptor.pre_list_ad_unit_sizes( request, metadata ) @@ -527,6 +652,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.AdUnitServiceClient.ListAdUnitSizes", + extra={ + "serviceName": "google.ads.admanager.v1.AdUnitService", + "rpcName": "ListAdUnitSizes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AdUnitServiceRestTransport._ListAdUnitSizes._get_response( self._host, @@ -547,7 +699,31 @@ def __call__( pb_resp = ad_unit_service.ListAdUnitSizesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_ad_unit_sizes(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ad_unit_service.ListAdUnitSizesResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ads.admanager_v1.AdUnitServiceClient.list_ad_unit_sizes", + extra={ + "serviceName": "google.ads.admanager.v1.AdUnitService", + "rpcName": "ListAdUnitSizes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -617,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 get operation method over HTTP. @@ -627,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: Response from GetOperation method. @@ -637,6 +815,7 @@ def __call__( http_options = ( _BaseAdUnitServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseAdUnitServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -647,6 +826,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.AdUnitServiceClient.GetOperation", + extra={ + "serviceName": "google.ads.admanager.v1.AdUnitService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AdUnitServiceRestTransport._GetOperation._get_response( self._host, @@ -666,6 +872,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.ads.admanager_v1.AdUnitServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.ads.admanager.v1.AdUnitService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-ads-admanager/google/ads/admanager_v1/services/company_service/client.py b/packages/google-ads-admanager/google/ads/admanager_v1/services/company_service/client.py index 2af110bc0a6d..6ae632c4105b 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/services/company_service/client.py +++ b/packages/google-ads-admanager/google/ads/admanager_v1/services/company_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.longrunning import operations_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -648,6 +658,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.ads.admanager_v1.CompanyServiceClient`.", + extra={ + "serviceName": "google.ads.admanager.v1.CompanyService", + "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.ads.admanager.v1.CompanyService", + "credentialsType": None, + }, + ) + def get_company( self, request: Optional[Union[company_service.GetCompanyRequest, dict]] = None, @@ -720,7 +757,7 @@ def get_company( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> company_messages.Company: r"""API to retrieve a ``Company`` object. @@ -763,8 +800,10 @@ def sample_get_company(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ads.admanager_v1.types.Company: @@ -820,7 +859,7 @@ def list_companies( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCompaniesPager: r"""API to retrieve a list of ``Company`` objects. @@ -864,8 +903,10 @@ def sample_list_companies(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ads.admanager_v1.services.company_service.pagers.ListCompaniesPager: @@ -949,7 +990,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. @@ -960,8 +1001,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-ads-admanager/google/ads/admanager_v1/services/company_service/pagers.py b/packages/google-ads-admanager/google/ads/admanager_v1/services/company_service/pagers.py index 7a1c65b16259..6c78f4a95f1e 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/services/company_service/pagers.py +++ b/packages/google-ads-admanager/google/ads/admanager_v1/services/company_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 = company_service.ListCompaniesRequest(request) diff --git a/packages/google-ads-admanager/google/ads/admanager_v1/services/company_service/transports/rest.py b/packages/google-ads-admanager/google/ads/admanager_v1/services/company_service/transports/rest.py index 3f57d36ab6f8..99607ae444c1 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/services/company_service/transports/rest.py +++ b/packages/google-ads-admanager/google/ads/admanager_v1/services/company_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = logging.getLogger(__name__) DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, @@ -86,8 +94,10 @@ def post_list_companies(self, response): def pre_get_company( self, request: company_service.GetCompanyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[company_service.GetCompanyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + company_service.GetCompanyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_company Override in a subclass to manipulate the request or metadata @@ -109,8 +119,10 @@ def post_get_company( def pre_list_companies( self, request: company_service.ListCompaniesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[company_service.ListCompaniesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + company_service.ListCompaniesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_companies Override in a subclass to manipulate the request or metadata @@ -132,8 +144,10 @@ def post_list_companies( 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 @@ -273,7 +287,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> company_messages.Company: r"""Call the get company method over HTTP. @@ -283,8 +297,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.company_messages.Company: @@ -294,6 +310,7 @@ def __call__( http_options = ( _BaseCompanyServiceRestTransport._BaseGetCompany._get_http_options() ) + request, metadata = self._interceptor.pre_get_company(request, metadata) transcoded_request = _BaseCompanyServiceRestTransport._BaseGetCompany._get_transcoded_request( http_options, request @@ -306,6 +323,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.CompanyServiceClient.GetCompany", + extra={ + "serviceName": "google.ads.admanager.v1.CompanyService", + "rpcName": "GetCompany", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CompanyServiceRestTransport._GetCompany._get_response( self._host, @@ -326,7 +370,29 @@ def __call__( pb_resp = company_messages.Company.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_company(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = company_messages.Company.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ads.admanager_v1.CompanyServiceClient.get_company", + extra={ + "serviceName": "google.ads.admanager.v1.CompanyService", + "rpcName": "GetCompany", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCompanies( @@ -363,7 +429,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> company_service.ListCompaniesResponse: r"""Call the list companies method over HTTP. @@ -373,8 +439,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.company_service.ListCompaniesResponse: @@ -386,6 +454,7 @@ def __call__( http_options = ( _BaseCompanyServiceRestTransport._BaseListCompanies._get_http_options() ) + request, metadata = self._interceptor.pre_list_companies(request, metadata) transcoded_request = _BaseCompanyServiceRestTransport._BaseListCompanies._get_transcoded_request( http_options, request @@ -396,6 +465,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.CompanyServiceClient.ListCompanies", + extra={ + "serviceName": "google.ads.admanager.v1.CompanyService", + "rpcName": "ListCompanies", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CompanyServiceRestTransport._ListCompanies._get_response( self._host, @@ -416,7 +512,31 @@ def __call__( pb_resp = company_service.ListCompaniesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_companies(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = company_service.ListCompaniesResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ads.admanager_v1.CompanyServiceClient.list_companies", + extra={ + "serviceName": "google.ads.admanager.v1.CompanyService", + "rpcName": "ListCompanies", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -475,7 +595,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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. @@ -485,8 +605,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: operations_pb2.Operation: Response from GetOperation method. @@ -495,6 +617,7 @@ def __call__( http_options = ( _BaseCompanyServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseCompanyServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -505,6 +628,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.CompanyServiceClient.GetOperation", + extra={ + "serviceName": "google.ads.admanager.v1.CompanyService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CompanyServiceRestTransport._GetOperation._get_response( self._host, @@ -524,6 +674,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.ads.admanager_v1.CompanyServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.ads.admanager.v1.CompanyService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-ads-admanager/google/ads/admanager_v1/services/custom_field_service/client.py b/packages/google-ads-admanager/google/ads/admanager_v1/services/custom_field_service/client.py index 96798568f55a..70d1153c5851 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/services/custom_field_service/client.py +++ b/packages/google-ads-admanager/google/ads/admanager_v1/services/custom_field_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.longrunning import operations_pb2 # type: ignore from google.ads.admanager_v1.services.custom_field_service import pagers @@ -596,6 +606,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -662,6 +676,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.ads.admanager_v1.CustomFieldServiceClient`.", + extra={ + "serviceName": "google.ads.admanager.v1.CustomFieldService", + "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.ads.admanager.v1.CustomFieldService", + "credentialsType": None, + }, + ) + def get_custom_field( self, request: Optional[ @@ -671,7 +708,7 @@ def get_custom_field( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> custom_field_messages.CustomField: r"""API to retrieve a ``CustomField`` object. @@ -714,8 +751,10 @@ def sample_get_custom_field(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ads.admanager_v1.types.CustomField: @@ -775,7 +814,7 @@ def list_custom_fields( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCustomFieldsPager: r"""API to retrieve a list of ``CustomField`` objects. @@ -819,8 +858,10 @@ def sample_list_custom_fields(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ads.admanager_v1.services.custom_field_service.pagers.ListCustomFieldsPager: @@ -904,7 +945,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. @@ -915,8 +956,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-ads-admanager/google/ads/admanager_v1/services/custom_field_service/pagers.py b/packages/google-ads-admanager/google/ads/admanager_v1/services/custom_field_service/pagers.py index b11c6be336cc..54d40dc35c43 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/services/custom_field_service/pagers.py +++ b/packages/google-ads-admanager/google/ads/admanager_v1/services/custom_field_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 = custom_field_service.ListCustomFieldsRequest(request) diff --git a/packages/google-ads-admanager/google/ads/admanager_v1/services/custom_field_service/transports/rest.py b/packages/google-ads-admanager/google/ads/admanager_v1/services/custom_field_service/transports/rest.py index bac2201c8666..4f302464ca68 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/services/custom_field_service/transports/rest.py +++ b/packages/google-ads-admanager/google/ads/admanager_v1/services/custom_field_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = logging.getLogger(__name__) DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, @@ -86,8 +94,11 @@ def post_list_custom_fields(self, response): def pre_get_custom_field( self, request: custom_field_service.GetCustomFieldRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[custom_field_service.GetCustomFieldRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + custom_field_service.GetCustomFieldRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_custom_field Override in a subclass to manipulate the request or metadata @@ -109,8 +120,11 @@ def post_get_custom_field( def pre_list_custom_fields( self, request: custom_field_service.ListCustomFieldsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[custom_field_service.ListCustomFieldsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + custom_field_service.ListCustomFieldsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_custom_fields Override in a subclass to manipulate the request or metadata @@ -132,8 +146,10 @@ def post_list_custom_fields( 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 @@ -274,7 +290,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> custom_field_messages.CustomField: r"""Call the get custom field method over HTTP. @@ -284,8 +300,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.custom_field_messages.CustomField: @@ -297,6 +315,7 @@ def __call__( http_options = ( _BaseCustomFieldServiceRestTransport._BaseGetCustomField._get_http_options() ) + request, metadata = self._interceptor.pre_get_custom_field( request, metadata ) @@ -309,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.ads.admanager_v1.CustomFieldServiceClient.GetCustomField", + extra={ + "serviceName": "google.ads.admanager.v1.CustomFieldService", + "rpcName": "GetCustomField", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CustomFieldServiceRestTransport._GetCustomField._get_response( self._host, @@ -329,7 +375,31 @@ def __call__( pb_resp = custom_field_messages.CustomField.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_custom_field(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = custom_field_messages.CustomField.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ads.admanager_v1.CustomFieldServiceClient.get_custom_field", + extra={ + "serviceName": "google.ads.admanager.v1.CustomFieldService", + "rpcName": "GetCustomField", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCustomFields( @@ -367,7 +437,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> custom_field_service.ListCustomFieldsResponse: r"""Call the list custom fields method over HTTP. @@ -377,8 +447,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.custom_field_service.ListCustomFieldsResponse: @@ -390,6 +462,7 @@ def __call__( http_options = ( _BaseCustomFieldServiceRestTransport._BaseListCustomFields._get_http_options() ) + request, metadata = self._interceptor.pre_list_custom_fields( request, metadata ) @@ -402,6 +475,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.CustomFieldServiceClient.ListCustomFields", + extra={ + "serviceName": "google.ads.admanager.v1.CustomFieldService", + "rpcName": "ListCustomFields", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CustomFieldServiceRestTransport._ListCustomFields._get_response( self._host, @@ -422,7 +522,31 @@ def __call__( pb_resp = custom_field_service.ListCustomFieldsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_custom_fields(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + custom_field_service.ListCustomFieldsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ads.admanager_v1.CustomFieldServiceClient.list_custom_fields", + extra={ + "serviceName": "google.ads.admanager.v1.CustomFieldService", + "rpcName": "ListCustomFields", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -485,7 +609,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -495,8 +619,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -505,6 +631,7 @@ def __call__( http_options = ( _BaseCustomFieldServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseCustomFieldServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -515,6 +642,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.CustomFieldServiceClient.GetOperation", + extra={ + "serviceName": "google.ads.admanager.v1.CustomFieldService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CustomFieldServiceRestTransport._GetOperation._get_response( self._host, @@ -534,6 +688,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.ads.admanager_v1.CustomFieldServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.ads.admanager.v1.CustomFieldService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-ads-admanager/google/ads/admanager_v1/services/custom_targeting_key_service/client.py b/packages/google-ads-admanager/google/ads/admanager_v1/services/custom_targeting_key_service/client.py index dcf8d11e56a6..fd79c9e1f297 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/services/custom_targeting_key_service/client.py +++ b/packages/google-ads-admanager/google/ads/admanager_v1/services/custom_targeting_key_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.longrunning import operations_pb2 # type: ignore from google.ads.admanager_v1.services.custom_targeting_key_service 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( @@ -669,6 +683,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.ads.admanager_v1.CustomTargetingKeyServiceClient`.", + extra={ + "serviceName": "google.ads.admanager.v1.CustomTargetingKeyService", + "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.ads.admanager.v1.CustomTargetingKeyService", + "credentialsType": None, + }, + ) + def get_custom_targeting_key( self, request: Optional[ @@ -678,7 +715,7 @@ def get_custom_targeting_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]]] = (), ) -> custom_targeting_key_messages.CustomTargetingKey: r"""API to retrieve a ``CustomTargetingKey`` object. @@ -722,8 +759,10 @@ def sample_get_custom_targeting_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.ads.admanager_v1.types.CustomTargetingKey: @@ -783,7 +822,7 @@ def list_custom_targeting_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.ListCustomTargetingKeysPager: r"""API to retrieve a list of ``CustomTargetingKey`` objects. @@ -827,8 +866,10 @@ def sample_list_custom_targeting_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.ads.admanager_v1.services.custom_targeting_key_service.pagers.ListCustomTargetingKeysPager: @@ -918,7 +959,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. @@ -929,8 +970,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-ads-admanager/google/ads/admanager_v1/services/custom_targeting_key_service/pagers.py b/packages/google-ads-admanager/google/ads/admanager_v1/services/custom_targeting_key_service/pagers.py index 88953ea7950c..f6e6e1accd90 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/services/custom_targeting_key_service/pagers.py +++ b/packages/google-ads-admanager/google/ads/admanager_v1/services/custom_targeting_key_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 = custom_targeting_key_service.ListCustomTargetingKeysRequest( diff --git a/packages/google-ads-admanager/google/ads/admanager_v1/services/custom_targeting_key_service/transports/rest.py b/packages/google-ads-admanager/google/ads/admanager_v1/services/custom_targeting_key_service/transports/rest.py index 0a63d81f557c..cfb4d42815d2 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/services/custom_targeting_key_service/transports/rest.py +++ b/packages/google-ads-admanager/google/ads/admanager_v1/services/custom_targeting_key_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, @@ -89,10 +97,10 @@ def post_list_custom_targeting_keys(self, response): def pre_get_custom_targeting_key( self, request: custom_targeting_key_service.GetCustomTargetingKeyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ custom_targeting_key_service.GetCustomTargetingKeyRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_custom_targeting_key @@ -115,10 +123,10 @@ def post_get_custom_targeting_key( def pre_list_custom_targeting_keys( self, request: custom_targeting_key_service.ListCustomTargetingKeysRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ custom_targeting_key_service.ListCustomTargetingKeysRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_custom_targeting_keys @@ -141,8 +149,10 @@ def post_list_custom_targeting_keys( 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 @@ -285,7 +295,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> custom_targeting_key_messages.CustomTargetingKey: r"""Call the get custom targeting key method over HTTP. @@ -295,8 +305,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.custom_targeting_key_messages.CustomTargetingKey: @@ -306,6 +318,7 @@ def __call__( http_options = ( _BaseCustomTargetingKeyServiceRestTransport._BaseGetCustomTargetingKey._get_http_options() ) + request, metadata = self._interceptor.pre_get_custom_targeting_key( request, metadata ) @@ -318,6 +331,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.CustomTargetingKeyServiceClient.GetCustomTargetingKey", + extra={ + "serviceName": "google.ads.admanager.v1.CustomTargetingKeyService", + "rpcName": "GetCustomTargetingKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CustomTargetingKeyServiceRestTransport._GetCustomTargetingKey._get_response( self._host, @@ -338,7 +378,33 @@ def __call__( pb_resp = custom_targeting_key_messages.CustomTargetingKey.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_custom_targeting_key(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + custom_targeting_key_messages.CustomTargetingKey.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ads.admanager_v1.CustomTargetingKeyServiceClient.get_custom_targeting_key", + extra={ + "serviceName": "google.ads.admanager.v1.CustomTargetingKeyService", + "rpcName": "GetCustomTargetingKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCustomTargetingKeys( @@ -378,7 +444,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> custom_targeting_key_service.ListCustomTargetingKeysResponse: r"""Call the list custom targeting keys method over HTTP. @@ -389,8 +455,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.custom_targeting_key_service.ListCustomTargetingKeysResponse: @@ -402,6 +470,7 @@ def __call__( http_options = ( _BaseCustomTargetingKeyServiceRestTransport._BaseListCustomTargetingKeys._get_http_options() ) + request, metadata = self._interceptor.pre_list_custom_targeting_keys( request, metadata ) @@ -414,6 +483,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.CustomTargetingKeyServiceClient.ListCustomTargetingKeys", + extra={ + "serviceName": "google.ads.admanager.v1.CustomTargetingKeyService", + "rpcName": "ListCustomTargetingKeys", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CustomTargetingKeyServiceRestTransport._ListCustomTargetingKeys._get_response( self._host, @@ -436,7 +532,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_custom_targeting_keys(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = custom_targeting_key_service.ListCustomTargetingKeysResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ads.admanager_v1.CustomTargetingKeyServiceClient.list_custom_targeting_keys", + extra={ + "serviceName": "google.ads.admanager.v1.CustomTargetingKeyService", + "rpcName": "ListCustomTargetingKeys", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -500,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -510,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: operations_pb2.Operation: Response from GetOperation method. @@ -520,6 +642,7 @@ def __call__( http_options = ( _BaseCustomTargetingKeyServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseCustomTargetingKeyServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -530,6 +653,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.CustomTargetingKeyServiceClient.GetOperation", + extra={ + "serviceName": "google.ads.admanager.v1.CustomTargetingKeyService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CustomTargetingKeyServiceRestTransport._GetOperation._get_response( @@ -551,6 +701,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.ads.admanager_v1.CustomTargetingKeyServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.ads.admanager.v1.CustomTargetingKeyService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-ads-admanager/google/ads/admanager_v1/services/custom_targeting_value_service/client.py b/packages/google-ads-admanager/google/ads/admanager_v1/services/custom_targeting_value_service/client.py index d368fd9f95b7..eb982112d026 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/services/custom_targeting_value_service/client.py +++ b/packages/google-ads-admanager/google/ads/admanager_v1/services/custom_targeting_value_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.longrunning import operations_pb2 # type: ignore from google.ads.admanager_v1.services.custom_targeting_value_service import pagers @@ -612,6 +622,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.ads.admanager_v1.CustomTargetingValueServiceClient`.", + extra={ + "serviceName": "google.ads.admanager.v1.CustomTargetingValueService", + "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.ads.admanager.v1.CustomTargetingValueService", + "credentialsType": None, + }, + ) + def get_custom_targeting_value( self, request: Optional[ @@ -689,7 +726,7 @@ def get_custom_targeting_value( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> custom_targeting_value_messages.CustomTargetingValue: r"""API to retrieve a ``CustomTargetingValue`` object. @@ -733,8 +770,10 @@ def sample_get_custom_targeting_value(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ads.admanager_v1.types.CustomTargetingValue: @@ -798,7 +837,7 @@ def list_custom_targeting_values( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCustomTargetingValuesPager: r"""API to retrieve a list of ``CustomTargetingValue`` objects. @@ -843,8 +882,10 @@ def sample_list_custom_targeting_values(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ads.admanager_v1.services.custom_targeting_value_service.pagers.ListCustomTargetingValuesPager: @@ -934,7 +975,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. @@ -945,8 +986,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-ads-admanager/google/ads/admanager_v1/services/custom_targeting_value_service/pagers.py b/packages/google-ads-admanager/google/ads/admanager_v1/services/custom_targeting_value_service/pagers.py index 214d53becdec..44ef41f9a4bb 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/services/custom_targeting_value_service/pagers.py +++ b/packages/google-ads-admanager/google/ads/admanager_v1/services/custom_targeting_value_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 = custom_targeting_value_service.ListCustomTargetingValuesRequest( diff --git a/packages/google-ads-admanager/google/ads/admanager_v1/services/custom_targeting_value_service/transports/rest.py b/packages/google-ads-admanager/google/ads/admanager_v1/services/custom_targeting_value_service/transports/rest.py index 0ea25cc15a45..1528b6133e5e 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/services/custom_targeting_value_service/transports/rest.py +++ b/packages/google-ads-admanager/google/ads/admanager_v1/services/custom_targeting_value_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, @@ -89,10 +97,10 @@ def post_list_custom_targeting_values(self, response): def pre_get_custom_targeting_value( self, request: custom_targeting_value_service.GetCustomTargetingValueRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ custom_targeting_value_service.GetCustomTargetingValueRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_custom_targeting_value @@ -115,10 +123,10 @@ def post_get_custom_targeting_value( def pre_list_custom_targeting_values( self, request: custom_targeting_value_service.ListCustomTargetingValuesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ custom_targeting_value_service.ListCustomTargetingValuesRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_custom_targeting_values @@ -141,8 +149,10 @@ def post_list_custom_targeting_values( 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 @@ -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]]] = (), ) -> custom_targeting_value_messages.CustomTargetingValue: r"""Call the get custom targeting value method over HTTP. @@ -298,8 +308,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.custom_targeting_value_messages.CustomTargetingValue: @@ -309,6 +321,7 @@ def __call__( http_options = ( _BaseCustomTargetingValueServiceRestTransport._BaseGetCustomTargetingValue._get_http_options() ) + request, metadata = self._interceptor.pre_get_custom_targeting_value( request, metadata ) @@ -321,6 +334,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.CustomTargetingValueServiceClient.GetCustomTargetingValue", + extra={ + "serviceName": "google.ads.admanager.v1.CustomTargetingValueService", + "rpcName": "GetCustomTargetingValue", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CustomTargetingValueServiceRestTransport._GetCustomTargetingValue._get_response( self._host, @@ -341,7 +381,33 @@ def __call__( pb_resp = custom_targeting_value_messages.CustomTargetingValue.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_custom_targeting_value(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + custom_targeting_value_messages.CustomTargetingValue.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ads.admanager_v1.CustomTargetingValueServiceClient.get_custom_targeting_value", + extra={ + "serviceName": "google.ads.admanager.v1.CustomTargetingValueService", + "rpcName": "GetCustomTargetingValue", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCustomTargetingValues( @@ -381,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]]] = (), ) -> custom_targeting_value_service.ListCustomTargetingValuesResponse: r"""Call the list custom targeting values method over HTTP. @@ -392,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: ~.custom_targeting_value_service.ListCustomTargetingValuesResponse: @@ -405,6 +473,7 @@ def __call__( http_options = ( _BaseCustomTargetingValueServiceRestTransport._BaseListCustomTargetingValues._get_http_options() ) + request, metadata = self._interceptor.pre_list_custom_targeting_values( request, metadata ) @@ -417,6 +486,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.CustomTargetingValueServiceClient.ListCustomTargetingValues", + extra={ + "serviceName": "google.ads.admanager.v1.CustomTargetingValueService", + "rpcName": "ListCustomTargetingValues", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CustomTargetingValueServiceRestTransport._ListCustomTargetingValues._get_response( self._host, @@ -441,7 +537,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_custom_targeting_values(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = custom_targeting_value_service.ListCustomTargetingValuesResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ads.admanager_v1.CustomTargetingValueServiceClient.list_custom_targeting_values", + extra={ + "serviceName": "google.ads.admanager.v1.CustomTargetingValueService", + "rpcName": "ListCustomTargetingValues", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -505,7 +625,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -515,8 +635,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -525,6 +647,7 @@ def __call__( http_options = ( _BaseCustomTargetingValueServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseCustomTargetingValueServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -535,6 +658,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.CustomTargetingValueServiceClient.GetOperation", + extra={ + "serviceName": "google.ads.admanager.v1.CustomTargetingValueService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CustomTargetingValueServiceRestTransport._GetOperation._get_response( @@ -556,6 +706,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.ads.admanager_v1.CustomTargetingValueServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.ads.admanager.v1.CustomTargetingValueService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-ads-admanager/google/ads/admanager_v1/services/entity_signals_mapping_service/client.py b/packages/google-ads-admanager/google/ads/admanager_v1/services/entity_signals_mapping_service/client.py index 072cd036e7f5..f8a09d16a91a 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/services/entity_signals_mapping_service/client.py +++ b/packages/google-ads-admanager/google/ads/admanager_v1/services/entity_signals_mapping_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.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_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( @@ -671,6 +685,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.ads.admanager_v1.EntitySignalsMappingServiceClient`.", + extra={ + "serviceName": "google.ads.admanager.v1.EntitySignalsMappingService", + "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.ads.admanager.v1.EntitySignalsMappingService", + "credentialsType": None, + }, + ) + def get_entity_signals_mapping( self, request: Optional[ @@ -680,7 +717,7 @@ def get_entity_signals_mapping( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> entity_signals_mapping_messages.EntitySignalsMapping: r"""API to retrieve a ``EntitySignalsMapping`` object. @@ -724,8 +761,10 @@ def sample_get_entity_signals_mapping(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ads.admanager_v1.types.EntitySignalsMapping: @@ -789,7 +828,7 @@ def list_entity_signals_mappings( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListEntitySignalsMappingsPager: r"""API to retrieve a list of ``EntitySignalsMapping`` objects. @@ -834,8 +873,10 @@ def sample_list_entity_signals_mappings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ads.admanager_v1.services.entity_signals_mapping_service.pagers.ListEntitySignalsMappingsPager: @@ -920,7 +961,7 @@ def create_entity_signals_mapping( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> entity_signals_mapping_messages.EntitySignalsMapping: r"""API to create an ``EntitySignalsMapping`` object. @@ -977,8 +1018,10 @@ def sample_create_entity_signals_mapping(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ads.admanager_v1.types.EntitySignalsMapping: @@ -1049,7 +1092,7 @@ def update_entity_signals_mapping( 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]]] = (), ) -> entity_signals_mapping_messages.EntitySignalsMapping: r"""API to update an ``EntitySignalsMapping`` object. @@ -1107,8 +1150,10 @@ def sample_update_entity_signals_mapping(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ads.admanager_v1.types.EntitySignalsMapping: @@ -1184,7 +1229,7 @@ def batch_create_entity_signals_mappings( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> entity_signals_mapping_service.BatchCreateEntitySignalsMappingsResponse: r"""API to batch create ``EntitySignalsMapping`` objects. @@ -1244,8 +1289,10 @@ def sample_batch_create_entity_signals_mappings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ads.admanager_v1.types.BatchCreateEntitySignalsMappingsResponse: @@ -1324,7 +1371,7 @@ def batch_update_entity_signals_mappings( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> entity_signals_mapping_service.BatchUpdateEntitySignalsMappingsResponse: r"""API to batch update ``EntitySignalsMapping`` objects. @@ -1383,8 +1430,10 @@ def sample_batch_update_entity_signals_mappings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ads.admanager_v1.types.BatchUpdateEntitySignalsMappingsResponse: @@ -1465,7 +1514,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. @@ -1476,8 +1525,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-ads-admanager/google/ads/admanager_v1/services/entity_signals_mapping_service/pagers.py b/packages/google-ads-admanager/google/ads/admanager_v1/services/entity_signals_mapping_service/pagers.py index 464c0fe8d515..f788389e4244 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/services/entity_signals_mapping_service/pagers.py +++ b/packages/google-ads-admanager/google/ads/admanager_v1/services/entity_signals_mapping_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 = entity_signals_mapping_service.ListEntitySignalsMappingsRequest( diff --git a/packages/google-ads-admanager/google/ads/admanager_v1/services/entity_signals_mapping_service/transports/rest.py b/packages/google-ads-admanager/google/ads/admanager_v1/services/entity_signals_mapping_service/transports/rest.py index a3f40470a661..7883b1005e15 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/services/entity_signals_mapping_service/transports/rest.py +++ b/packages/google-ads-admanager/google/ads/admanager_v1/services/entity_signals_mapping_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -41,6 +41,14 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = logging.getLogger(__name__) DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, @@ -121,10 +129,10 @@ def post_update_entity_signals_mapping(self, response): def pre_batch_create_entity_signals_mappings( self, request: entity_signals_mapping_service.BatchCreateEntitySignalsMappingsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ entity_signals_mapping_service.BatchCreateEntitySignalsMappingsRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for batch_create_entity_signals_mappings @@ -148,10 +156,10 @@ def post_batch_create_entity_signals_mappings( def pre_batch_update_entity_signals_mappings( self, request: entity_signals_mapping_service.BatchUpdateEntitySignalsMappingsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ entity_signals_mapping_service.BatchUpdateEntitySignalsMappingsRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for batch_update_entity_signals_mappings @@ -175,10 +183,10 @@ def post_batch_update_entity_signals_mappings( def pre_create_entity_signals_mapping( self, request: entity_signals_mapping_service.CreateEntitySignalsMappingRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ entity_signals_mapping_service.CreateEntitySignalsMappingRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_entity_signals_mapping @@ -201,10 +209,10 @@ def post_create_entity_signals_mapping( def pre_get_entity_signals_mapping( self, request: entity_signals_mapping_service.GetEntitySignalsMappingRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ entity_signals_mapping_service.GetEntitySignalsMappingRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_entity_signals_mapping @@ -227,10 +235,10 @@ def post_get_entity_signals_mapping( def pre_list_entity_signals_mappings( self, request: entity_signals_mapping_service.ListEntitySignalsMappingsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ entity_signals_mapping_service.ListEntitySignalsMappingsRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_entity_signals_mappings @@ -253,10 +261,10 @@ def post_list_entity_signals_mappings( def pre_update_entity_signals_mapping( self, request: entity_signals_mapping_service.UpdateEntitySignalsMappingRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ entity_signals_mapping_service.UpdateEntitySignalsMappingRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_entity_signals_mapping @@ -279,8 +287,10 @@ def post_update_entity_signals_mapping( 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 @@ -426,7 +436,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> entity_signals_mapping_service.BatchCreateEntitySignalsMappingsResponse: r"""Call the batch create entity signals mappings method over HTTP. @@ -438,8 +448,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.entity_signals_mapping_service.BatchCreateEntitySignalsMappingsResponse: @@ -451,6 +463,7 @@ def __call__( http_options = ( _BaseEntitySignalsMappingServiceRestTransport._BaseBatchCreateEntitySignalsMappings._get_http_options() ) + ( request, metadata, @@ -470,6 +483,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.EntitySignalsMappingServiceClient.BatchCreateEntitySignalsMappings", + extra={ + "serviceName": "google.ads.admanager.v1.EntitySignalsMappingService", + "rpcName": "BatchCreateEntitySignalsMappings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EntitySignalsMappingServiceRestTransport._BatchCreateEntitySignalsMappings._get_response( self._host, @@ -495,7 +535,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_create_entity_signals_mappings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = entity_signals_mapping_service.BatchCreateEntitySignalsMappingsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ads.admanager_v1.EntitySignalsMappingServiceClient.batch_create_entity_signals_mappings", + extra={ + "serviceName": "google.ads.admanager.v1.EntitySignalsMappingService", + "rpcName": "BatchCreateEntitySignalsMappings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchUpdateEntitySignalsMappings( @@ -536,7 +600,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> entity_signals_mapping_service.BatchUpdateEntitySignalsMappingsResponse: r"""Call the batch update entity signals mappings method over HTTP. @@ -548,8 +612,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.entity_signals_mapping_service.BatchUpdateEntitySignalsMappingsResponse: @@ -561,6 +627,7 @@ def __call__( http_options = ( _BaseEntitySignalsMappingServiceRestTransport._BaseBatchUpdateEntitySignalsMappings._get_http_options() ) + ( request, metadata, @@ -580,6 +647,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.EntitySignalsMappingServiceClient.BatchUpdateEntitySignalsMappings", + extra={ + "serviceName": "google.ads.admanager.v1.EntitySignalsMappingService", + "rpcName": "BatchUpdateEntitySignalsMappings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EntitySignalsMappingServiceRestTransport._BatchUpdateEntitySignalsMappings._get_response( self._host, @@ -605,7 +699,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_update_entity_signals_mappings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = entity_signals_mapping_service.BatchUpdateEntitySignalsMappingsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ads.admanager_v1.EntitySignalsMappingServiceClient.batch_update_entity_signals_mappings", + extra={ + "serviceName": "google.ads.admanager.v1.EntitySignalsMappingService", + "rpcName": "BatchUpdateEntitySignalsMappings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateEntitySignalsMapping( @@ -646,7 +764,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> entity_signals_mapping_messages.EntitySignalsMapping: r"""Call the create entity signals mapping method over HTTP. @@ -658,8 +776,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.entity_signals_mapping_messages.EntitySignalsMapping: @@ -669,6 +789,7 @@ def __call__( http_options = ( _BaseEntitySignalsMappingServiceRestTransport._BaseCreateEntitySignalsMapping._get_http_options() ) + request, metadata = self._interceptor.pre_create_entity_signals_mapping( request, metadata ) @@ -685,6 +806,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.EntitySignalsMappingServiceClient.CreateEntitySignalsMapping", + extra={ + "serviceName": "google.ads.admanager.v1.EntitySignalsMappingService", + "rpcName": "CreateEntitySignalsMapping", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EntitySignalsMappingServiceRestTransport._CreateEntitySignalsMapping._get_response( self._host, @@ -706,7 +854,33 @@ def __call__( pb_resp = entity_signals_mapping_messages.EntitySignalsMapping.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_entity_signals_mapping(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + entity_signals_mapping_messages.EntitySignalsMapping.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ads.admanager_v1.EntitySignalsMappingServiceClient.create_entity_signals_mapping", + extra={ + "serviceName": "google.ads.admanager.v1.EntitySignalsMappingService", + "rpcName": "CreateEntitySignalsMapping", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetEntitySignalsMapping( @@ -746,7 +920,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> entity_signals_mapping_messages.EntitySignalsMapping: r"""Call the get entity signals mapping method over HTTP. @@ -757,8 +931,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.entity_signals_mapping_messages.EntitySignalsMapping: @@ -768,6 +944,7 @@ def __call__( http_options = ( _BaseEntitySignalsMappingServiceRestTransport._BaseGetEntitySignalsMapping._get_http_options() ) + request, metadata = self._interceptor.pre_get_entity_signals_mapping( request, metadata ) @@ -780,6 +957,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.EntitySignalsMappingServiceClient.GetEntitySignalsMapping", + extra={ + "serviceName": "google.ads.admanager.v1.EntitySignalsMappingService", + "rpcName": "GetEntitySignalsMapping", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EntitySignalsMappingServiceRestTransport._GetEntitySignalsMapping._get_response( self._host, @@ -800,7 +1004,33 @@ def __call__( pb_resp = entity_signals_mapping_messages.EntitySignalsMapping.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_entity_signals_mapping(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + entity_signals_mapping_messages.EntitySignalsMapping.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ads.admanager_v1.EntitySignalsMappingServiceClient.get_entity_signals_mapping", + extra={ + "serviceName": "google.ads.admanager.v1.EntitySignalsMappingService", + "rpcName": "GetEntitySignalsMapping", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListEntitySignalsMappings( @@ -840,7 +1070,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> entity_signals_mapping_service.ListEntitySignalsMappingsResponse: r"""Call the list entity signals mappings method over HTTP. @@ -851,8 +1081,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.entity_signals_mapping_service.ListEntitySignalsMappingsResponse: @@ -864,6 +1096,7 @@ def __call__( http_options = ( _BaseEntitySignalsMappingServiceRestTransport._BaseListEntitySignalsMappings._get_http_options() ) + request, metadata = self._interceptor.pre_list_entity_signals_mappings( request, metadata ) @@ -876,6 +1109,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.EntitySignalsMappingServiceClient.ListEntitySignalsMappings", + extra={ + "serviceName": "google.ads.admanager.v1.EntitySignalsMappingService", + "rpcName": "ListEntitySignalsMappings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EntitySignalsMappingServiceRestTransport._ListEntitySignalsMappings._get_response( self._host, @@ -900,7 +1160,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_entity_signals_mappings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = entity_signals_mapping_service.ListEntitySignalsMappingsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ads.admanager_v1.EntitySignalsMappingServiceClient.list_entity_signals_mappings", + extra={ + "serviceName": "google.ads.admanager.v1.EntitySignalsMappingService", + "rpcName": "ListEntitySignalsMappings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateEntitySignalsMapping( @@ -941,7 +1225,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> entity_signals_mapping_messages.EntitySignalsMapping: r"""Call the update entity signals mapping method over HTTP. @@ -953,8 +1237,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.entity_signals_mapping_messages.EntitySignalsMapping: @@ -964,6 +1250,7 @@ def __call__( http_options = ( _BaseEntitySignalsMappingServiceRestTransport._BaseUpdateEntitySignalsMapping._get_http_options() ) + request, metadata = self._interceptor.pre_update_entity_signals_mapping( request, metadata ) @@ -980,6 +1267,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.EntitySignalsMappingServiceClient.UpdateEntitySignalsMapping", + extra={ + "serviceName": "google.ads.admanager.v1.EntitySignalsMappingService", + "rpcName": "UpdateEntitySignalsMapping", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = EntitySignalsMappingServiceRestTransport._UpdateEntitySignalsMapping._get_response( self._host, @@ -1001,7 +1315,33 @@ def __call__( pb_resp = entity_signals_mapping_messages.EntitySignalsMapping.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_entity_signals_mapping(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + entity_signals_mapping_messages.EntitySignalsMapping.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ads.admanager_v1.EntitySignalsMappingServiceClient.update_entity_signals_mapping", + extra={ + "serviceName": "google.ads.admanager.v1.EntitySignalsMappingService", + "rpcName": "UpdateEntitySignalsMapping", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1109,7 +1449,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1119,8 +1459,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -1129,6 +1471,7 @@ def __call__( http_options = ( _BaseEntitySignalsMappingServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseEntitySignalsMappingServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1139,6 +1482,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.EntitySignalsMappingServiceClient.GetOperation", + extra={ + "serviceName": "google.ads.admanager.v1.EntitySignalsMappingService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( EntitySignalsMappingServiceRestTransport._GetOperation._get_response( @@ -1160,6 +1530,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.ads.admanager_v1.EntitySignalsMappingServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.ads.admanager.v1.EntitySignalsMappingService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-ads-admanager/google/ads/admanager_v1/services/network_service/client.py b/packages/google-ads-admanager/google/ads/admanager_v1/services/network_service/client.py index 6d6e51f15d37..a55f2e1974bc 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/services/network_service/client.py +++ b/packages/google-ads-admanager/google/ads/admanager_v1/services/network_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.longrunning import operations_pb2 # type: ignore from google.ads.admanager_v1.types import network_messages, network_service @@ -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( @@ -650,6 +664,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.ads.admanager_v1.NetworkServiceClient`.", + extra={ + "serviceName": "google.ads.admanager.v1.NetworkService", + "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.ads.admanager.v1.NetworkService", + "credentialsType": None, + }, + ) + def get_network( self, request: Optional[Union[network_service.GetNetworkRequest, dict]] = None, @@ -657,7 +694,7 @@ def get_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]]] = (), ) -> network_messages.Network: r"""API to retrieve a Network object. @@ -700,8 +737,10 @@ def sample_get_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.ads.admanager_v1.types.Network: @@ -756,7 +795,7 @@ def list_networks( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> network_service.ListNetworksResponse: r"""API to retrieve all the networks the current user has access to. @@ -792,8 +831,10 @@ def sample_list_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.ads.admanager_v1.types.ListNetworksResponse: @@ -842,7 +883,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. @@ -853,8 +894,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-ads-admanager/google/ads/admanager_v1/services/network_service/transports/rest.py b/packages/google-ads-admanager/google/ads/admanager_v1/services/network_service/transports/rest.py index c8371987cf23..3546c7b0022b 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/services/network_service/transports/rest.py +++ b/packages/google-ads-admanager/google/ads/admanager_v1/services/network_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = logging.getLogger(__name__) DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, @@ -86,8 +94,10 @@ def post_list_networks(self, response): def pre_get_network( self, request: network_service.GetNetworkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[network_service.GetNetworkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + network_service.GetNetworkRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_network Override in a subclass to manipulate the request or metadata @@ -109,8 +119,10 @@ def post_get_network( def pre_list_networks( self, request: network_service.ListNetworksRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[network_service.ListNetworksRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + network_service.ListNetworksRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_networks Override in a subclass to manipulate the request or metadata @@ -132,8 +144,10 @@ def post_list_networks( 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 @@ -273,7 +287,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> network_messages.Network: r"""Call the get network method over HTTP. @@ -283,8 +297,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.network_messages.Network: @@ -294,6 +310,7 @@ def __call__( http_options = ( _BaseNetworkServiceRestTransport._BaseGetNetwork._get_http_options() ) + request, metadata = self._interceptor.pre_get_network(request, metadata) transcoded_request = _BaseNetworkServiceRestTransport._BaseGetNetwork._get_transcoded_request( http_options, request @@ -306,6 +323,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.NetworkServiceClient.GetNetwork", + extra={ + "serviceName": "google.ads.admanager.v1.NetworkService", + "rpcName": "GetNetwork", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworkServiceRestTransport._GetNetwork._get_response( self._host, @@ -326,7 +370,29 @@ def __call__( pb_resp = network_messages.Network.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_network(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = network_messages.Network.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ads.admanager_v1.NetworkServiceClient.get_network", + extra={ + "serviceName": "google.ads.admanager.v1.NetworkService", + "rpcName": "GetNetwork", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListNetworks( @@ -363,7 +429,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> network_service.ListNetworksResponse: r"""Call the list networks method over HTTP. @@ -373,8 +439,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.network_service.ListNetworksResponse: @@ -384,6 +452,7 @@ def __call__( http_options = ( _BaseNetworkServiceRestTransport._BaseListNetworks._get_http_options() ) + request, metadata = self._interceptor.pre_list_networks(request, metadata) transcoded_request = _BaseNetworkServiceRestTransport._BaseListNetworks._get_transcoded_request( http_options, request @@ -394,6 +463,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.NetworkServiceClient.ListNetworks", + extra={ + "serviceName": "google.ads.admanager.v1.NetworkService", + "rpcName": "ListNetworks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworkServiceRestTransport._ListNetworks._get_response( self._host, @@ -414,7 +510,31 @@ def __call__( pb_resp = network_service.ListNetworksResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_networks(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = network_service.ListNetworksResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ads.admanager_v1.NetworkServiceClient.list_networks", + extra={ + "serviceName": "google.ads.admanager.v1.NetworkService", + "rpcName": "ListNetworks", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -473,7 +593,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -483,8 +603,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -493,6 +615,7 @@ def __call__( http_options = ( _BaseNetworkServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseNetworkServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -503,6 +626,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.NetworkServiceClient.GetOperation", + extra={ + "serviceName": "google.ads.admanager.v1.NetworkService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = NetworkServiceRestTransport._GetOperation._get_response( self._host, @@ -522,6 +672,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.ads.admanager_v1.NetworkServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.ads.admanager.v1.NetworkService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-ads-admanager/google/ads/admanager_v1/services/order_service/client.py b/packages/google-ads-admanager/google/ads/admanager_v1/services/order_service/client.py index 3f8f3ca57f7f..9f0bd4093669 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/services/order_service/client.py +++ b/packages/google-ads-admanager/google/ads/admanager_v1/services/order_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.longrunning import operations_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -699,6 +709,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( @@ -761,6 +775,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.ads.admanager_v1.OrderServiceClient`.", + extra={ + "serviceName": "google.ads.admanager.v1.OrderService", + "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.ads.admanager.v1.OrderService", + "credentialsType": None, + }, + ) + def get_order( self, request: Optional[Union[order_service.GetOrderRequest, dict]] = None, @@ -768,7 +805,7 @@ def get_order( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> order_messages.Order: r"""API to retrieve an Order object. @@ -811,8 +848,10 @@ def sample_get_order(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ads.admanager_v1.types.Order: @@ -868,7 +907,7 @@ def list_orders( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListOrdersPager: r"""API to retrieve a list of ``Order`` objects. @@ -918,8 +957,10 @@ def sample_list_orders(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ads.admanager_v1.services.order_service.pagers.ListOrdersPager: @@ -1003,7 +1044,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. @@ -1014,8 +1055,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-ads-admanager/google/ads/admanager_v1/services/order_service/pagers.py b/packages/google-ads-admanager/google/ads/admanager_v1/services/order_service/pagers.py index 6990818382ad..cbd58ecf2aa7 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/services/order_service/pagers.py +++ b/packages/google-ads-admanager/google/ads/admanager_v1/services/order_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 = order_service.ListOrdersRequest(request) diff --git a/packages/google-ads-admanager/google/ads/admanager_v1/services/order_service/transports/rest.py b/packages/google-ads-admanager/google/ads/admanager_v1/services/order_service/transports/rest.py index 8a59e535cc49..8e683e62aca0 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/services/order_service/transports/rest.py +++ b/packages/google-ads-admanager/google/ads/admanager_v1/services/order_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = logging.getLogger(__name__) DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, @@ -86,8 +94,8 @@ def post_list_orders(self, response): def pre_get_order( self, request: order_service.GetOrderRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[order_service.GetOrderRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[order_service.GetOrderRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_order Override in a subclass to manipulate the request or metadata @@ -107,8 +115,10 @@ def post_get_order(self, response: order_messages.Order) -> order_messages.Order def pre_list_orders( self, request: order_service.ListOrdersRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[order_service.ListOrdersRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + order_service.ListOrdersRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_orders Override in a subclass to manipulate the request or metadata @@ -130,8 +140,10 @@ def post_list_orders( 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 @@ -269,7 +281,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> order_messages.Order: r"""Call the get order method over HTTP. @@ -279,8 +291,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.order_messages.Order: @@ -290,6 +304,7 @@ def __call__( http_options = ( _BaseOrderServiceRestTransport._BaseGetOrder._get_http_options() ) + request, metadata = self._interceptor.pre_get_order(request, metadata) transcoded_request = ( _BaseOrderServiceRestTransport._BaseGetOrder._get_transcoded_request( @@ -304,6 +319,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.OrderServiceClient.GetOrder", + extra={ + "serviceName": "google.ads.admanager.v1.OrderService", + "rpcName": "GetOrder", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OrderServiceRestTransport._GetOrder._get_response( self._host, @@ -324,7 +366,29 @@ def __call__( pb_resp = order_messages.Order.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_order(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = order_messages.Order.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ads.admanager_v1.OrderServiceClient.get_order", + extra={ + "serviceName": "google.ads.admanager.v1.OrderService", + "rpcName": "GetOrder", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListOrders( @@ -361,7 +425,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> order_service.ListOrdersResponse: r"""Call the list orders method over HTTP. @@ -371,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: ~.order_service.ListOrdersResponse: @@ -384,6 +450,7 @@ def __call__( http_options = ( _BaseOrderServiceRestTransport._BaseListOrders._get_http_options() ) + request, metadata = self._interceptor.pre_list_orders(request, metadata) transcoded_request = ( _BaseOrderServiceRestTransport._BaseListOrders._get_transcoded_request( @@ -398,6 +465,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.OrderServiceClient.ListOrders", + extra={ + "serviceName": "google.ads.admanager.v1.OrderService", + "rpcName": "ListOrders", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OrderServiceRestTransport._ListOrders._get_response( self._host, @@ -418,7 +512,31 @@ def __call__( pb_resp = order_service.ListOrdersResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_orders(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = order_service.ListOrdersResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ads.admanager_v1.OrderServiceClient.list_orders", + extra={ + "serviceName": "google.ads.admanager.v1.OrderService", + "rpcName": "ListOrders", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -475,7 +593,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -485,8 +603,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -495,6 +615,7 @@ def __call__( http_options = ( _BaseOrderServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseOrderServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -507,6 +628,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.OrderServiceClient.GetOperation", + extra={ + "serviceName": "google.ads.admanager.v1.OrderService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = OrderServiceRestTransport._GetOperation._get_response( self._host, @@ -526,6 +674,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.ads.admanager_v1.OrderServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.ads.admanager.v1.OrderService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-ads-admanager/google/ads/admanager_v1/services/placement_service/client.py b/packages/google-ads-admanager/google/ads/admanager_v1/services/placement_service/client.py index 3c8735de6913..df86540e30dd 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/services/placement_service/client.py +++ b/packages/google-ads-admanager/google/ads/admanager_v1/services/placement_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.longrunning import operations_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -612,6 +622,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( @@ -678,6 +692,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.ads.admanager_v1.PlacementServiceClient`.", + extra={ + "serviceName": "google.ads.admanager.v1.PlacementService", + "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.ads.admanager.v1.PlacementService", + "credentialsType": None, + }, + ) + def get_placement( self, request: Optional[Union[placement_service.GetPlacementRequest, dict]] = None, @@ -685,7 +722,7 @@ def get_placement( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> placement_messages.Placement: r"""API to retrieve a ``Placement`` object. @@ -728,8 +765,10 @@ def sample_get_placement(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ads.admanager_v1.types.Placement: @@ -785,7 +824,7 @@ def list_placements( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPlacementsPager: r"""API to retrieve a list of ``Placement`` objects. @@ -829,8 +868,10 @@ def sample_list_placements(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ads.admanager_v1.services.placement_service.pagers.ListPlacementsPager: @@ -914,7 +955,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. @@ -925,8 +966,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-ads-admanager/google/ads/admanager_v1/services/placement_service/pagers.py b/packages/google-ads-admanager/google/ads/admanager_v1/services/placement_service/pagers.py index 8dfe5d886b93..0a66c3c7cb71 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/services/placement_service/pagers.py +++ b/packages/google-ads-admanager/google/ads/admanager_v1/services/placement_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 = placement_service.ListPlacementsRequest(request) diff --git a/packages/google-ads-admanager/google/ads/admanager_v1/services/placement_service/transports/rest.py b/packages/google-ads-admanager/google/ads/admanager_v1/services/placement_service/transports/rest.py index 91b2c58d3515..8e8f883e3453 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/services/placement_service/transports/rest.py +++ b/packages/google-ads-admanager/google/ads/admanager_v1/services/placement_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = logging.getLogger(__name__) DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, @@ -86,8 +94,10 @@ def post_list_placements(self, response): def pre_get_placement( self, request: placement_service.GetPlacementRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[placement_service.GetPlacementRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + placement_service.GetPlacementRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_placement Override in a subclass to manipulate the request or metadata @@ -109,8 +119,10 @@ def post_get_placement( def pre_list_placements( self, request: placement_service.ListPlacementsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[placement_service.ListPlacementsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + placement_service.ListPlacementsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_placements Override in a subclass to manipulate the request or metadata @@ -132,8 +144,10 @@ def post_list_placements( 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 @@ -273,7 +287,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> placement_messages.Placement: r"""Call the get placement method over HTTP. @@ -283,8 +297,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.placement_messages.Placement: @@ -294,6 +310,7 @@ def __call__( http_options = ( _BasePlacementServiceRestTransport._BaseGetPlacement._get_http_options() ) + request, metadata = self._interceptor.pre_get_placement(request, metadata) transcoded_request = _BasePlacementServiceRestTransport._BaseGetPlacement._get_transcoded_request( http_options, request @@ -304,6 +321,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.PlacementServiceClient.GetPlacement", + extra={ + "serviceName": "google.ads.admanager.v1.PlacementService", + "rpcName": "GetPlacement", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PlacementServiceRestTransport._GetPlacement._get_response( self._host, @@ -324,7 +368,29 @@ def __call__( pb_resp = placement_messages.Placement.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_placement(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = placement_messages.Placement.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ads.admanager_v1.PlacementServiceClient.get_placement", + extra={ + "serviceName": "google.ads.admanager.v1.PlacementService", + "rpcName": "GetPlacement", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListPlacements( @@ -361,7 +427,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> placement_service.ListPlacementsResponse: r"""Call the list placements method over HTTP. @@ -371,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: ~.placement_service.ListPlacementsResponse: @@ -384,6 +452,7 @@ def __call__( http_options = ( _BasePlacementServiceRestTransport._BaseListPlacements._get_http_options() ) + request, metadata = self._interceptor.pre_list_placements(request, metadata) transcoded_request = _BasePlacementServiceRestTransport._BaseListPlacements._get_transcoded_request( http_options, request @@ -394,6 +463,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.PlacementServiceClient.ListPlacements", + extra={ + "serviceName": "google.ads.admanager.v1.PlacementService", + "rpcName": "ListPlacements", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PlacementServiceRestTransport._ListPlacements._get_response( self._host, @@ -414,7 +510,31 @@ def __call__( pb_resp = placement_service.ListPlacementsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_placements(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = placement_service.ListPlacementsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ads.admanager_v1.PlacementServiceClient.list_placements", + extra={ + "serviceName": "google.ads.admanager.v1.PlacementService", + "rpcName": "ListPlacements", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -476,7 +596,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -486,8 +606,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -496,6 +618,7 @@ def __call__( http_options = ( _BasePlacementServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BasePlacementServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -506,6 +629,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.PlacementServiceClient.GetOperation", + extra={ + "serviceName": "google.ads.admanager.v1.PlacementService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PlacementServiceRestTransport._GetOperation._get_response( self._host, @@ -525,6 +675,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.ads.admanager_v1.PlacementServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.ads.admanager.v1.PlacementService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-ads-admanager/google/ads/admanager_v1/services/report_service/client.py b/packages/google-ads-admanager/google/ads/admanager_v1/services/report_service/client.py index 5ccce8d9cf8a..8fcc1028591a 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/services/report_service/client.py +++ b/packages/google-ads-admanager/google/ads/admanager_v1/services/report_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 @@ -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( @@ -653,6 +667,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.ads.admanager_v1.ReportServiceClient`.", + extra={ + "serviceName": "google.ads.admanager.v1.ReportService", + "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.ads.admanager.v1.ReportService", + "credentialsType": None, + }, + ) + def get_report( self, request: Optional[Union[report_service.GetReportRequest, dict]] = None, @@ -660,7 +697,7 @@ def get_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]]] = (), ) -> report_service.Report: r"""API to retrieve a ``Report`` object. @@ -703,8 +740,10 @@ def sample_get_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.ads.admanager_v1.types.Report: @@ -760,7 +799,7 @@ def list_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.ListReportsPager: r"""API to retrieve a list of ``Report`` objects. @@ -804,8 +843,10 @@ def sample_list_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.ads.admanager_v1.services.report_service.pagers.ListReportsPager: @@ -878,7 +919,7 @@ def create_report( report: Optional[report_service.Report] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> report_service.Report: r"""API to create a ``Report`` object. @@ -932,8 +973,10 @@ def sample_create_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.ads.admanager_v1.types.Report: @@ -992,7 +1035,7 @@ def update_report( 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]]] = (), ) -> report_service.Report: r"""API to update a ``Report`` object. @@ -1045,8 +1088,10 @@ def sample_update_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.ads.admanager_v1.types.Report: @@ -1106,7 +1151,7 @@ def run_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"""Initiates the execution of an existing report asynchronously. Users can get the report by polling this operation via @@ -1161,8 +1206,10 @@ def sample_run_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: @@ -1233,7 +1280,7 @@ def fetch_report_result_rows( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.FetchReportResultRowsPager: r"""Returns the result rows from a completed report. The caller must have previously called ``RunReport`` and waited for that @@ -1281,8 +1328,10 @@ def sample_fetch_report_result_rows(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ads.admanager_v1.services.report_service.pagers.FetchReportResultRowsPager: @@ -1366,7 +1415,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. @@ -1377,8 +1426,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-ads-admanager/google/ads/admanager_v1/services/report_service/pagers.py b/packages/google-ads-admanager/google/ads/admanager_v1/services/report_service/pagers.py index 5299974427f5..1ff9c653958b 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/services/report_service/pagers.py +++ b/packages/google-ads-admanager/google/ads/admanager_v1/services/report_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 = report_service.ListReportsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -155,8 +157,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = report_service.FetchReportResultRowsRequest(request) diff --git a/packages/google-ads-admanager/google/ads/admanager_v1/services/report_service/transports/rest.py b/packages/google-ads-admanager/google/ads/admanager_v1/services/report_service/transports/rest.py index daca3aeb7387..96bd9a927d92 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/services/report_service/transports/rest.py +++ b/packages/google-ads-admanager/google/ads/admanager_v1/services/report_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, @@ -118,8 +126,10 @@ def post_update_report(self, response): def pre_create_report( self, request: report_service.CreateReportRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[report_service.CreateReportRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + report_service.CreateReportRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_report Override in a subclass to manipulate the request or metadata @@ -141,8 +151,11 @@ def post_create_report( def pre_fetch_report_result_rows( self, request: report_service.FetchReportResultRowsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[report_service.FetchReportResultRowsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + report_service.FetchReportResultRowsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for fetch_report_result_rows Override in a subclass to manipulate the request or metadata @@ -164,8 +177,10 @@ def post_fetch_report_result_rows( def pre_get_report( self, request: report_service.GetReportRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[report_service.GetReportRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + report_service.GetReportRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_report Override in a subclass to manipulate the request or metadata @@ -185,8 +200,10 @@ def post_get_report(self, response: report_service.Report) -> report_service.Rep def pre_list_reports( self, request: report_service.ListReportsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[report_service.ListReportsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + report_service.ListReportsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_reports Override in a subclass to manipulate the request or metadata @@ -208,8 +225,10 @@ def post_list_reports( def pre_run_report( self, request: report_service.RunReportRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[report_service.RunReportRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + report_service.RunReportRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for run_report Override in a subclass to manipulate the request or metadata @@ -231,8 +250,10 @@ def post_run_report( def pre_update_report( self, request: report_service.UpdateReportRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[report_service.UpdateReportRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + report_service.UpdateReportRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_report Override in a subclass to manipulate the request or metadata @@ -254,8 +275,10 @@ def post_update_report( 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 @@ -435,7 +458,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> report_service.Report: r"""Call the create report method over HTTP. @@ -445,8 +468,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.report_service.Report: @@ -456,6 +481,7 @@ def __call__( http_options = ( _BaseReportServiceRestTransport._BaseCreateReport._get_http_options() ) + request, metadata = self._interceptor.pre_create_report(request, metadata) transcoded_request = _BaseReportServiceRestTransport._BaseCreateReport._get_transcoded_request( http_options, request @@ -470,6 +496,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.ReportServiceClient.CreateReport", + extra={ + "serviceName": "google.ads.admanager.v1.ReportService", + "rpcName": "CreateReport", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ReportServiceRestTransport._CreateReport._get_response( self._host, @@ -491,7 +544,29 @@ def __call__( pb_resp = report_service.Report.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_report(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = report_service.Report.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ads.admanager_v1.ReportServiceClient.create_report", + extra={ + "serviceName": "google.ads.admanager.v1.ReportService", + "rpcName": "CreateReport", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _FetchReportResultRows( @@ -529,7 +604,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> report_service.FetchReportResultRowsResponse: r"""Call the fetch report result rows method over HTTP. @@ -540,8 +615,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.report_service.FetchReportResultRowsResponse: @@ -553,6 +630,7 @@ def __call__( http_options = ( _BaseReportServiceRestTransport._BaseFetchReportResultRows._get_http_options() ) + request, metadata = self._interceptor.pre_fetch_report_result_rows( request, metadata ) @@ -565,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 = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.ReportServiceClient.FetchReportResultRows", + extra={ + "serviceName": "google.ads.admanager.v1.ReportService", + "rpcName": "FetchReportResultRows", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ReportServiceRestTransport._FetchReportResultRows._get_response( self._host, @@ -585,7 +690,31 @@ def __call__( pb_resp = report_service.FetchReportResultRowsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_fetch_report_result_rows(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + report_service.FetchReportResultRowsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ads.admanager_v1.ReportServiceClient.fetch_report_result_rows", + extra={ + "serviceName": "google.ads.admanager.v1.ReportService", + "rpcName": "FetchReportResultRows", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetReport( @@ -622,7 +751,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> report_service.Report: r"""Call the get report method over HTTP. @@ -632,8 +761,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.report_service.Report: @@ -643,6 +774,7 @@ def __call__( http_options = ( _BaseReportServiceRestTransport._BaseGetReport._get_http_options() ) + request, metadata = self._interceptor.pre_get_report(request, metadata) transcoded_request = ( _BaseReportServiceRestTransport._BaseGetReport._get_transcoded_request( @@ -657,6 +789,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.ReportServiceClient.GetReport", + extra={ + "serviceName": "google.ads.admanager.v1.ReportService", + "rpcName": "GetReport", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ReportServiceRestTransport._GetReport._get_response( self._host, @@ -677,7 +836,29 @@ def __call__( pb_resp = report_service.Report.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_report(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = report_service.Report.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ads.admanager_v1.ReportServiceClient.get_report", + extra={ + "serviceName": "google.ads.admanager.v1.ReportService", + "rpcName": "GetReport", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListReports( @@ -714,7 +895,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> report_service.ListReportsResponse: r"""Call the list reports method over HTTP. @@ -724,8 +905,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.report_service.ListReportsResponse: @@ -737,6 +920,7 @@ def __call__( http_options = ( _BaseReportServiceRestTransport._BaseListReports._get_http_options() ) + request, metadata = self._interceptor.pre_list_reports(request, metadata) transcoded_request = _BaseReportServiceRestTransport._BaseListReports._get_transcoded_request( http_options, request @@ -749,6 +933,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.ReportServiceClient.ListReports", + extra={ + "serviceName": "google.ads.admanager.v1.ReportService", + "rpcName": "ListReports", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ReportServiceRestTransport._ListReports._get_response( self._host, @@ -769,7 +980,31 @@ def __call__( pb_resp = report_service.ListReportsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_reports(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = report_service.ListReportsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ads.admanager_v1.ReportServiceClient.list_reports", + extra={ + "serviceName": "google.ads.admanager.v1.ReportService", + "rpcName": "ListReports", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RunReport( @@ -807,7 +1042,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the run report method over HTTP. @@ -818,8 +1053,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -832,6 +1069,7 @@ def __call__( http_options = ( _BaseReportServiceRestTransport._BaseRunReport._get_http_options() ) + request, metadata = self._interceptor.pre_run_report(request, metadata) transcoded_request = ( _BaseReportServiceRestTransport._BaseRunReport._get_transcoded_request( @@ -852,6 +1090,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.ReportServiceClient.RunReport", + extra={ + "serviceName": "google.ads.admanager.v1.ReportService", + "rpcName": "RunReport", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ReportServiceRestTransport._RunReport._get_response( self._host, @@ -871,7 +1136,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_run_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.ads.admanager_v1.ReportServiceClient.run_report", + extra={ + "serviceName": "google.ads.admanager.v1.ReportService", + "rpcName": "RunReport", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateReport( @@ -909,7 +1196,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> report_service.Report: r"""Call the update report method over HTTP. @@ -919,8 +1206,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.report_service.Report: @@ -930,6 +1219,7 @@ def __call__( http_options = ( _BaseReportServiceRestTransport._BaseUpdateReport._get_http_options() ) + request, metadata = self._interceptor.pre_update_report(request, metadata) transcoded_request = _BaseReportServiceRestTransport._BaseUpdateReport._get_transcoded_request( http_options, request @@ -944,6 +1234,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.ReportServiceClient.UpdateReport", + extra={ + "serviceName": "google.ads.admanager.v1.ReportService", + "rpcName": "UpdateReport", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ReportServiceRestTransport._UpdateReport._get_response( self._host, @@ -965,7 +1282,29 @@ def __call__( pb_resp = report_service.Report.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_report(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = report_service.Report.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ads.admanager_v1.ReportServiceClient.update_report", + extra={ + "serviceName": "google.ads.admanager.v1.ReportService", + "rpcName": "UpdateReport", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1059,7 +1398,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1069,8 +1408,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: operations_pb2.Operation: Response from GetOperation method. @@ -1079,6 +1420,7 @@ def __call__( http_options = ( _BaseReportServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseReportServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1089,6 +1431,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.ReportServiceClient.GetOperation", + extra={ + "serviceName": "google.ads.admanager.v1.ReportService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ReportServiceRestTransport._GetOperation._get_response( self._host, @@ -1108,6 +1477,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.ads.admanager_v1.ReportServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.ads.admanager.v1.ReportService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-ads-admanager/google/ads/admanager_v1/services/role_service/client.py b/packages/google-ads-admanager/google/ads/admanager_v1/services/role_service/client.py index 12b4ded58fdd..9b00a7dcfc53 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/services/role_service/client.py +++ b/packages/google-ads-admanager/google/ads/admanager_v1/services/role_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.longrunning import operations_pb2 # type: ignore from google.ads.admanager_v1.services.role_service import pagers @@ -584,6 +594,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -646,6 +660,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.ads.admanager_v1.RoleServiceClient`.", + extra={ + "serviceName": "google.ads.admanager.v1.RoleService", + "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.ads.admanager.v1.RoleService", + "credentialsType": None, + }, + ) + def get_role( self, request: Optional[Union[role_service.GetRoleRequest, dict]] = None, @@ -653,7 +690,7 @@ def get_role( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> role_messages.Role: r"""API to retrieve a ``Role`` object. @@ -696,8 +733,10 @@ def sample_get_role(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ads.admanager_v1.types.Role: @@ -753,7 +792,7 @@ def list_roles( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListRolesPager: r"""API to retrieve a list of ``Role`` objects. @@ -797,8 +836,10 @@ def sample_list_roles(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ads.admanager_v1.services.role_service.pagers.ListRolesPager: @@ -882,7 +923,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. @@ -893,8 +934,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-ads-admanager/google/ads/admanager_v1/services/role_service/pagers.py b/packages/google-ads-admanager/google/ads/admanager_v1/services/role_service/pagers.py index be9ac9755dd2..3c7ce1a18013 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/services/role_service/pagers.py +++ b/packages/google-ads-admanager/google/ads/admanager_v1/services/role_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 = role_service.ListRolesRequest(request) diff --git a/packages/google-ads-admanager/google/ads/admanager_v1/services/role_service/transports/rest.py b/packages/google-ads-admanager/google/ads/admanager_v1/services/role_service/transports/rest.py index ecbafd6c5f3c..f2f0211e46f0 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/services/role_service/transports/rest.py +++ b/packages/google-ads-admanager/google/ads/admanager_v1/services/role_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, @@ -84,8 +92,10 @@ def post_list_roles(self, response): """ def pre_get_role( - self, request: role_service.GetRoleRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[role_service.GetRoleRequest, Sequence[Tuple[str, str]]]: + self, + request: role_service.GetRoleRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[role_service.GetRoleRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_role Override in a subclass to manipulate the request or metadata @@ -105,8 +115,8 @@ def post_get_role(self, response: role_messages.Role) -> role_messages.Role: def pre_list_roles( self, request: role_service.ListRolesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[role_service.ListRolesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[role_service.ListRolesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_roles Override in a subclass to manipulate the request or metadata @@ -128,8 +138,10 @@ def post_list_roles( 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 @@ -267,7 +279,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> role_messages.Role: r"""Call the get role method over HTTP. @@ -277,8 +289,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.role_messages.Role: @@ -288,6 +302,7 @@ def __call__( http_options = ( _BaseRoleServiceRestTransport._BaseGetRole._get_http_options() ) + request, metadata = self._interceptor.pre_get_role(request, metadata) transcoded_request = ( _BaseRoleServiceRestTransport._BaseGetRole._get_transcoded_request( @@ -302,6 +317,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.RoleServiceClient.GetRole", + extra={ + "serviceName": "google.ads.admanager.v1.RoleService", + "rpcName": "GetRole", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RoleServiceRestTransport._GetRole._get_response( self._host, @@ -322,7 +364,29 @@ def __call__( pb_resp = role_messages.Role.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_role(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = role_messages.Role.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ads.admanager_v1.RoleServiceClient.get_role", + extra={ + "serviceName": "google.ads.admanager.v1.RoleService", + "rpcName": "GetRole", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListRoles(_BaseRoleServiceRestTransport._BaseListRoles, RoleServiceRestStub): @@ -357,7 +421,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> role_service.ListRolesResponse: r"""Call the list roles method over HTTP. @@ -367,8 +431,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.role_service.ListRolesResponse: @@ -380,6 +446,7 @@ def __call__( http_options = ( _BaseRoleServiceRestTransport._BaseListRoles._get_http_options() ) + request, metadata = self._interceptor.pre_list_roles(request, metadata) transcoded_request = ( _BaseRoleServiceRestTransport._BaseListRoles._get_transcoded_request( @@ -394,6 +461,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.RoleServiceClient.ListRoles", + extra={ + "serviceName": "google.ads.admanager.v1.RoleService", + "rpcName": "ListRoles", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RoleServiceRestTransport._ListRoles._get_response( self._host, @@ -414,7 +508,29 @@ def __call__( pb_resp = role_service.ListRolesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_roles(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = role_service.ListRolesResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ads.admanager_v1.RoleServiceClient.list_roles", + extra={ + "serviceName": "google.ads.admanager.v1.RoleService", + "rpcName": "ListRoles", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -469,7 +585,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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. @@ -479,8 +595,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: operations_pb2.Operation: Response from GetOperation method. @@ -489,6 +607,7 @@ def __call__( http_options = ( _BaseRoleServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseRoleServiceRestTransport._BaseGetOperation._get_transcoded_request( @@ -503,6 +622,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.RoleServiceClient.GetOperation", + extra={ + "serviceName": "google.ads.admanager.v1.RoleService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RoleServiceRestTransport._GetOperation._get_response( self._host, @@ -522,6 +668,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.ads.admanager_v1.RoleServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.ads.admanager.v1.RoleService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-ads-admanager/google/ads/admanager_v1/services/taxonomy_category_service/client.py b/packages/google-ads-admanager/google/ads/admanager_v1/services/taxonomy_category_service/client.py index 34d2eecbffc5..831d3ae1ddcc 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/services/taxonomy_category_service/client.py +++ b/packages/google-ads-admanager/google/ads/admanager_v1/services/taxonomy_category_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.longrunning import operations_pb2 # type: ignore from google.ads.admanager_v1.services.taxonomy_category_service import pagers @@ -601,6 +611,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -667,6 +681,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.ads.admanager_v1.TaxonomyCategoryServiceClient`.", + extra={ + "serviceName": "google.ads.admanager.v1.TaxonomyCategoryService", + "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.ads.admanager.v1.TaxonomyCategoryService", + "credentialsType": None, + }, + ) + def get_taxonomy_category( self, request: Optional[ @@ -676,7 +713,7 @@ def get_taxonomy_category( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> taxonomy_category_messages.TaxonomyCategory: r"""API to retrieve a ``TaxonomyCategory`` object. @@ -720,8 +757,10 @@ def sample_get_taxonomy_category(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ads.admanager_v1.types.TaxonomyCategory: @@ -781,7 +820,7 @@ def list_taxonomy_categories( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTaxonomyCategoriesPager: r"""API to retrieve a list of ``TaxonomyCategory`` objects. @@ -825,8 +864,10 @@ def sample_list_taxonomy_categories(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ads.admanager_v1.services.taxonomy_category_service.pagers.ListTaxonomyCategoriesPager: @@ -912,7 +953,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. @@ -923,8 +964,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-ads-admanager/google/ads/admanager_v1/services/taxonomy_category_service/pagers.py b/packages/google-ads-admanager/google/ads/admanager_v1/services/taxonomy_category_service/pagers.py index ba0e74b14baf..373b8a1e1f72 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/services/taxonomy_category_service/pagers.py +++ b/packages/google-ads-admanager/google/ads/admanager_v1/services/taxonomy_category_service/pagers.py @@ -70,7 +70,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -84,8 +84,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = taxonomy_category_service.ListTaxonomyCategoriesRequest(request) diff --git a/packages/google-ads-admanager/google/ads/admanager_v1/services/taxonomy_category_service/transports/rest.py b/packages/google-ads-admanager/google/ads/admanager_v1/services/taxonomy_category_service/transports/rest.py index cc2741c4fe7a..4e32840d3ddd 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/services/taxonomy_category_service/transports/rest.py +++ b/packages/google-ads-admanager/google/ads/admanager_v1/services/taxonomy_category_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, @@ -89,9 +97,10 @@ def post_list_taxonomy_categories(self, response): def pre_get_taxonomy_category( self, request: taxonomy_category_service.GetTaxonomyCategoryRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - taxonomy_category_service.GetTaxonomyCategoryRequest, Sequence[Tuple[str, str]] + taxonomy_category_service.GetTaxonomyCategoryRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_taxonomy_category @@ -114,10 +123,10 @@ def post_get_taxonomy_category( def pre_list_taxonomy_categories( self, request: taxonomy_category_service.ListTaxonomyCategoriesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ taxonomy_category_service.ListTaxonomyCategoriesRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_taxonomy_categories @@ -140,8 +149,10 @@ def post_list_taxonomy_categories( 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 @@ -282,7 +293,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> taxonomy_category_messages.TaxonomyCategory: r"""Call the get taxonomy category method over HTTP. @@ -292,8 +303,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.taxonomy_category_messages.TaxonomyCategory: @@ -303,6 +316,7 @@ def __call__( http_options = ( _BaseTaxonomyCategoryServiceRestTransport._BaseGetTaxonomyCategory._get_http_options() ) + request, metadata = self._interceptor.pre_get_taxonomy_category( request, metadata ) @@ -315,6 +329,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.TaxonomyCategoryServiceClient.GetTaxonomyCategory", + extra={ + "serviceName": "google.ads.admanager.v1.TaxonomyCategoryService", + "rpcName": "GetTaxonomyCategory", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( TaxonomyCategoryServiceRestTransport._GetTaxonomyCategory._get_response( @@ -337,7 +378,31 @@ def __call__( pb_resp = taxonomy_category_messages.TaxonomyCategory.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_taxonomy_category(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + taxonomy_category_messages.TaxonomyCategory.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ads.admanager_v1.TaxonomyCategoryServiceClient.get_taxonomy_category", + extra={ + "serviceName": "google.ads.admanager.v1.TaxonomyCategoryService", + "rpcName": "GetTaxonomyCategory", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTaxonomyCategories( @@ -375,7 +440,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> taxonomy_category_service.ListTaxonomyCategoriesResponse: r"""Call the list taxonomy categories method over HTTP. @@ -385,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: ~.taxonomy_category_service.ListTaxonomyCategoriesResponse: @@ -398,6 +465,7 @@ def __call__( http_options = ( _BaseTaxonomyCategoryServiceRestTransport._BaseListTaxonomyCategories._get_http_options() ) + request, metadata = self._interceptor.pre_list_taxonomy_categories( request, metadata ) @@ -410,6 +478,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.TaxonomyCategoryServiceClient.ListTaxonomyCategories", + extra={ + "serviceName": "google.ads.admanager.v1.TaxonomyCategoryService", + "rpcName": "ListTaxonomyCategories", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TaxonomyCategoryServiceRestTransport._ListTaxonomyCategories._get_response( self._host, @@ -430,7 +525,31 @@ def __call__( pb_resp = taxonomy_category_service.ListTaxonomyCategoriesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_taxonomy_categories(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = taxonomy_category_service.ListTaxonomyCategoriesResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ads.admanager_v1.TaxonomyCategoryServiceClient.list_taxonomy_categories", + extra={ + "serviceName": "google.ads.admanager.v1.TaxonomyCategoryService", + "rpcName": "ListTaxonomyCategories", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -494,7 +613,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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. @@ -504,8 +623,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: operations_pb2.Operation: Response from GetOperation method. @@ -514,6 +635,7 @@ def __call__( http_options = ( _BaseTaxonomyCategoryServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseTaxonomyCategoryServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -524,6 +646,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.TaxonomyCategoryServiceClient.GetOperation", + extra={ + "serviceName": "google.ads.admanager.v1.TaxonomyCategoryService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TaxonomyCategoryServiceRestTransport._GetOperation._get_response( self._host, @@ -543,6 +692,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.ads.admanager_v1.TaxonomyCategoryServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.ads.admanager.v1.TaxonomyCategoryService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-ads-admanager/google/ads/admanager_v1/services/user_service/client.py b/packages/google-ads-admanager/google/ads/admanager_v1/services/user_service/client.py index b8f7c7b12598..fbd1b70e7d1d 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/services/user_service/client.py +++ b/packages/google-ads-admanager/google/ads/admanager_v1/services/user_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.longrunning import operations_pb2 # type: ignore from google.ads.admanager_v1.types import user_messages, user_service @@ -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.ads.admanager_v1.UserServiceClient`.", + extra={ + "serviceName": "google.ads.admanager.v1.UserService", + "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.ads.admanager.v1.UserService", + "credentialsType": None, + }, + ) + def get_user( self, request: Optional[Union[user_service.GetUserRequest, dict]] = None, @@ -654,7 +691,7 @@ def get_user( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> user_messages.User: r"""API to retrieve a User object. @@ -700,8 +737,10 @@ def sample_get_user(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ads.admanager_v1.types.User: @@ -769,7 +808,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. @@ -780,8 +819,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-ads-admanager/google/ads/admanager_v1/services/user_service/transports/rest.py b/packages/google-ads-admanager/google/ads/admanager_v1/services/user_service/transports/rest.py index 525597ed0c69..294fbf1cd532 100644 --- a/packages/google-ads-admanager/google/ads/admanager_v1/services/user_service/transports/rest.py +++ b/packages/google-ads-admanager/google/ads/admanager_v1/services/user_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, @@ -76,8 +84,10 @@ def post_get_user(self, response): """ def pre_get_user( - self, request: user_service.GetUserRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[user_service.GetUserRequest, Sequence[Tuple[str, str]]]: + self, + request: user_service.GetUserRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[user_service.GetUserRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_user Override in a subclass to manipulate the request or metadata @@ -97,8 +107,10 @@ def post_get_user(self, response: user_messages.User) -> user_messages.User: 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 @@ -236,7 +248,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> user_messages.User: r"""Call the get user method over HTTP. @@ -246,8 +258,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.user_messages.User: @@ -257,6 +271,7 @@ def __call__( http_options = ( _BaseUserServiceRestTransport._BaseGetUser._get_http_options() ) + request, metadata = self._interceptor.pre_get_user(request, metadata) transcoded_request = ( _BaseUserServiceRestTransport._BaseGetUser._get_transcoded_request( @@ -271,6 +286,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.UserServiceClient.GetUser", + extra={ + "serviceName": "google.ads.admanager.v1.UserService", + "rpcName": "GetUser", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UserServiceRestTransport._GetUser._get_response( self._host, @@ -291,7 +333,29 @@ def __call__( pb_resp = user_messages.User.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_user(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = user_messages.User.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ads.admanager_v1.UserServiceClient.get_user", + extra={ + "serviceName": "google.ads.admanager.v1.UserService", + "rpcName": "GetUser", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -338,7 +402,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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. @@ -348,8 +412,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -358,6 +424,7 @@ def __call__( http_options = ( _BaseUserServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseUserServiceRestTransport._BaseGetOperation._get_transcoded_request( @@ -372,6 +439,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ads.admanager_v1.UserServiceClient.GetOperation", + extra={ + "serviceName": "google.ads.admanager.v1.UserService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = UserServiceRestTransport._GetOperation._get_response( self._host, @@ -391,6 +485,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.ads.admanager_v1.UserServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.ads.admanager.v1.UserService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-ads-admanager/samples/generated_samples/snippet_metadata_google.ads.admanager.v1.json b/packages/google-ads-admanager/samples/generated_samples/snippet_metadata_google.ads.admanager.v1.json index 2480467d0962..e616c7d90ec3 100644 --- a/packages/google-ads-admanager/samples/generated_samples/snippet_metadata_google.ads.admanager.v1.json +++ b/packages/google-ads-admanager/samples/generated_samples/snippet_metadata_google.ads.admanager.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-ads-admanager", - "version": "0.2.2" + "version": "0.1.0" }, "snippets": [ { @@ -46,7 +46,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.admanager_v1.types.AdUnit", @@ -126,7 +126,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.admanager_v1.services.ad_unit_service.pagers.ListAdUnitSizesPager", @@ -206,7 +206,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.admanager_v1.services.ad_unit_service.pagers.ListAdUnitsPager", @@ -286,7 +286,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.admanager_v1.types.Company", @@ -366,7 +366,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.admanager_v1.services.company_service.pagers.ListCompaniesPager", @@ -446,7 +446,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.admanager_v1.types.CustomField", @@ -526,7 +526,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.admanager_v1.services.custom_field_service.pagers.ListCustomFieldsPager", @@ -606,7 +606,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.admanager_v1.types.CustomTargetingKey", @@ -686,7 +686,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.admanager_v1.services.custom_targeting_key_service.pagers.ListCustomTargetingKeysPager", @@ -766,7 +766,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.admanager_v1.types.CustomTargetingValue", @@ -846,7 +846,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.admanager_v1.services.custom_targeting_value_service.pagers.ListCustomTargetingValuesPager", @@ -930,7 +930,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.admanager_v1.types.BatchCreateEntitySignalsMappingsResponse", @@ -1014,7 +1014,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.admanager_v1.types.BatchUpdateEntitySignalsMappingsResponse", @@ -1098,7 +1098,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.admanager_v1.types.EntitySignalsMapping", @@ -1178,7 +1178,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.admanager_v1.types.EntitySignalsMapping", @@ -1258,7 +1258,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.admanager_v1.services.entity_signals_mapping_service.pagers.ListEntitySignalsMappingsPager", @@ -1342,7 +1342,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.admanager_v1.types.EntitySignalsMapping", @@ -1422,7 +1422,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.admanager_v1.types.Network", @@ -1498,7 +1498,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.admanager_v1.types.ListNetworksResponse", @@ -1578,7 +1578,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.admanager_v1.types.Order", @@ -1658,7 +1658,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.admanager_v1.services.order_service.pagers.ListOrdersPager", @@ -1738,7 +1738,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.admanager_v1.types.Placement", @@ -1818,7 +1818,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.admanager_v1.services.placement_service.pagers.ListPlacementsPager", @@ -1902,7 +1902,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.admanager_v1.types.Report", @@ -1982,7 +1982,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.admanager_v1.services.report_service.pagers.FetchReportResultRowsPager", @@ -2062,7 +2062,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.admanager_v1.types.Report", @@ -2142,7 +2142,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.admanager_v1.services.report_service.pagers.ListReportsPager", @@ -2222,7 +2222,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2306,7 +2306,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.admanager_v1.types.Report", @@ -2386,7 +2386,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.admanager_v1.types.Role", @@ -2466,7 +2466,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.admanager_v1.services.role_service.pagers.ListRolesPager", @@ -2546,7 +2546,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.admanager_v1.types.TaxonomyCategory", @@ -2626,7 +2626,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.admanager_v1.services.taxonomy_category_service.pagers.ListTaxonomyCategoriesPager", @@ -2706,7 +2706,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.admanager_v1.types.User", diff --git a/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_ad_unit_service.py b/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_ad_unit_service.py index 8ad32e14d084..cbbc892a654a 100644 --- a/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_ad_unit_service.py +++ b/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_ad_unit_service.py @@ -1001,6 +1001,7 @@ def test_get_ad_unit_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_ad_unit(request) @@ -1046,6 +1047,7 @@ def test_get_ad_unit_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_ad_unit(**mock_args) @@ -1185,6 +1187,7 @@ def test_list_ad_units_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_ad_units(request) @@ -1241,6 +1244,7 @@ def test_list_ad_units_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_ad_units(**mock_args) @@ -1447,6 +1451,7 @@ def test_list_ad_unit_sizes_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_ad_unit_sizes(request) @@ -1503,6 +1508,7 @@ def test_list_ad_unit_sizes_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_ad_unit_sizes(**mock_args) @@ -1694,6 +1700,7 @@ def test_get_ad_unit_rest_bad_request(request_type=ad_unit_service.GetAdUnitRequ response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_ad_unit(request) @@ -1745,6 +1752,7 @@ def test_get_ad_unit_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_ad_unit(request) # Establish that the response is the type that we expect. @@ -1812,6 +1820,7 @@ def test_get_ad_unit_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = ad_unit_messages.AdUnit.to_json(ad_unit_messages.AdUnit()) req.return_value.content = return_value @@ -1856,6 +1865,7 @@ def test_list_ad_units_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_ad_units(request) @@ -1892,6 +1902,7 @@ def test_list_ad_units_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_ad_units(request) # Establish that the response is the type that we expect. @@ -1933,6 +1944,7 @@ def test_list_ad_units_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = ad_unit_service.ListAdUnitsResponse.to_json( ad_unit_service.ListAdUnitsResponse() ) @@ -1979,6 +1991,7 @@ def test_list_ad_unit_sizes_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_ad_unit_sizes(request) @@ -2015,6 +2028,7 @@ def test_list_ad_unit_sizes_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_ad_unit_sizes(request) # Establish that the response is the type that we expect. @@ -2056,6 +2070,7 @@ def test_list_ad_unit_sizes_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = ad_unit_service.ListAdUnitSizesResponse.to_json( ad_unit_service.ListAdUnitSizesResponse() ) @@ -2104,6 +2119,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) @@ -2134,6 +2150,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-ads-admanager/tests/unit/gapic/admanager_v1/test_company_service.py b/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_company_service.py index 31192a252ba0..ea9adbde0902 100644 --- a/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_company_service.py +++ b/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_company_service.py @@ -1005,6 +1005,7 @@ def test_get_company_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_company(request) @@ -1050,6 +1051,7 @@ def test_get_company_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_company(**mock_args) @@ -1189,6 +1191,7 @@ def test_list_companies_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_companies(request) @@ -1245,6 +1248,7 @@ def test_list_companies_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_companies(**mock_args) @@ -1436,6 +1440,7 @@ def test_get_company_rest_bad_request(request_type=company_service.GetCompanyReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_company(request) @@ -1484,6 +1489,7 @@ def test_get_company_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_company(request) # Establish that the response is the type that we expect. @@ -1540,6 +1546,7 @@ def test_get_company_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = company_messages.Company.to_json(company_messages.Company()) req.return_value.content = return_value @@ -1584,6 +1591,7 @@ def test_list_companies_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_companies(request) @@ -1620,6 +1628,7 @@ def test_list_companies_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_companies(request) # Establish that the response is the type that we expect. @@ -1661,6 +1670,7 @@ def test_list_companies_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = company_service.ListCompaniesResponse.to_json( company_service.ListCompaniesResponse() ) @@ -1709,6 +1719,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) @@ -1739,6 +1750,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-ads-admanager/tests/unit/gapic/admanager_v1/test_custom_field_service.py b/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_custom_field_service.py index 8277a7391d0e..cf1494107490 100644 --- a/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_custom_field_service.py +++ b/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_custom_field_service.py @@ -1036,6 +1036,7 @@ def test_get_custom_field_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_custom_field(request) @@ -1081,6 +1082,7 @@ def test_get_custom_field_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_custom_field(**mock_args) @@ -1226,6 +1228,7 @@ def test_list_custom_fields_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_custom_fields(request) @@ -1282,6 +1285,7 @@ def test_list_custom_fields_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_custom_fields(**mock_args) @@ -1475,6 +1479,7 @@ def test_get_custom_field_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_custom_field(request) @@ -1517,6 +1522,7 @@ def test_get_custom_field_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_custom_field(request) # Establish that the response is the type that we expect. @@ -1576,6 +1582,7 @@ def test_get_custom_field_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = custom_field_messages.CustomField.to_json( custom_field_messages.CustomField() ) @@ -1622,6 +1629,7 @@ def test_list_custom_fields_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_custom_fields(request) @@ -1658,6 +1666,7 @@ def test_list_custom_fields_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_custom_fields(request) # Establish that the response is the type that we expect. @@ -1699,6 +1708,7 @@ def test_list_custom_fields_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = custom_field_service.ListCustomFieldsResponse.to_json( custom_field_service.ListCustomFieldsResponse() ) @@ -1747,6 +1757,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) @@ -1777,6 +1788,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-ads-admanager/tests/unit/gapic/admanager_v1/test_custom_targeting_key_service.py b/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_custom_targeting_key_service.py index c638f5bc671f..4aed3143f97d 100644 --- a/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_custom_targeting_key_service.py +++ b/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_custom_targeting_key_service.py @@ -1065,6 +1065,7 @@ def test_get_custom_targeting_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_custom_targeting_key(request) @@ -1110,6 +1111,7 @@ def test_get_custom_targeting_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_custom_targeting_key(**mock_args) @@ -1259,6 +1261,7 @@ def test_list_custom_targeting_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_custom_targeting_keys(request) @@ -1317,6 +1320,7 @@ def test_list_custom_targeting_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_custom_targeting_keys(**mock_args) @@ -1515,6 +1519,7 @@ def test_get_custom_targeting_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_custom_targeting_key(request) @@ -1556,6 +1561,7 @@ def test_get_custom_targeting_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_custom_targeting_key(request) # Establish that the response is the type that we expect. @@ -1613,6 +1619,7 @@ def test_get_custom_targeting_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 = custom_targeting_key_messages.CustomTargetingKey.to_json( custom_targeting_key_messages.CustomTargetingKey() ) @@ -1659,6 +1666,7 @@ def test_list_custom_targeting_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_custom_targeting_keys(request) @@ -1697,6 +1705,7 @@ def test_list_custom_targeting_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_custom_targeting_keys(request) # Establish that the response is the type that we expect. @@ -1740,6 +1749,7 @@ def test_list_custom_targeting_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 = ( custom_targeting_key_service.ListCustomTargetingKeysResponse.to_json( custom_targeting_key_service.ListCustomTargetingKeysResponse() @@ -1792,6 +1802,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) @@ -1822,6 +1833,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-ads-admanager/tests/unit/gapic/admanager_v1/test_custom_targeting_value_service.py b/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_custom_targeting_value_service.py index 3364cf5b4339..7012ac0c2344 100644 --- a/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_custom_targeting_value_service.py +++ b/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_custom_targeting_value_service.py @@ -1069,6 +1069,7 @@ def test_get_custom_targeting_value_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_custom_targeting_value(request) @@ -1118,6 +1119,7 @@ def test_get_custom_targeting_value_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_custom_targeting_value(**mock_args) @@ -1268,6 +1270,7 @@ def test_list_custom_targeting_values_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_custom_targeting_values(request) @@ -1330,6 +1333,7 @@ def test_list_custom_targeting_values_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_custom_targeting_values(**mock_args) @@ -1531,6 +1535,7 @@ def test_get_custom_targeting_value_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_custom_targeting_value(request) @@ -1574,6 +1579,7 @@ def test_get_custom_targeting_value_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_custom_targeting_value(request) # Establish that the response is the type that we expect. @@ -1626,6 +1632,7 @@ def test_get_custom_targeting_value_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = custom_targeting_value_messages.CustomTargetingValue.to_json( custom_targeting_value_messages.CustomTargetingValue() ) @@ -1672,6 +1679,7 @@ def test_list_custom_targeting_values_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_custom_targeting_values(request) @@ -1712,6 +1720,7 @@ def test_list_custom_targeting_values_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_custom_targeting_values(request) # Establish that the response is the type that we expect. @@ -1755,6 +1764,7 @@ def test_list_custom_targeting_values_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = ( custom_targeting_value_service.ListCustomTargetingValuesResponse.to_json( custom_targeting_value_service.ListCustomTargetingValuesResponse() @@ -1807,6 +1817,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) @@ -1837,6 +1848,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-ads-admanager/tests/unit/gapic/admanager_v1/test_entity_signals_mapping_service.py b/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_entity_signals_mapping_service.py index 6ac3e48f7132..2368f1e1d2e5 100644 --- a/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_entity_signals_mapping_service.py +++ b/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_entity_signals_mapping_service.py @@ -1069,6 +1069,7 @@ def test_get_entity_signals_mapping_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_entity_signals_mapping(request) @@ -1116,6 +1117,7 @@ def test_get_entity_signals_mapping_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_entity_signals_mapping(**mock_args) @@ -1265,6 +1267,7 @@ def test_list_entity_signals_mappings_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_entity_signals_mappings(request) @@ -1327,6 +1330,7 @@ def test_list_entity_signals_mappings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_entity_signals_mappings(**mock_args) @@ -1532,6 +1536,7 @@ def test_create_entity_signals_mapping_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_entity_signals_mapping(request) @@ -1592,6 +1597,7 @@ def test_create_entity_signals_mapping_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_entity_signals_mapping(**mock_args) @@ -1730,6 +1736,7 @@ def test_update_entity_signals_mapping_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_entity_signals_mapping(request) @@ -1794,6 +1801,7 @@ def test_update_entity_signals_mapping_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_entity_signals_mapping(**mock_args) @@ -1938,6 +1946,7 @@ def test_batch_create_entity_signals_mappings_rest_required_fields( response_value._content = json_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_entity_signals_mappings(request) @@ -2004,6 +2013,7 @@ def test_batch_create_entity_signals_mappings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.batch_create_entity_signals_mappings(**mock_args) @@ -2152,6 +2162,7 @@ def test_batch_update_entity_signals_mappings_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.batch_update_entity_signals_mappings(request) @@ -2220,6 +2231,7 @@ def test_batch_update_entity_signals_mappings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.batch_update_entity_signals_mappings(**mock_args) @@ -2361,6 +2373,7 @@ def test_get_entity_signals_mapping_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_entity_signals_mapping(request) @@ -2401,6 +2414,7 @@ def test_get_entity_signals_mapping_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_entity_signals_mapping(request) # Establish that the response is the type that we expect. @@ -2445,6 +2459,7 @@ def test_get_entity_signals_mapping_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = entity_signals_mapping_messages.EntitySignalsMapping.to_json( entity_signals_mapping_messages.EntitySignalsMapping() ) @@ -2491,6 +2506,7 @@ def test_list_entity_signals_mappings_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_entity_signals_mappings(request) @@ -2531,6 +2547,7 @@ def test_list_entity_signals_mappings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_entity_signals_mappings(request) # Establish that the response is the type that we expect. @@ -2574,6 +2591,7 @@ def test_list_entity_signals_mappings_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = ( entity_signals_mapping_service.ListEntitySignalsMappingsResponse.to_json( entity_signals_mapping_service.ListEntitySignalsMappingsResponse() @@ -2624,6 +2642,7 @@ def test_create_entity_signals_mapping_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_entity_signals_mapping(request) @@ -2745,6 +2764,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_entity_signals_mapping(request) # Establish that the response is the type that we expect. @@ -2791,6 +2811,7 @@ def test_create_entity_signals_mapping_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = entity_signals_mapping_messages.EntitySignalsMapping.to_json( entity_signals_mapping_messages.EntitySignalsMapping() ) @@ -2841,6 +2862,7 @@ def test_update_entity_signals_mapping_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_entity_signals_mapping(request) @@ -2966,6 +2988,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_entity_signals_mapping(request) # Establish that the response is the type that we expect. @@ -3012,6 +3035,7 @@ def test_update_entity_signals_mapping_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = entity_signals_mapping_messages.EntitySignalsMapping.to_json( entity_signals_mapping_messages.EntitySignalsMapping() ) @@ -3058,6 +3082,7 @@ def test_batch_create_entity_signals_mappings_rest_bad_request( response_value.status_code = 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_entity_signals_mappings(request) @@ -3097,6 +3122,7 @@ def test_batch_create_entity_signals_mappings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_entity_signals_mappings(request) # Establish that the response is the type that we expect. @@ -3143,6 +3169,7 @@ def test_batch_create_entity_signals_mappings_rest_interceptors(null_interceptor req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = entity_signals_mapping_service.BatchCreateEntitySignalsMappingsResponse.to_json( entity_signals_mapping_service.BatchCreateEntitySignalsMappingsResponse() ) @@ -3193,6 +3220,7 @@ def test_batch_update_entity_signals_mappings_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.batch_update_entity_signals_mappings(request) @@ -3232,6 +3260,7 @@ def test_batch_update_entity_signals_mappings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.batch_update_entity_signals_mappings(request) # Establish that the response is the type that we expect. @@ -3278,6 +3307,7 @@ def test_batch_update_entity_signals_mappings_rest_interceptors(null_interceptor req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = entity_signals_mapping_service.BatchUpdateEntitySignalsMappingsResponse.to_json( entity_signals_mapping_service.BatchUpdateEntitySignalsMappingsResponse() ) @@ -3330,6 +3360,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) @@ -3360,6 +3391,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-ads-admanager/tests/unit/gapic/admanager_v1/test_network_service.py b/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_network_service.py index d81d1d2daacf..2ca64e50c3ee 100644 --- a/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_network_service.py +++ b/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_network_service.py @@ -997,6 +997,7 @@ def test_get_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_network(request) @@ -1042,6 +1043,7 @@ def test_get_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_network(**mock_args) @@ -1206,6 +1208,7 @@ def test_get_network_rest_bad_request(request_type=network_service.GetNetworkReq response_value.status_code = 400 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(request) @@ -1250,6 +1253,7 @@ def test_get_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_network(request) # Establish that the response is the type that we expect. @@ -1299,6 +1303,7 @@ def test_get_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 = network_messages.Network.to_json(network_messages.Network()) req.return_value.content = return_value @@ -1343,6 +1348,7 @@ def test_list_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_networks(request) @@ -1376,6 +1382,7 @@ def test_list_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_networks(request) # Establish that the response is the type that we expect. @@ -1415,6 +1422,7 @@ def test_list_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 = network_service.ListNetworksResponse.to_json( network_service.ListNetworksResponse() ) @@ -1463,6 +1471,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) @@ -1493,6 +1502,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-ads-admanager/tests/unit/gapic/admanager_v1/test_order_service.py b/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_order_service.py index ff0845f7b8c7..62013e27fa51 100644 --- a/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_order_service.py +++ b/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_order_service.py @@ -986,6 +986,7 @@ def test_get_order_rest_required_fields(request_type=order_service.GetOrderReque response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_order(request) @@ -1031,6 +1032,7 @@ def test_get_order_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_order(**mock_args) @@ -1168,6 +1170,7 @@ def test_list_orders_rest_required_fields(request_type=order_service.ListOrdersR response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_orders(request) @@ -1224,6 +1227,7 @@ def test_list_orders_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_orders(**mock_args) @@ -1413,6 +1417,7 @@ def test_get_order_rest_bad_request(request_type=order_service.GetOrderRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_order(request) @@ -1470,6 +1475,7 @@ def test_get_order_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_order(request) # Establish that the response is the type that we expect. @@ -1530,6 +1536,7 @@ def test_get_order_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = order_messages.Order.to_json(order_messages.Order()) req.return_value.content = return_value @@ -1572,6 +1579,7 @@ def test_list_orders_rest_bad_request(request_type=order_service.ListOrdersReque response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_orders(request) @@ -1608,6 +1616,7 @@ def test_list_orders_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_orders(request) # Establish that the response is the type that we expect. @@ -1649,6 +1658,7 @@ def test_list_orders_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = order_service.ListOrdersResponse.to_json( order_service.ListOrdersResponse() ) @@ -1697,6 +1707,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) @@ -1727,6 +1738,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-ads-admanager/tests/unit/gapic/admanager_v1/test_placement_service.py b/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_placement_service.py index e5ccc44d6400..aeb3edbe704e 100644 --- a/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_placement_service.py +++ b/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_placement_service.py @@ -1023,6 +1023,7 @@ def test_get_placement_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_placement(request) @@ -1068,6 +1069,7 @@ def test_get_placement_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_placement(**mock_args) @@ -1207,6 +1209,7 @@ def test_list_placements_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_placements(request) @@ -1263,6 +1266,7 @@ def test_list_placements_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_placements(**mock_args) @@ -1456,6 +1460,7 @@ def test_get_placement_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_placement(request) @@ -1497,6 +1502,7 @@ def test_get_placement_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_placement(request) # Establish that the response is the type that we expect. @@ -1543,6 +1549,7 @@ def test_get_placement_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = placement_messages.Placement.to_json( placement_messages.Placement() ) @@ -1589,6 +1596,7 @@ def test_list_placements_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_placements(request) @@ -1625,6 +1633,7 @@ def test_list_placements_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_placements(request) # Establish that the response is the type that we expect. @@ -1666,6 +1675,7 @@ def test_list_placements_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = placement_service.ListPlacementsResponse.to_json( placement_service.ListPlacementsResponse() ) @@ -1714,6 +1724,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) @@ -1744,6 +1755,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-ads-admanager/tests/unit/gapic/admanager_v1/test_report_service.py b/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_report_service.py index de1573b91071..53295bb95d07 100644 --- a/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_report_service.py +++ b/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_report_service.py @@ -1006,6 +1006,7 @@ def test_get_report_rest_required_fields(request_type=report_service.GetReportRe response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_report(request) @@ -1051,6 +1052,7 @@ def test_get_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_report(**mock_args) @@ -1190,6 +1192,7 @@ def test_list_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_reports(request) @@ -1246,6 +1249,7 @@ def test_list_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_reports(**mock_args) @@ -1439,6 +1443,7 @@ def test_create_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_report(request) @@ -1493,6 +1498,7 @@ def test_create_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_report(**mock_args) @@ -1621,6 +1627,7 @@ def test_update_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.update_report(request) @@ -1675,6 +1682,7 @@ def test_update_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.update_report(**mock_args) @@ -1805,6 +1813,7 @@ def test_run_report_rest_required_fields(request_type=report_service.RunReportRe response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.run_report(request) @@ -1848,6 +1857,7 @@ def test_run_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.run_report(**mock_args) @@ -1944,6 +1954,7 @@ def test_fetch_report_result_rows_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_report_result_rows(**mock_args) @@ -2137,6 +2148,7 @@ def test_get_report_rest_bad_request(request_type=report_service.GetReportReques response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_report(request) @@ -2176,6 +2188,7 @@ def test_get_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_report(request) # Establish that the response is the type that we expect. @@ -2220,6 +2233,7 @@ def test_get_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 = report_service.Report.to_json(report_service.Report()) req.return_value.content = return_value @@ -2262,6 +2276,7 @@ def test_list_reports_rest_bad_request(request_type=report_service.ListReportsRe response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_reports(request) @@ -2298,6 +2313,7 @@ def test_list_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_reports(request) # Establish that the response is the type that we expect. @@ -2339,6 +2355,7 @@ def test_list_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 = report_service.ListReportsResponse.to_json( report_service.ListReportsResponse() ) @@ -2385,6 +2402,7 @@ def test_create_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_report(request) @@ -2574,6 +2592,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_report(request) # Establish that the response is the type that we expect. @@ -2618,6 +2637,7 @@ def test_create_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 = report_service.Report.to_json(report_service.Report()) req.return_value.content = return_value @@ -2662,6 +2682,7 @@ def test_update_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.update_report(request) @@ -2851,6 +2872,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_report(request) # Establish that the response is the type that we expect. @@ -2895,6 +2917,7 @@ def test_update_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 = report_service.Report.to_json(report_service.Report()) req.return_value.content = return_value @@ -2937,6 +2960,7 @@ def test_run_report_rest_bad_request(request_type=report_service.RunReportReques response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.run_report(request) @@ -2967,6 +2991,7 @@ def test_run_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.run_report(request) # Establish that the response is the type that we expect. @@ -3008,6 +3033,7 @@ def test_run_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 @@ -3052,6 +3078,7 @@ def test_fetch_report_result_rows_rest_bad_request( response_value.status_code = 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_report_result_rows(request) @@ -3088,6 +3115,7 @@ def test_fetch_report_result_rows_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_report_result_rows(request) # Establish that the response is the type that we expect. @@ -3129,6 +3157,7 @@ def test_fetch_report_result_rows_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = report_service.FetchReportResultRowsResponse.to_json( report_service.FetchReportResultRowsResponse() ) @@ -3177,6 +3206,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) @@ -3207,6 +3237,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-ads-admanager/tests/unit/gapic/admanager_v1/test_role_service.py b/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_role_service.py index a47b868d77ca..539557e51834 100644 --- a/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_role_service.py +++ b/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_role_service.py @@ -975,6 +975,7 @@ def test_get_role_rest_required_fields(request_type=role_service.GetRoleRequest) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_role(request) @@ -1020,6 +1021,7 @@ def test_get_role_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_role(**mock_args) @@ -1157,6 +1159,7 @@ def test_list_roles_rest_required_fields(request_type=role_service.ListRolesRequ response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_roles(request) @@ -1213,6 +1216,7 @@ def test_list_roles_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_roles(**mock_args) @@ -1402,6 +1406,7 @@ def test_get_role_rest_bad_request(request_type=role_service.GetRoleRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_role(request) @@ -1442,6 +1447,7 @@ def test_get_role_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_role(request) # Establish that the response is the type that we expect. @@ -1485,6 +1491,7 @@ def test_get_role_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = role_messages.Role.to_json(role_messages.Role()) req.return_value.content = return_value @@ -1527,6 +1534,7 @@ def test_list_roles_rest_bad_request(request_type=role_service.ListRolesRequest) response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_roles(request) @@ -1563,6 +1571,7 @@ def test_list_roles_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_roles(request) # Establish that the response is the type that we expect. @@ -1602,6 +1611,7 @@ def test_list_roles_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = role_service.ListRolesResponse.to_json( role_service.ListRolesResponse() ) @@ -1650,6 +1660,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) @@ -1680,6 +1691,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-ads-admanager/tests/unit/gapic/admanager_v1/test_taxonomy_category_service.py b/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_taxonomy_category_service.py index c27e580f33f3..b8dfaa8586f0 100644 --- a/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_taxonomy_category_service.py +++ b/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_taxonomy_category_service.py @@ -1053,6 +1053,7 @@ def test_get_taxonomy_category_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_taxonomy_category(request) @@ -1098,6 +1099,7 @@ def test_get_taxonomy_category_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_taxonomy_category(**mock_args) @@ -1245,6 +1247,7 @@ def test_list_taxonomy_categories_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_taxonomy_categories(request) @@ -1303,6 +1306,7 @@ def test_list_taxonomy_categories_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_taxonomy_categories(**mock_args) @@ -1500,6 +1504,7 @@ def test_get_taxonomy_category_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_taxonomy_category(request) @@ -1542,6 +1547,7 @@ def test_get_taxonomy_category_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_taxonomy_category(request) # Establish that the response is the type that we expect. @@ -1592,6 +1598,7 @@ def test_get_taxonomy_category_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = taxonomy_category_messages.TaxonomyCategory.to_json( taxonomy_category_messages.TaxonomyCategory() ) @@ -1638,6 +1645,7 @@ def test_list_taxonomy_categories_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_taxonomy_categories(request) @@ -1676,6 +1684,7 @@ def test_list_taxonomy_categories_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_taxonomy_categories(request) # Establish that the response is the type that we expect. @@ -1719,6 +1728,7 @@ def test_list_taxonomy_categories_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = taxonomy_category_service.ListTaxonomyCategoriesResponse.to_json( taxonomy_category_service.ListTaxonomyCategoriesResponse() ) @@ -1767,6 +1777,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) @@ -1797,6 +1808,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-ads-admanager/tests/unit/gapic/admanager_v1/test_user_service.py b/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_user_service.py index c90a6aafca07..e7c70abf8365 100644 --- a/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_user_service.py +++ b/packages/google-ads-admanager/tests/unit/gapic/admanager_v1/test_user_service.py @@ -971,6 +971,7 @@ def test_get_user_rest_required_fields(request_type=user_service.GetUserRequest) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_user(request) @@ -1016,6 +1017,7 @@ def test_get_user_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_user(**mock_args) @@ -1144,6 +1146,7 @@ def test_get_user_rest_bad_request(request_type=user_service.GetUserRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_user(request) @@ -1187,6 +1190,7 @@ def test_get_user_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_user(request) # Establish that the response is the type that we expect. @@ -1233,6 +1237,7 @@ def test_get_user_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = user_messages.User.to_json(user_messages.User()) req.return_value.content = return_value @@ -1279,6 +1284,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) @@ -1309,6 +1315,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-ads-marketingplatform-admin/google/ads/marketingplatform_admin/gapic_version.py b/packages/google-ads-marketingplatform-admin/google/ads/marketingplatform_admin/gapic_version.py index 3b0a9d9a8d43..558c8aab67c5 100644 --- a/packages/google-ads-marketingplatform-admin/google/ads/marketingplatform_admin/gapic_version.py +++ b/packages/google-ads-marketingplatform-admin/google/ads/marketingplatform_admin/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-ads-marketingplatform-admin/google/ads/marketingplatform_admin_v1alpha/gapic_version.py b/packages/google-ads-marketingplatform-admin/google/ads/marketingplatform_admin_v1alpha/gapic_version.py index 3b0a9d9a8d43..558c8aab67c5 100644 --- a/packages/google-ads-marketingplatform-admin/google/ads/marketingplatform_admin_v1alpha/gapic_version.py +++ b/packages/google-ads-marketingplatform-admin/google/ads/marketingplatform_admin_v1alpha/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-ads-marketingplatform-admin/google/ads/marketingplatform_admin_v1alpha/services/marketingplatform_admin_service/async_client.py b/packages/google-ads-marketingplatform-admin/google/ads/marketingplatform_admin_v1alpha/services/marketingplatform_admin_service/async_client.py index cc9647487d98..84d198546ec6 100644 --- a/packages/google-ads-marketingplatform-admin/google/ads/marketingplatform_admin_v1alpha/services/marketingplatform_admin_service/async_client.py +++ b/packages/google-ads-marketingplatform-admin/google/ads/marketingplatform_admin_v1alpha/services/marketingplatform_admin_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, MarketingplatformAdminServiceTransport from .transports.grpc_asyncio import MarketingplatformAdminServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class MarketingplatformAdminServiceAsyncClient: """Service Interface for the Google Marketing Platform Admin @@ -291,6 +301,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.marketingplatform.admin_v1alpha.MarketingplatformAdminServiceAsyncClient`.", + extra={ + "serviceName": "google.marketingplatform.admin.v1alpha.MarketingplatformAdminService", + "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.marketingplatform.admin.v1alpha.MarketingplatformAdminService", + "credentialsType": None, + }, + ) + async def get_organization( self, request: Optional[ @@ -300,7 +332,7 @@ async def get_organization( name: Optional[str] = None, retry: OptionalRetry = 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.Organization: r"""Lookup for a single organization. @@ -344,8 +376,10 @@ async def sample_get_organization(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ads.marketingplatform_admin_v1alpha.types.Organization: @@ -408,7 +442,7 @@ async def list_analytics_account_links( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAnalyticsAccountLinksAsyncPager: r"""Lists the Google Analytics accounts link to the specified Google Marketing Platform organization. @@ -455,8 +489,10 @@ async def sample_list_analytics_account_links(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ads.marketingplatform_admin_v1alpha.services.marketingplatform_admin_service.pagers.ListAnalyticsAccountLinksAsyncPager: @@ -536,7 +572,7 @@ async def create_analytics_account_link( analytics_account_link: Optional[resources.AnalyticsAccountLink] = None, retry: OptionalRetry = 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.AnalyticsAccountLink: r"""Creates the link between the Analytics account and the Google Marketing Platform organization. @@ -599,8 +635,10 @@ async def sample_create_analytics_account_link(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ads.marketingplatform_admin_v1alpha.types.AnalyticsAccountLink: @@ -669,7 +707,7 @@ async def delete_analytics_account_link( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 AnalyticsAccountLink, which detaches the Analytics account from the Google Marketing Platform @@ -716,8 +754,10 @@ async def sample_delete_analytics_account_link(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -773,7 +813,7 @@ async def set_property_service_level( analytics_account_link: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> marketingplatform_admin.SetPropertyServiceLevelResponse: r"""Updates the service level for an Analytics property. @@ -820,8 +860,10 @@ async def sample_set_property_service_level(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ads.marketingplatform_admin_v1alpha.types.SetPropertyServiceLevelResponse: diff --git a/packages/google-ads-marketingplatform-admin/google/ads/marketingplatform_admin_v1alpha/services/marketingplatform_admin_service/client.py b/packages/google-ads-marketingplatform-admin/google/ads/marketingplatform_admin_v1alpha/services/marketingplatform_admin_service/client.py index 5128a184339f..15e600d41a85 100644 --- a/packages/google-ads-marketingplatform-admin/google/ads/marketingplatform_admin_v1alpha/services/marketingplatform_admin_service/client.py +++ b/packages/google-ads-marketingplatform-admin/google/ads/marketingplatform_admin_v1alpha/services/marketingplatform_admin_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.ads.marketingplatform_admin_v1alpha.services.marketingplatform_admin_service import ( pagers, ) @@ -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( @@ -712,6 +726,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.marketingplatform.admin_v1alpha.MarketingplatformAdminServiceClient`.", + extra={ + "serviceName": "google.marketingplatform.admin.v1alpha.MarketingplatformAdminService", + "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.marketingplatform.admin.v1alpha.MarketingplatformAdminService", + "credentialsType": None, + }, + ) + def get_organization( self, request: Optional[ @@ -721,7 +758,7 @@ def get_organization( name: Optional[str] = None, retry: OptionalRetry = 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.Organization: r"""Lookup for a single organization. @@ -765,8 +802,10 @@ def sample_get_organization(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ads.marketingplatform_admin_v1alpha.types.Organization: @@ -826,7 +865,7 @@ def list_analytics_account_links( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAnalyticsAccountLinksPager: r"""Lists the Google Analytics accounts link to the specified Google Marketing Platform organization. @@ -873,8 +912,10 @@ def sample_list_analytics_account_links(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ads.marketingplatform_admin_v1alpha.services.marketingplatform_admin_service.pagers.ListAnalyticsAccountLinksPager: @@ -953,7 +994,7 @@ def create_analytics_account_link( analytics_account_link: Optional[resources.AnalyticsAccountLink] = None, retry: OptionalRetry = 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.AnalyticsAccountLink: r"""Creates the link between the Analytics account and the Google Marketing Platform organization. @@ -1016,8 +1057,10 @@ def sample_create_analytics_account_link(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ads.marketingplatform_admin_v1alpha.types.AnalyticsAccountLink: @@ -1085,7 +1128,7 @@ def delete_analytics_account_link( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 AnalyticsAccountLink, which detaches the Analytics account from the Google Marketing Platform @@ -1132,8 +1175,10 @@ def sample_delete_analytics_account_link(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -1188,7 +1233,7 @@ def set_property_service_level( analytics_account_link: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> marketingplatform_admin.SetPropertyServiceLevelResponse: r"""Updates the service level for an Analytics property. @@ -1235,8 +1280,10 @@ def sample_set_property_service_level(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ads.marketingplatform_admin_v1alpha.types.SetPropertyServiceLevelResponse: diff --git a/packages/google-ads-marketingplatform-admin/google/ads/marketingplatform_admin_v1alpha/services/marketingplatform_admin_service/pagers.py b/packages/google-ads-marketingplatform-admin/google/ads/marketingplatform_admin_v1alpha/services/marketingplatform_admin_service/pagers.py index bed8bd431770..e473c51fd7b2 100644 --- a/packages/google-ads-marketingplatform-admin/google/ads/marketingplatform_admin_v1alpha/services/marketingplatform_admin_service/pagers.py +++ b/packages/google-ads-marketingplatform-admin/google/ads/marketingplatform_admin_v1alpha/services/marketingplatform_admin_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 = marketingplatform_admin.ListAnalyticsAccountLinksRequest( @@ -152,7 +154,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. @@ -166,8 +168,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 = marketingplatform_admin.ListAnalyticsAccountLinksRequest( diff --git a/packages/google-ads-marketingplatform-admin/google/ads/marketingplatform_admin_v1alpha/services/marketingplatform_admin_service/transports/grpc.py b/packages/google-ads-marketingplatform-admin/google/ads/marketingplatform_admin_v1alpha/services/marketingplatform_admin_service/transports/grpc.py index e8f3656c2d06..be769d9fcd52 100644 --- a/packages/google-ads-marketingplatform-admin/google/ads/marketingplatform_admin_v1alpha/services/marketingplatform_admin_service/transports/grpc.py +++ b/packages/google-ads-marketingplatform-admin/google/ads/marketingplatform_admin_v1alpha/services/marketingplatform_admin_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,7 +24,10 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.ads.marketingplatform_admin_v1alpha.types import ( marketingplatform_admin, @@ -30,6 +36,81 @@ from .base import DEFAULT_CLIENT_INFO, MarketingplatformAdminServiceTransport +try: + from google.api_core import client_logging # 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.marketingplatform.admin.v1alpha.MarketingplatformAdminService", + "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.marketingplatform.admin.v1alpha.MarketingplatformAdminService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class MarketingplatformAdminServiceGrpcTransport( MarketingplatformAdminServiceTransport @@ -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 get_organization( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_organization" not in self._stubs: - self._stubs["get_organization"] = self.grpc_channel.unary_unary( + self._stubs["get_organization"] = self._logged_channel.unary_unary( "/google.marketingplatform.admin.v1alpha.MarketingplatformAdminService/GetOrganization", request_serializer=marketingplatform_admin.GetOrganizationRequest.serialize, response_deserializer=resources.Organization.deserialize, @@ -292,7 +378,9 @@ def list_analytics_account_links( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_analytics_account_links" not in self._stubs: - self._stubs["list_analytics_account_links"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_analytics_account_links" + ] = self._logged_channel.unary_unary( "/google.marketingplatform.admin.v1alpha.MarketingplatformAdminService/ListAnalyticsAccountLinks", request_serializer=marketingplatform_admin.ListAnalyticsAccountLinksRequest.serialize, response_deserializer=marketingplatform_admin.ListAnalyticsAccountLinksResponse.deserialize, @@ -330,7 +418,7 @@ def create_analytics_account_link( if "create_analytics_account_link" not in self._stubs: self._stubs[ "create_analytics_account_link" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.marketingplatform.admin.v1alpha.MarketingplatformAdminService/CreateAnalyticsAccountLink", request_serializer=marketingplatform_admin.CreateAnalyticsAccountLinkRequest.serialize, response_deserializer=resources.AnalyticsAccountLink.deserialize, @@ -365,7 +453,7 @@ def delete_analytics_account_link( if "delete_analytics_account_link" not in self._stubs: self._stubs[ "delete_analytics_account_link" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.marketingplatform.admin.v1alpha.MarketingplatformAdminService/DeleteAnalyticsAccountLink", request_serializer=marketingplatform_admin.DeleteAnalyticsAccountLinkRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -394,7 +482,9 @@ def set_property_service_level( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_property_service_level" not in self._stubs: - self._stubs["set_property_service_level"] = self.grpc_channel.unary_unary( + self._stubs[ + "set_property_service_level" + ] = self._logged_channel.unary_unary( "/google.marketingplatform.admin.v1alpha.MarketingplatformAdminService/SetPropertyServiceLevel", request_serializer=marketingplatform_admin.SetPropertyServiceLevelRequest.serialize, response_deserializer=marketingplatform_admin.SetPropertyServiceLevelResponse.deserialize, @@ -402,7 +492,7 @@ def set_property_service_level( return self._stubs["set_property_service_level"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-ads-marketingplatform-admin/google/ads/marketingplatform_admin_v1alpha/services/marketingplatform_admin_service/transports/grpc_asyncio.py b/packages/google-ads-marketingplatform-admin/google/ads/marketingplatform_admin_v1alpha/services/marketingplatform_admin_service/transports/grpc_asyncio.py index 34d4287705fb..37cccdfff598 100644 --- a/packages/google-ads-marketingplatform-admin/google/ads/marketingplatform_admin_v1alpha/services/marketingplatform_admin_service/transports/grpc_asyncio.py +++ b/packages/google-ads-marketingplatform-admin/google/ads/marketingplatform_admin_v1alpha/services/marketingplatform_admin_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,8 +26,11 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.ads.marketingplatform_admin_v1alpha.types import ( marketingplatform_admin, @@ -34,6 +40,82 @@ from .base import DEFAULT_CLIENT_INFO, MarketingplatformAdminServiceTransport from .grpc import MarketingplatformAdminServiceGrpcTransport +try: + from google.api_core import client_logging # 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.marketingplatform.admin.v1alpha.MarketingplatformAdminService", + "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.marketingplatform.admin.v1alpha.MarketingplatformAdminService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class MarketingplatformAdminServiceGrpcAsyncIOTransport( MarketingplatformAdminServiceTransport @@ -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 get_organization( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_organization" not in self._stubs: - self._stubs["get_organization"] = self.grpc_channel.unary_unary( + self._stubs["get_organization"] = self._logged_channel.unary_unary( "/google.marketingplatform.admin.v1alpha.MarketingplatformAdminService/GetOrganization", request_serializer=marketingplatform_admin.GetOrganizationRequest.serialize, response_deserializer=resources.Organization.deserialize, @@ -301,7 +386,9 @@ def list_analytics_account_links( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_analytics_account_links" not in self._stubs: - self._stubs["list_analytics_account_links"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_analytics_account_links" + ] = self._logged_channel.unary_unary( "/google.marketingplatform.admin.v1alpha.MarketingplatformAdminService/ListAnalyticsAccountLinks", request_serializer=marketingplatform_admin.ListAnalyticsAccountLinksRequest.serialize, response_deserializer=marketingplatform_admin.ListAnalyticsAccountLinksResponse.deserialize, @@ -339,7 +426,7 @@ def create_analytics_account_link( if "create_analytics_account_link" not in self._stubs: self._stubs[ "create_analytics_account_link" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.marketingplatform.admin.v1alpha.MarketingplatformAdminService/CreateAnalyticsAccountLink", request_serializer=marketingplatform_admin.CreateAnalyticsAccountLinkRequest.serialize, response_deserializer=resources.AnalyticsAccountLink.deserialize, @@ -375,7 +462,7 @@ def delete_analytics_account_link( if "delete_analytics_account_link" not in self._stubs: self._stubs[ "delete_analytics_account_link" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.marketingplatform.admin.v1alpha.MarketingplatformAdminService/DeleteAnalyticsAccountLink", request_serializer=marketingplatform_admin.DeleteAnalyticsAccountLinkRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -404,7 +491,9 @@ def set_property_service_level( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_property_service_level" not in self._stubs: - self._stubs["set_property_service_level"] = self.grpc_channel.unary_unary( + self._stubs[ + "set_property_service_level" + ] = self._logged_channel.unary_unary( "/google.marketingplatform.admin.v1alpha.MarketingplatformAdminService/SetPropertyServiceLevel", request_serializer=marketingplatform_admin.SetPropertyServiceLevelRequest.serialize, response_deserializer=marketingplatform_admin.SetPropertyServiceLevelResponse.deserialize, @@ -447,7 +536,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-ads-marketingplatform-admin/google/ads/marketingplatform_admin_v1alpha/services/marketingplatform_admin_service/transports/rest.py b/packages/google-ads-marketingplatform-admin/google/ads/marketingplatform_admin_v1alpha/services/marketingplatform_admin_service/transports/rest.py index ed52685f96f3..517279fa52d3 100644 --- a/packages/google-ads-marketingplatform-admin/google/ads/marketingplatform_admin_v1alpha/services/marketingplatform_admin_service/transports/rest.py +++ b/packages/google-ads-marketingplatform-admin/google/ads/marketingplatform_admin_v1alpha/services/marketingplatform_admin_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, @@ -109,10 +117,10 @@ def post_set_property_service_level(self, response): def pre_create_analytics_account_link( self, request: marketingplatform_admin.CreateAnalyticsAccountLinkRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ marketingplatform_admin.CreateAnalyticsAccountLinkRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_analytics_account_link @@ -135,10 +143,10 @@ def post_create_analytics_account_link( def pre_delete_analytics_account_link( self, request: marketingplatform_admin.DeleteAnalyticsAccountLinkRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ marketingplatform_admin.DeleteAnalyticsAccountLinkRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_analytics_account_link @@ -150,9 +158,10 @@ def pre_delete_analytics_account_link( def pre_get_organization( self, request: marketingplatform_admin.GetOrganizationRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - marketingplatform_admin.GetOrganizationRequest, Sequence[Tuple[str, str]] + marketingplatform_admin.GetOrganizationRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_organization @@ -175,10 +184,10 @@ def post_get_organization( def pre_list_analytics_account_links( self, request: marketingplatform_admin.ListAnalyticsAccountLinksRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ marketingplatform_admin.ListAnalyticsAccountLinksRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_analytics_account_links @@ -201,10 +210,10 @@ def post_list_analytics_account_links( def pre_set_property_service_level( self, request: marketingplatform_admin.SetPropertyServiceLevelRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ marketingplatform_admin.SetPropertyServiceLevelRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for set_property_service_level @@ -354,7 +363,7 @@ 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.AnalyticsAccountLink: r"""Call the create analytics account link method over HTTP. @@ -366,8 +375,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.AnalyticsAccountLink: @@ -381,6 +392,7 @@ def __call__( http_options = ( _BaseMarketingplatformAdminServiceRestTransport._BaseCreateAnalyticsAccountLink._get_http_options() ) + request, metadata = self._interceptor.pre_create_analytics_account_link( request, metadata ) @@ -397,6 +409,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.marketingplatform.admin_v1alpha.MarketingplatformAdminServiceClient.CreateAnalyticsAccountLink", + extra={ + "serviceName": "google.marketingplatform.admin.v1alpha.MarketingplatformAdminService", + "rpcName": "CreateAnalyticsAccountLink", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MarketingplatformAdminServiceRestTransport._CreateAnalyticsAccountLink._get_response( self._host, @@ -418,7 +457,29 @@ def __call__( pb_resp = resources.AnalyticsAccountLink.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_analytics_account_link(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.AnalyticsAccountLink.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.marketingplatform.admin_v1alpha.MarketingplatformAdminServiceClient.create_analytics_account_link", + extra={ + "serviceName": "google.marketingplatform.admin.v1alpha.MarketingplatformAdminService", + "rpcName": "CreateAnalyticsAccountLink", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteAnalyticsAccountLink( @@ -458,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]]] = (), ): r"""Call the delete analytics account link method over HTTP. @@ -470,13 +531,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 = ( _BaseMarketingplatformAdminServiceRestTransport._BaseDeleteAnalyticsAccountLink._get_http_options() ) + request, metadata = self._interceptor.pre_delete_analytics_account_link( request, metadata ) @@ -489,6 +553,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.marketingplatform.admin_v1alpha.MarketingplatformAdminServiceClient.DeleteAnalyticsAccountLink", + extra={ + "serviceName": "google.marketingplatform.admin.v1alpha.MarketingplatformAdminService", + "rpcName": "DeleteAnalyticsAccountLink", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MarketingplatformAdminServiceRestTransport._DeleteAnalyticsAccountLink._get_response( self._host, @@ -539,7 +630,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Organization: r"""Call the get organization method over HTTP. @@ -550,8 +641,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.Organization: @@ -563,6 +656,7 @@ def __call__( http_options = ( _BaseMarketingplatformAdminServiceRestTransport._BaseGetOrganization._get_http_options() ) + request, metadata = self._interceptor.pre_get_organization( request, metadata ) @@ -575,6 +669,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.marketingplatform.admin_v1alpha.MarketingplatformAdminServiceClient.GetOrganization", + extra={ + "serviceName": "google.marketingplatform.admin.v1alpha.MarketingplatformAdminService", + "rpcName": "GetOrganization", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MarketingplatformAdminServiceRestTransport._GetOrganization._get_response( self._host, @@ -595,7 +716,29 @@ def __call__( pb_resp = resources.Organization.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_organization(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Organization.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.marketingplatform.admin_v1alpha.MarketingplatformAdminServiceClient.get_organization", + extra={ + "serviceName": "google.marketingplatform.admin.v1alpha.MarketingplatformAdminService", + "rpcName": "GetOrganization", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAnalyticsAccountLinks( @@ -635,7 +778,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> marketingplatform_admin.ListAnalyticsAccountLinksResponse: r"""Call the list analytics account links method over HTTP. @@ -647,8 +790,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.marketingplatform_admin.ListAnalyticsAccountLinksResponse: @@ -660,6 +805,7 @@ def __call__( http_options = ( _BaseMarketingplatformAdminServiceRestTransport._BaseListAnalyticsAccountLinks._get_http_options() ) + request, metadata = self._interceptor.pre_list_analytics_account_links( request, metadata ) @@ -672,6 +818,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.marketingplatform.admin_v1alpha.MarketingplatformAdminServiceClient.ListAnalyticsAccountLinks", + extra={ + "serviceName": "google.marketingplatform.admin.v1alpha.MarketingplatformAdminService", + "rpcName": "ListAnalyticsAccountLinks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MarketingplatformAdminServiceRestTransport._ListAnalyticsAccountLinks._get_response( self._host, @@ -692,7 +865,31 @@ def __call__( pb_resp = marketingplatform_admin.ListAnalyticsAccountLinksResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_analytics_account_links(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = marketingplatform_admin.ListAnalyticsAccountLinksResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.marketingplatform.admin_v1alpha.MarketingplatformAdminServiceClient.list_analytics_account_links", + extra={ + "serviceName": "google.marketingplatform.admin.v1alpha.MarketingplatformAdminService", + "rpcName": "ListAnalyticsAccountLinks", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetPropertyServiceLevel( @@ -733,7 +930,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> marketingplatform_admin.SetPropertyServiceLevelResponse: r"""Call the set property service level method over HTTP. @@ -745,8 +942,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.marketingplatform_admin.SetPropertyServiceLevelResponse: @@ -758,6 +957,7 @@ def __call__( http_options = ( _BaseMarketingplatformAdminServiceRestTransport._BaseSetPropertyServiceLevel._get_http_options() ) + request, metadata = self._interceptor.pre_set_property_service_level( request, metadata ) @@ -774,6 +974,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.marketingplatform.admin_v1alpha.MarketingplatformAdminServiceClient.SetPropertyServiceLevel", + extra={ + "serviceName": "google.marketingplatform.admin.v1alpha.MarketingplatformAdminService", + "rpcName": "SetPropertyServiceLevel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MarketingplatformAdminServiceRestTransport._SetPropertyServiceLevel._get_response( self._host, @@ -795,7 +1022,33 @@ def __call__( pb_resp = marketingplatform_admin.SetPropertyServiceLevelResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_property_service_level(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + marketingplatform_admin.SetPropertyServiceLevelResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.marketingplatform.admin_v1alpha.MarketingplatformAdminServiceClient.set_property_service_level", + extra={ + "serviceName": "google.marketingplatform.admin.v1alpha.MarketingplatformAdminService", + "rpcName": "SetPropertyServiceLevel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-ads-marketingplatform-admin/samples/generated_samples/snippet_metadata_google.marketingplatform.admin.v1alpha.json b/packages/google-ads-marketingplatform-admin/samples/generated_samples/snippet_metadata_google.marketingplatform.admin.v1alpha.json index 7e4cf53f136e..86c76465c9d5 100644 --- a/packages/google-ads-marketingplatform-admin/samples/generated_samples/snippet_metadata_google.marketingplatform.admin.v1alpha.json +++ b/packages/google-ads-marketingplatform-admin/samples/generated_samples/snippet_metadata_google.marketingplatform.admin.v1alpha.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-ads-marketingplatform-admin", - "version": "0.1.2" + "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.ads.marketingplatform_admin_v1alpha.types.AnalyticsAccountLink", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.marketingplatform_admin_v1alpha.types.AnalyticsAccountLink", @@ -216,7 +216,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_analytics_account_link" @@ -293,7 +293,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_analytics_account_link" @@ -371,7 +371,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.marketingplatform_admin_v1alpha.types.Organization", @@ -451,7 +451,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.marketingplatform_admin_v1alpha.types.Organization", @@ -532,7 +532,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.marketingplatform_admin_v1alpha.services.marketingplatform_admin_service.pagers.ListAnalyticsAccountLinksAsyncPager", @@ -612,7 +612,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.marketingplatform_admin_v1alpha.services.marketingplatform_admin_service.pagers.ListAnalyticsAccountLinksPager", @@ -693,7 +693,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.marketingplatform_admin_v1alpha.types.SetPropertyServiceLevelResponse", @@ -773,7 +773,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ads.marketingplatform_admin_v1alpha.types.SetPropertyServiceLevelResponse", diff --git a/packages/google-ads-marketingplatform-admin/tests/unit/gapic/marketingplatform_admin_v1alpha/test_marketingplatform_admin_service.py b/packages/google-ads-marketingplatform-admin/tests/unit/gapic/marketingplatform_admin_v1alpha/test_marketingplatform_admin_service.py index 96938b18f7ab..09189bc7f2a3 100644 --- a/packages/google-ads-marketingplatform-admin/tests/unit/gapic/marketingplatform_admin_v1alpha/test_marketingplatform_admin_service.py +++ b/packages/google-ads-marketingplatform-admin/tests/unit/gapic/marketingplatform_admin_v1alpha/test_marketingplatform_admin_service.py @@ -3176,6 +3176,7 @@ def test_get_organization_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_organization(request) @@ -3221,6 +3222,7 @@ def test_get_organization_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_organization(**mock_args) @@ -3364,6 +3366,7 @@ def test_list_analytics_account_links_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_analytics_account_links(request) @@ -3419,6 +3422,7 @@ def test_list_analytics_account_links_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_analytics_account_links(**mock_args) @@ -3620,6 +3624,7 @@ def test_create_analytics_account_link_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_analytics_account_link(request) @@ -3676,6 +3681,7 @@ def test_create_analytics_account_link_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_analytics_account_link(**mock_args) @@ -3810,6 +3816,7 @@ def test_delete_analytics_account_link_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_analytics_account_link(request) @@ -3855,6 +3862,7 @@ def test_delete_analytics_account_link_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_analytics_account_link(**mock_args) @@ -3998,6 +4006,7 @@ def test_set_property_service_level_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.set_property_service_level(request) @@ -4056,6 +4065,7 @@ def test_set_property_service_level_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.set_property_service_level(**mock_args) @@ -4487,6 +4497,7 @@ def test_get_organization_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_organization(request) @@ -4523,6 +4534,7 @@ def test_get_organization_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_organization(request) # Establish that the response is the type that we expect. @@ -4564,6 +4576,7 @@ def test_get_organization_rest_interceptors(null_interceptor): req.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.Organization.to_json(resources.Organization()) req.return_value.content = return_value @@ -4608,6 +4621,7 @@ def test_list_analytics_account_links_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_analytics_account_links(request) @@ -4645,6 +4659,7 @@ def test_list_analytics_account_links_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_analytics_account_links(request) # Establish that the response is the type that we expect. @@ -4687,6 +4702,7 @@ def test_list_analytics_account_links_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = ( marketingplatform_admin.ListAnalyticsAccountLinksResponse.to_json( marketingplatform_admin.ListAnalyticsAccountLinksResponse() @@ -4735,6 +4751,7 @@ def test_create_analytics_account_link_rest_bad_request( response_value.status_code = 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_analytics_account_link(request) @@ -4850,6 +4867,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_analytics_account_link(request) # Establish that the response is the type that we expect. @@ -4898,6 +4916,7 @@ def test_create_analytics_account_link_rest_interceptors(null_interceptor): req.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.AnalyticsAccountLink.to_json( resources.AnalyticsAccountLink() ) @@ -4944,6 +4963,7 @@ def test_delete_analytics_account_link_rest_bad_request( response_value.status_code = 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_analytics_account_link(request) @@ -4974,6 +4994,7 @@ def test_delete_analytics_account_link_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_analytics_account_link(request) # Establish that the response is the type that we expect. @@ -5011,6 +5032,7 @@ def test_delete_analytics_account_link_rest_interceptors(null_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 = marketingplatform_admin.DeleteAnalyticsAccountLinkRequest() metadata = [ @@ -5053,6 +5075,7 @@ def test_set_property_service_level_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.set_property_service_level(request) @@ -5090,6 +5113,7 @@ def test_set_property_service_level_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.set_property_service_level(request) # Establish that the response is the type that we expect. @@ -5131,6 +5155,7 @@ def test_set_property_service_level_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = marketingplatform_admin.SetPropertyServiceLevelResponse.to_json( marketingplatform_admin.SetPropertyServiceLevelResponse() ) diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage/gapic_version.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage/gapic_version.py index b72badcc1eca..558c8aab67c5 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage/gapic_version.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.6.13" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/gapic_version.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/gapic_version.py index b72badcc1eca..558c8aab67c5 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/gapic_version.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.6.13" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/generative_service/async_client.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/generative_service/async_client.py index ae0b42b98ca6..2a0471ed2dc9 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/generative_service/async_client.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/generative_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, @@ -54,6 +55,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, GenerativeServiceTransport from .transports.grpc_asyncio import GenerativeServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class GenerativeServiceAsyncClient: """API for using Large Models that generate multimodal content @@ -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.ai.generativelanguage_v1.GenerativeServiceAsyncClient`.", + extra={ + "serviceName": "google.ai.generativelanguage.v1.GenerativeService", + "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.ai.generativelanguage.v1.GenerativeService", + "credentialsType": None, + }, + ) + async def generate_content( self, request: Optional[ @@ -275,7 +307,7 @@ async def generate_content( contents: Optional[MutableSequence[content.Content]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_service.GenerateContentResponse: r"""Generates a model response given an input ``GenerateContentRequest``. Refer to the `text generation @@ -342,8 +374,10 @@ async def sample_generate_content(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1.types.GenerateContentResponse: @@ -419,7 +453,7 @@ def stream_generate_content( contents: Optional[MutableSequence[content.Content]] = None, retry: OptionalRetry = 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[generative_service.GenerateContentResponse]]: r"""Generates a `streamed response `__ @@ -481,8 +515,10 @@ async def sample_stream_generate_content(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: AsyncIterable[google.ai.generativelanguage_v1.types.GenerateContentResponse]: @@ -556,7 +592,7 @@ async def embed_content( content: Optional[gag_content.Content] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_service.EmbedContentResponse: r"""Generates a text embedding vector from the input ``Content`` using the specified `Gemini Embedding @@ -614,8 +650,10 @@ async def sample_embed_content(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1.types.EmbedContentResponse: @@ -681,7 +719,7 @@ async def batch_embed_contents( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_service.BatchEmbedContentsResponse: r"""Generates multiple embedding vectors from the input ``Content`` which consists of a batch of strings represented as @@ -744,8 +782,10 @@ async def sample_batch_embed_contents(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1.types.BatchEmbedContentsResponse: @@ -807,7 +847,7 @@ async def count_tokens( contents: Optional[MutableSequence[content.Content]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_service.CountTokensResponse: r"""Runs a model's tokenizer on input ``Content`` and returns the token count. Refer to the `tokens @@ -870,8 +910,10 @@ async def sample_count_tokens(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1.types.CountTokensResponse: @@ -934,7 +976,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. @@ -945,8 +987,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. @@ -987,7 +1031,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. @@ -998,8 +1042,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. @@ -1040,7 +1086,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. @@ -1055,8 +1101,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-ai-generativelanguage/google/ai/generativelanguage_v1/services/generative_service/client.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/generative_service/client.py index 3194a369d1f6..258a77134a14 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/generative_service/client.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/generative_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 ( @@ -49,6 +50,15 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + from google.longrunning import operations_pb2 # type: ignore from google.ai.generativelanguage_v1.types import content @@ -581,6 +591,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -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.ai.generativelanguage_v1.GenerativeServiceClient`.", + extra={ + "serviceName": "google.ai.generativelanguage.v1.GenerativeService", + "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.ai.generativelanguage.v1.GenerativeService", + "credentialsType": None, + }, + ) + def generate_content( self, request: Optional[ @@ -657,7 +694,7 @@ def generate_content( contents: Optional[MutableSequence[content.Content]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_service.GenerateContentResponse: r"""Generates a model response given an input ``GenerateContentRequest``. Refer to the `text generation @@ -724,8 +761,10 @@ def sample_generate_content(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1.types.GenerateContentResponse: @@ -798,7 +837,7 @@ def stream_generate_content( contents: Optional[MutableSequence[content.Content]] = None, retry: OptionalRetry = 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[generative_service.GenerateContentResponse]: r"""Generates a `streamed response `__ @@ -860,8 +899,10 @@ def sample_stream_generate_content(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: Iterable[google.ai.generativelanguage_v1.types.GenerateContentResponse]: @@ -932,7 +973,7 @@ def embed_content( content: Optional[gag_content.Content] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_service.EmbedContentResponse: r"""Generates a text embedding vector from the input ``Content`` using the specified `Gemini Embedding @@ -990,8 +1031,10 @@ def sample_embed_content(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1.types.EmbedContentResponse: @@ -1054,7 +1097,7 @@ def batch_embed_contents( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_service.BatchEmbedContentsResponse: r"""Generates multiple embedding vectors from the input ``Content`` which consists of a batch of strings represented as @@ -1117,8 +1160,10 @@ def sample_batch_embed_contents(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1.types.BatchEmbedContentsResponse: @@ -1177,7 +1222,7 @@ def count_tokens( contents: Optional[MutableSequence[content.Content]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_service.CountTokensResponse: r"""Runs a model's tokenizer on input ``Content`` and returns the token count. Refer to the `tokens @@ -1240,8 +1285,10 @@ def sample_count_tokens(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1.types.CountTokensResponse: @@ -1314,7 +1361,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. @@ -1325,8 +1372,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. @@ -1367,7 +1416,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. @@ -1378,8 +1427,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. @@ -1420,7 +1471,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. @@ -1435,8 +1486,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-ai-generativelanguage/google/ai/generativelanguage_v1/services/generative_service/transports/grpc.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/generative_service/transports/grpc.py index 0c05a0b60ad9..eae71d9cc454 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/generative_service/transports/grpc.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/generative_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.ai.generativelanguage_v1.types import generative_service from .base import DEFAULT_CLIENT_INFO, GenerativeServiceTransport +try: + from google.api_core import client_logging # 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.ai.generativelanguage.v1.GenerativeService", + "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.ai.generativelanguage.v1.GenerativeService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class GenerativeServiceGrpcTransport(GenerativeServiceTransport): """gRPC backend transport for GenerativeService. @@ -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 @@ -266,7 +352,7 @@ def generate_content( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_content" not in self._stubs: - self._stubs["generate_content"] = self.grpc_channel.unary_unary( + self._stubs["generate_content"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1.GenerativeService/GenerateContent", request_serializer=generative_service.GenerateContentRequest.serialize, response_deserializer=generative_service.GenerateContentResponse.deserialize, @@ -297,7 +383,7 @@ def stream_generate_content( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stream_generate_content" not in self._stubs: - self._stubs["stream_generate_content"] = self.grpc_channel.unary_stream( + self._stubs["stream_generate_content"] = self._logged_channel.unary_stream( "/google.ai.generativelanguage.v1.GenerativeService/StreamGenerateContent", request_serializer=generative_service.GenerateContentRequest.serialize, response_deserializer=generative_service.GenerateContentResponse.deserialize, @@ -328,7 +414,7 @@ def embed_content( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "embed_content" not in self._stubs: - self._stubs["embed_content"] = self.grpc_channel.unary_unary( + self._stubs["embed_content"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1.GenerativeService/EmbedContent", request_serializer=generative_service.EmbedContentRequest.serialize, response_deserializer=generative_service.EmbedContentResponse.deserialize, @@ -359,7 +445,7 @@ def batch_embed_contents( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_embed_contents" not in self._stubs: - self._stubs["batch_embed_contents"] = self.grpc_channel.unary_unary( + self._stubs["batch_embed_contents"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1.GenerativeService/BatchEmbedContents", request_serializer=generative_service.BatchEmbedContentsRequest.serialize, response_deserializer=generative_service.BatchEmbedContentsResponse.deserialize, @@ -390,7 +476,7 @@ def count_tokens( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "count_tokens" not in self._stubs: - self._stubs["count_tokens"] = self.grpc_channel.unary_unary( + self._stubs["count_tokens"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1.GenerativeService/CountTokens", request_serializer=generative_service.CountTokensRequest.serialize, response_deserializer=generative_service.CountTokensResponse.deserialize, @@ -398,7 +484,7 @@ def count_tokens( return self._stubs["count_tokens"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -410,7 +496,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -427,7 +513,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -446,7 +532,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/generative_service/transports/grpc_asyncio.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/generative_service/transports/grpc_asyncio.py index 7156ce990640..a696bbc5ce28 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/generative_service/transports/grpc_asyncio.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/generative_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.ai.generativelanguage_v1.types import generative_service from .base import DEFAULT_CLIENT_INFO, GenerativeServiceTransport from .grpc import GenerativeServiceGrpcTransport +try: + from google.api_core import client_logging # 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.ai.generativelanguage.v1.GenerativeService", + "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.ai.generativelanguage.v1.GenerativeService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class GenerativeServiceGrpcAsyncIOTransport(GenerativeServiceTransport): """gRPC AsyncIO backend transport for GenerativeService. @@ -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 @@ -274,7 +359,7 @@ def generate_content( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_content" not in self._stubs: - self._stubs["generate_content"] = self.grpc_channel.unary_unary( + self._stubs["generate_content"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1.GenerativeService/GenerateContent", request_serializer=generative_service.GenerateContentRequest.serialize, response_deserializer=generative_service.GenerateContentResponse.deserialize, @@ -305,7 +390,7 @@ def stream_generate_content( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stream_generate_content" not in self._stubs: - self._stubs["stream_generate_content"] = self.grpc_channel.unary_stream( + self._stubs["stream_generate_content"] = self._logged_channel.unary_stream( "/google.ai.generativelanguage.v1.GenerativeService/StreamGenerateContent", request_serializer=generative_service.GenerateContentRequest.serialize, response_deserializer=generative_service.GenerateContentResponse.deserialize, @@ -336,7 +421,7 @@ def embed_content( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "embed_content" not in self._stubs: - self._stubs["embed_content"] = self.grpc_channel.unary_unary( + self._stubs["embed_content"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1.GenerativeService/EmbedContent", request_serializer=generative_service.EmbedContentRequest.serialize, response_deserializer=generative_service.EmbedContentResponse.deserialize, @@ -367,7 +452,7 @@ def batch_embed_contents( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_embed_contents" not in self._stubs: - self._stubs["batch_embed_contents"] = self.grpc_channel.unary_unary( + self._stubs["batch_embed_contents"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1.GenerativeService/BatchEmbedContents", request_serializer=generative_service.BatchEmbedContentsRequest.serialize, response_deserializer=generative_service.BatchEmbedContentsResponse.deserialize, @@ -399,7 +484,7 @@ def count_tokens( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "count_tokens" not in self._stubs: - self._stubs["count_tokens"] = self.grpc_channel.unary_unary( + self._stubs["count_tokens"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1.GenerativeService/CountTokens", request_serializer=generative_service.CountTokensRequest.serialize, response_deserializer=generative_service.CountTokensResponse.deserialize, @@ -502,7 +587,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: @@ -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, diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/generative_service/transports/rest.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/generative_service/transports/rest.py index 2db8dba0cc18..152a68d02151 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/generative_service/transports/rest.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/generative_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,11 @@ def post_stream_generate_content(self, response): def pre_batch_embed_contents( self, request: generative_service.BatchEmbedContentsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[generative_service.BatchEmbedContentsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + generative_service.BatchEmbedContentsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for batch_embed_contents Override in a subclass to manipulate the request or metadata @@ -133,8 +144,10 @@ def post_batch_embed_contents( def pre_count_tokens( self, request: generative_service.CountTokensRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[generative_service.CountTokensRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + generative_service.CountTokensRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for count_tokens Override in a subclass to manipulate the request or metadata @@ -156,8 +169,10 @@ def post_count_tokens( def pre_embed_content( self, request: generative_service.EmbedContentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[generative_service.EmbedContentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + generative_service.EmbedContentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for embed_content Override in a subclass to manipulate the request or metadata @@ -179,8 +194,11 @@ def post_embed_content( def pre_generate_content( self, request: generative_service.GenerateContentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[generative_service.GenerateContentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + generative_service.GenerateContentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for generate_content Override in a subclass to manipulate the request or metadata @@ -202,8 +220,11 @@ def post_generate_content( def pre_stream_generate_content( self, request: generative_service.GenerateContentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[generative_service.GenerateContentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + generative_service.GenerateContentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for stream_generate_content Override in a subclass to manipulate the request or metadata @@ -225,8 +246,10 @@ def post_stream_generate_content( 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 @@ -246,8 +269,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -269,8 +294,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 @@ -413,7 +440,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_service.BatchEmbedContentsResponse: r"""Call the batch embed contents method over HTTP. @@ -424,8 +451,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.generative_service.BatchEmbedContentsResponse: @@ -435,6 +464,7 @@ def __call__( http_options = ( _BaseGenerativeServiceRestTransport._BaseBatchEmbedContents._get_http_options() ) + request, metadata = self._interceptor.pre_batch_embed_contents( request, metadata ) @@ -451,6 +481,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1.GenerativeServiceClient.BatchEmbedContents", + extra={ + "serviceName": "google.ai.generativelanguage.v1.GenerativeService", + "rpcName": "BatchEmbedContents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GenerativeServiceRestTransport._BatchEmbedContents._get_response( self._host, @@ -472,7 +529,31 @@ def __call__( pb_resp = generative_service.BatchEmbedContentsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_embed_contents(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + generative_service.BatchEmbedContentsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1.GenerativeServiceClient.batch_embed_contents", + extra={ + "serviceName": "google.ai.generativelanguage.v1.GenerativeService", + "rpcName": "BatchEmbedContents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CountTokens( @@ -510,7 +591,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_service.CountTokensResponse: r"""Call the count tokens method over HTTP. @@ -524,8 +605,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.generative_service.CountTokensResponse: @@ -539,6 +622,7 @@ def __call__( http_options = ( _BaseGenerativeServiceRestTransport._BaseCountTokens._get_http_options() ) + request, metadata = self._interceptor.pre_count_tokens(request, metadata) transcoded_request = _BaseGenerativeServiceRestTransport._BaseCountTokens._get_transcoded_request( http_options, request @@ -553,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 = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1.GenerativeServiceClient.CountTokens", + extra={ + "serviceName": "google.ai.generativelanguage.v1.GenerativeService", + "rpcName": "CountTokens", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GenerativeServiceRestTransport._CountTokens._get_response( self._host, @@ -574,7 +685,31 @@ def __call__( pb_resp = generative_service.CountTokensResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_count_tokens(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = generative_service.CountTokensResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1.GenerativeServiceClient.count_tokens", + extra={ + "serviceName": "google.ai.generativelanguage.v1.GenerativeService", + "rpcName": "CountTokens", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _EmbedContent( @@ -612,7 +747,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_service.EmbedContentResponse: r"""Call the embed content method over HTTP. @@ -623,8 +758,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.generative_service.EmbedContentResponse: @@ -634,6 +771,7 @@ def __call__( http_options = ( _BaseGenerativeServiceRestTransport._BaseEmbedContent._get_http_options() ) + request, metadata = self._interceptor.pre_embed_content(request, metadata) transcoded_request = _BaseGenerativeServiceRestTransport._BaseEmbedContent._get_transcoded_request( http_options, request @@ -648,6 +786,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1.GenerativeServiceClient.EmbedContent", + extra={ + "serviceName": "google.ai.generativelanguage.v1.GenerativeService", + "rpcName": "EmbedContent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GenerativeServiceRestTransport._EmbedContent._get_response( self._host, @@ -669,7 +834,31 @@ def __call__( pb_resp = generative_service.EmbedContentResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_embed_content(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = generative_service.EmbedContentResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1.GenerativeServiceClient.embed_content", + extra={ + "serviceName": "google.ai.generativelanguage.v1.GenerativeService", + "rpcName": "EmbedContent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GenerateContent( @@ -708,7 +897,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_service.GenerateContentResponse: r"""Call the generate content method over HTTP. @@ -719,8 +908,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.generative_service.GenerateContentResponse: @@ -746,6 +937,7 @@ def __call__( http_options = ( _BaseGenerativeServiceRestTransport._BaseGenerateContent._get_http_options() ) + request, metadata = self._interceptor.pre_generate_content( request, metadata ) @@ -762,6 +954,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1.GenerativeServiceClient.GenerateContent", + extra={ + "serviceName": "google.ai.generativelanguage.v1.GenerativeService", + "rpcName": "GenerateContent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GenerativeServiceRestTransport._GenerateContent._get_response( self._host, @@ -783,7 +1002,31 @@ def __call__( pb_resp = generative_service.GenerateContentResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_generate_content(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + generative_service.GenerateContentResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1.GenerativeServiceClient.generate_content", + extra={ + "serviceName": "google.ai.generativelanguage.v1.GenerativeService", + "rpcName": "GenerateContent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StreamGenerateContent( @@ -823,7 +1066,7 @@ 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: r"""Call the stream generate content method over HTTP. @@ -834,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: ~.generative_service.GenerateContentResponse: @@ -861,6 +1106,7 @@ def __call__( http_options = ( _BaseGenerativeServiceRestTransport._BaseStreamGenerateContent._get_http_options() ) + request, metadata = self._interceptor.pre_stream_generate_content( request, metadata ) @@ -877,6 +1123,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1.GenerativeServiceClient.StreamGenerateContent", + extra={ + "serviceName": "google.ai.generativelanguage.v1.GenerativeService", + "rpcName": "StreamGenerateContent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( GenerativeServiceRestTransport._StreamGenerateContent._get_response( @@ -899,6 +1172,7 @@ def __call__( resp = rest_streaming.ResponseIterator( response, generative_service.GenerateContentResponse ) + resp = self._interceptor.post_stream_generate_content(resp) return resp @@ -996,7 +1270,7 @@ 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. @@ -1006,13 +1280,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 = ( _BaseGenerativeServiceRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1029,6 +1306,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1.GenerativeServiceClient.CancelOperation", + extra={ + "serviceName": "google.ai.generativelanguage.v1.GenerativeService", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GenerativeServiceRestTransport._CancelOperation._get_response( self._host, @@ -1085,7 +1389,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1095,8 +1399,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: operations_pb2.Operation: Response from GetOperation method. @@ -1105,6 +1411,7 @@ def __call__( http_options = ( _BaseGenerativeServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseGenerativeServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1115,6 +1422,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1.GenerativeServiceClient.GetOperation", + extra={ + "serviceName": "google.ai.generativelanguage.v1.GenerativeService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GenerativeServiceRestTransport._GetOperation._get_response( self._host, @@ -1134,6 +1468,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.ai.generativelanguage_v1.GenerativeServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.ai.generativelanguage.v1.GenerativeService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1175,7 +1530,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1185,8 +1540,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1195,6 +1552,7 @@ def __call__( http_options = ( _BaseGenerativeServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseGenerativeServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1205,6 +1563,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1.GenerativeServiceClient.ListOperations", + extra={ + "serviceName": "google.ai.generativelanguage.v1.GenerativeService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GenerativeServiceRestTransport._ListOperations._get_response( self._host, @@ -1224,6 +1609,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.ai.generativelanguage_v1.GenerativeServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.ai.generativelanguage.v1.GenerativeService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/model_service/async_client.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/model_service/async_client.py index 1eca885c6dc1..560535ac33de 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/model_service/async_client.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/model_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, ModelServiceTransport from .transports.grpc_asyncio import ModelServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class ModelServiceAsyncClient: """Provides methods for getting metadata information about @@ -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.ai.generativelanguage_v1.ModelServiceAsyncClient`.", + extra={ + "serviceName": "google.ai.generativelanguage.v1.ModelService", + "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.ai.generativelanguage.v1.ModelService", + "credentialsType": None, + }, + ) + async def get_model( self, request: Optional[Union[model_service.GetModelRequest, dict]] = None, @@ -261,7 +293,7 @@ async def get_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model.Model: r"""Gets information about a specific ``Model`` such as its version number, token limits, @@ -314,8 +346,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.ai.generativelanguage_v1.types.Model: @@ -377,7 +411,7 @@ async def list_models( page_token: Optional[str] = None, retry: OptionalRetry = gapic_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 the ```Model``\ s `__ @@ -439,8 +473,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.ai.generativelanguage_v1.services.model_service.pagers.ListModelsAsyncPager: @@ -510,7 +546,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. @@ -521,8 +557,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. @@ -563,7 +601,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. @@ -574,8 +612,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. @@ -616,7 +656,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. @@ -631,8 +671,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-ai-generativelanguage/google/ai/generativelanguage_v1/services/model_service/client.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/model_service/client.py index 18edd759c7e4..8eb5853bd189 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/model_service/client.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/model_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.longrunning import operations_pb2 # type: ignore from google.ai.generativelanguage_v1.services.model_service import pagers @@ -573,6 +583,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -635,6 +649,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.ai.generativelanguage_v1.ModelServiceClient`.", + extra={ + "serviceName": "google.ai.generativelanguage.v1.ModelService", + "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.ai.generativelanguage.v1.ModelService", + "credentialsType": None, + }, + ) + def get_model( self, request: Optional[Union[model_service.GetModelRequest, dict]] = None, @@ -642,7 +679,7 @@ def get_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model.Model: r"""Gets information about a specific ``Model`` such as its version number, token limits, @@ -695,8 +732,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.ai.generativelanguage_v1.types.Model: @@ -755,7 +794,7 @@ def list_models( page_token: Optional[str] = None, retry: OptionalRetry = gapic_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 the ```Model``\ s `__ @@ -817,8 +856,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.ai.generativelanguage_v1.services.model_service.pagers.ListModelsPager: @@ -898,7 +939,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. @@ -909,8 +950,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. @@ -951,7 +994,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. @@ -962,8 +1005,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. @@ -1004,7 +1049,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. @@ -1019,8 +1064,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-ai-generativelanguage/google/ai/generativelanguage_v1/services/model_service/pagers.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/model_service/pagers.py index cb4d1cf23deb..e4a3f74c2901 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/model_service/pagers.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/model_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 = model_service.ListModelsRequest(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 = model_service.ListModelsRequest(request) diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/model_service/transports/grpc.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/model_service/transports/grpc.py index 234ee1693ebf..5434c9e43118 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/model_service/transports/grpc.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/model_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.ai.generativelanguage_v1.types import model, model_service from .base import DEFAULT_CLIENT_INFO, ModelServiceTransport +try: + from google.api_core import client_logging # 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.ai.generativelanguage.v1.ModelService", + "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.ai.generativelanguage.v1.ModelService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ModelServiceGrpcTransport(ModelServiceTransport): """gRPC backend transport for ModelService. @@ -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 @@ -258,7 +344,7 @@ def get_model(self) -> Callable[[model_service.GetModelRequest], model.Model]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_model" not in self._stubs: - self._stubs["get_model"] = self.grpc_channel.unary_unary( + self._stubs["get_model"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1.ModelService/GetModel", request_serializer=model_service.GetModelRequest.serialize, response_deserializer=model.Model.deserialize, @@ -286,7 +372,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.ai.generativelanguage.v1.ModelService/ListModels", request_serializer=model_service.ListModelsRequest.serialize, response_deserializer=model_service.ListModelsResponse.deserialize, @@ -294,7 +380,7 @@ def list_models( return self._stubs["list_models"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -306,7 +392,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, @@ -323,7 +409,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, @@ -342,7 +428,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-ai-generativelanguage/google/ai/generativelanguage_v1/services/model_service/transports/grpc_asyncio.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/model_service/transports/grpc_asyncio.py index 2c8bb11ed45a..4e12a60c4432 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/model_service/transports/grpc_asyncio.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/model_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.ai.generativelanguage_v1.types import model, model_service from .base import DEFAULT_CLIENT_INFO, ModelServiceTransport from .grpc import ModelServiceGrpcTransport +try: + from google.api_core import client_logging # 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.ai.generativelanguage.v1.ModelService", + "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.ai.generativelanguage.v1.ModelService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ModelServiceGrpcAsyncIOTransport(ModelServiceTransport): """gRPC AsyncIO backend transport for ModelService. @@ -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 @@ -268,7 +353,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.ai.generativelanguage.v1.ModelService/GetModel", request_serializer=model_service.GetModelRequest.serialize, response_deserializer=model.Model.deserialize, @@ -298,7 +383,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.ai.generativelanguage.v1.ModelService/ListModels", request_serializer=model_service.ListModelsRequest.serialize, response_deserializer=model_service.ListModelsResponse.deserialize, @@ -341,7 +426,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: @@ -357,7 +442,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, @@ -374,7 +459,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, @@ -393,7 +478,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-ai-generativelanguage/google/ai/generativelanguage_v1/services/model_service/transports/rest.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/model_service/transports/rest.py index 3462b9835d7b..99e1125ccde2 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/model_service/transports/rest.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1/services/model_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = logging.getLogger(__name__) DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, @@ -86,8 +94,8 @@ def post_list_models(self, response): def pre_get_model( self, request: model_service.GetModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.GetModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[model_service.GetModelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_model Override in a subclass to manipulate the request or metadata @@ -107,8 +115,10 @@ def post_get_model(self, response: model.Model) -> model.Model: def pre_list_models( self, request: model_service.ListModelsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.ListModelsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + model_service.ListModelsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_models Override in a subclass to manipulate the request or metadata @@ -130,8 +140,10 @@ def post_list_models( 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 @@ -151,8 +163,10 @@ def post_cancel_operation(self, response: None) -> None: def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -174,8 +188,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 @@ -314,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]]] = (), ) -> model.Model: r"""Call the get model method over HTTP. @@ -325,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: ~.model.Model: @@ -338,6 +356,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseGetModel._get_http_options() ) + request, metadata = self._interceptor.pre_get_model(request, metadata) transcoded_request = ( _BaseModelServiceRestTransport._BaseGetModel._get_transcoded_request( @@ -352,6 +371,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1.ModelServiceClient.GetModel", + extra={ + "serviceName": "google.ai.generativelanguage.v1.ModelService", + "rpcName": "GetModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._GetModel._get_response( self._host, @@ -372,7 +418,29 @@ def __call__( pb_resp = model.Model.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_model(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = model.Model.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1.ModelServiceClient.get_model", + extra={ + "serviceName": "google.ai.generativelanguage.v1.ModelService", + "rpcName": "GetModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListModels( @@ -409,7 +477,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model_service.ListModelsResponse: r"""Call the list models method over HTTP. @@ -419,8 +487,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.model_service.ListModelsResponse: @@ -432,6 +502,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseListModels._get_http_options() ) + request, metadata = self._interceptor.pre_list_models(request, metadata) transcoded_request = ( _BaseModelServiceRestTransport._BaseListModels._get_transcoded_request( @@ -446,6 +517,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1.ModelServiceClient.ListModels", + extra={ + "serviceName": "google.ai.generativelanguage.v1.ModelService", + "rpcName": "ListModels", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._ListModels._get_response( self._host, @@ -466,7 +564,31 @@ def __call__( pb_resp = model_service.ListModelsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_models(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = model_service.ListModelsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1.ModelServiceClient.list_models", + extra={ + "serviceName": "google.ai.generativelanguage.v1.ModelService", + "rpcName": "ListModels", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -522,7 +644,7 @@ 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. @@ -532,13 +654,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 = ( _BaseModelServiceRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -555,6 +680,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1.ModelServiceClient.CancelOperation", + extra={ + "serviceName": "google.ai.generativelanguage.v1.ModelService", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._CancelOperation._get_response( self._host, @@ -611,7 +763,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -621,8 +773,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -631,6 +785,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseModelServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -643,6 +798,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1.ModelServiceClient.GetOperation", + extra={ + "serviceName": "google.ai.generativelanguage.v1.ModelService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._GetOperation._get_response( self._host, @@ -662,6 +844,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.ai.generativelanguage_v1.ModelServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.ai.generativelanguage.v1.ModelService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -702,7 +905,7 @@ def __call__( *, 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. @@ -712,8 +915,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -722,6 +927,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseModelServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -732,6 +938,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1.ModelServiceClient.ListOperations", + extra={ + "serviceName": "google.ai.generativelanguage.v1.ModelService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._ListOperations._get_response( self._host, @@ -751,6 +984,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.ai.generativelanguage_v1.ModelServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.ai.generativelanguage.v1.ModelService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/gapic_version.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/gapic_version.py index b72badcc1eca..558c8aab67c5 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/gapic_version.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.6.13" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/cache_service/async_client.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/cache_service/async_client.py index dad22c2c26ad..2401a2613eea 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/cache_service/async_client.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/cache_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -59,6 +60,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, CacheServiceTransport from .transports.grpc_asyncio import CacheServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class CacheServiceAsyncClient: """API for managing cache of content (CachedContent resources) @@ -269,13 +279,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.ai.generativelanguage_v1beta.CacheServiceAsyncClient`.", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.CacheService", + "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.ai.generativelanguage.v1beta.CacheService", + "credentialsType": None, + }, + ) + async def list_cached_contents( self, request: Optional[Union[cache_service.ListCachedContentsRequest, 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]]] = (), ) -> pagers.ListCachedContentsAsyncPager: r"""Lists CachedContents. @@ -311,8 +343,10 @@ async def sample_list_cached_contents(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.services.cache_service.pagers.ListCachedContentsAsyncPager: @@ -367,7 +401,7 @@ async def create_cached_content( cached_content: Optional[gag_cached_content.CachedContent] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gag_cached_content.CachedContent: r"""Creates CachedContent resource. @@ -409,8 +443,10 @@ async def sample_create_cached_content(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.CachedContent: @@ -469,7 +505,7 @@ async def get_cached_content( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cached_content.CachedContent: r"""Reads CachedContent resource. @@ -512,8 +548,10 @@ async def sample_get_cached_content(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.CachedContent: @@ -579,7 +617,7 @@ async def update_cached_content( 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]]] = (), ) -> gag_cached_content.CachedContent: r"""Updates CachedContent resource (only expiration is updatable). @@ -627,8 +665,10 @@ async def sample_update_cached_content(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.CachedContent: @@ -697,7 +737,7 @@ async def delete_cached_content( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 CachedContent resource. @@ -737,8 +777,10 @@ async def sample_delete_cached_content(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -789,7 +831,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. @@ -800,8 +842,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. @@ -842,7 +886,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. @@ -853,8 +897,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-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/cache_service/client.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/cache_service/client.py index d588f8ce2220..86d3bd0e8ad7 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/cache_service/client.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/cache_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.longrunning import operations_pb2 # type: ignore from google.protobuf import duration_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -599,6 +609,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( @@ -661,13 +675,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.ai.generativelanguage_v1beta.CacheServiceClient`.", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.CacheService", + "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.ai.generativelanguage.v1beta.CacheService", + "credentialsType": None, + }, + ) + def list_cached_contents( self, request: Optional[Union[cache_service.ListCachedContentsRequest, 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]]] = (), ) -> pagers.ListCachedContentsPager: r"""Lists CachedContents. @@ -703,8 +740,10 @@ def sample_list_cached_contents(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.services.cache_service.pagers.ListCachedContentsPager: @@ -757,7 +796,7 @@ def create_cached_content( cached_content: Optional[gag_cached_content.CachedContent] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gag_cached_content.CachedContent: r"""Creates CachedContent resource. @@ -799,8 +838,10 @@ def sample_create_cached_content(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.CachedContent: @@ -856,7 +897,7 @@ def get_cached_content( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cached_content.CachedContent: r"""Reads CachedContent resource. @@ -899,8 +940,10 @@ def sample_get_cached_content(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.CachedContent: @@ -963,7 +1006,7 @@ def update_cached_content( 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]]] = (), ) -> gag_cached_content.CachedContent: r"""Updates CachedContent resource (only expiration is updatable). @@ -1011,8 +1054,10 @@ def sample_update_cached_content(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.CachedContent: @@ -1078,7 +1123,7 @@ def delete_cached_content( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 CachedContent resource. @@ -1118,8 +1163,10 @@ def sample_delete_cached_content(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1180,7 +1227,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. @@ -1191,8 +1238,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. @@ -1233,7 +1282,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. @@ -1244,8 +1293,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-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/cache_service/pagers.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/cache_service/pagers.py index 5d57df24ad77..e60b16590f07 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/cache_service/pagers.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/cache_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 = cache_service.ListCachedContentsRequest(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 = cache_service.ListCachedContentsRequest(request) diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/cache_service/transports/grpc.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/cache_service/transports/grpc.py index ff201c5735c3..899697ec1160 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/cache_service/transports/grpc.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/cache_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,7 +25,10 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.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.ai.generativelanguage_v1beta.types import ( cached_content as gag_cached_content, @@ -32,6 +38,81 @@ from .base import DEFAULT_CLIENT_INFO, CacheServiceTransport +try: + from google.api_core import client_logging # 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.ai.generativelanguage.v1beta.CacheService", + "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.ai.generativelanguage.v1beta.CacheService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CacheServiceGrpcTransport(CacheServiceTransport): """gRPC backend transport for CacheService. @@ -189,7 +270,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientInterceptor() + self._logged_channel = grpc.intercept_channel( + self._grpc_channel, self._interceptor + ) + + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @classmethod @@ -266,7 +352,7 @@ def list_cached_contents( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_cached_contents" not in self._stubs: - self._stubs["list_cached_contents"] = self.grpc_channel.unary_unary( + self._stubs["list_cached_contents"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.CacheService/ListCachedContents", request_serializer=cache_service.ListCachedContentsRequest.serialize, response_deserializer=cache_service.ListCachedContentsResponse.deserialize, @@ -294,7 +380,7 @@ def create_cached_content( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_cached_content" not in self._stubs: - self._stubs["create_cached_content"] = self.grpc_channel.unary_unary( + self._stubs["create_cached_content"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.CacheService/CreateCachedContent", request_serializer=cache_service.CreateCachedContentRequest.serialize, response_deserializer=gag_cached_content.CachedContent.deserialize, @@ -322,7 +408,7 @@ def get_cached_content( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_cached_content" not in self._stubs: - self._stubs["get_cached_content"] = self.grpc_channel.unary_unary( + self._stubs["get_cached_content"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.CacheService/GetCachedContent", request_serializer=cache_service.GetCachedContentRequest.serialize, response_deserializer=cached_content.CachedContent.deserialize, @@ -351,7 +437,7 @@ def update_cached_content( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_cached_content" not in self._stubs: - self._stubs["update_cached_content"] = self.grpc_channel.unary_unary( + self._stubs["update_cached_content"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.CacheService/UpdateCachedContent", request_serializer=cache_service.UpdateCachedContentRequest.serialize, response_deserializer=gag_cached_content.CachedContent.deserialize, @@ -377,7 +463,7 @@ def delete_cached_content( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_cached_content" not in self._stubs: - self._stubs["delete_cached_content"] = self.grpc_channel.unary_unary( + self._stubs["delete_cached_content"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.CacheService/DeleteCachedContent", request_serializer=cache_service.DeleteCachedContentRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -385,7 +471,7 @@ def delete_cached_content( return self._stubs["delete_cached_content"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -397,7 +483,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, @@ -416,7 +502,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-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/cache_service/transports/grpc_asyncio.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/cache_service/transports/grpc_asyncio.py index 6fe64da28cb8..8fd03abc010a 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/cache_service/transports/grpc_asyncio.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/cache_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.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.ai.generativelanguage_v1beta.types import ( cached_content as gag_cached_content, @@ -36,6 +42,82 @@ from .base import DEFAULT_CLIENT_INFO, CacheServiceTransport from .grpc import CacheServiceGrpcTransport +try: + from google.api_core import client_logging # 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.ai.generativelanguage.v1beta.CacheService", + "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.ai.generativelanguage.v1beta.CacheService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CacheServiceGrpcAsyncIOTransport(CacheServiceTransport): """gRPC AsyncIO backend transport for CacheService. @@ -236,10 +318,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientAIOInterceptor() + self._grpc_channel._unary_unary_interceptors.append(self._interceptor) + self._logged_channel = self._grpc_channel self._wrap_with_kind = ( "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters ) + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @property @@ -274,7 +359,7 @@ def list_cached_contents( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_cached_contents" not in self._stubs: - self._stubs["list_cached_contents"] = self.grpc_channel.unary_unary( + self._stubs["list_cached_contents"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.CacheService/ListCachedContents", request_serializer=cache_service.ListCachedContentsRequest.serialize, response_deserializer=cache_service.ListCachedContentsResponse.deserialize, @@ -303,7 +388,7 @@ def create_cached_content( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_cached_content" not in self._stubs: - self._stubs["create_cached_content"] = self.grpc_channel.unary_unary( + self._stubs["create_cached_content"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.CacheService/CreateCachedContent", request_serializer=cache_service.CreateCachedContentRequest.serialize, response_deserializer=gag_cached_content.CachedContent.deserialize, @@ -331,7 +416,7 @@ def get_cached_content( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_cached_content" not in self._stubs: - self._stubs["get_cached_content"] = self.grpc_channel.unary_unary( + self._stubs["get_cached_content"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.CacheService/GetCachedContent", request_serializer=cache_service.GetCachedContentRequest.serialize, response_deserializer=cached_content.CachedContent.deserialize, @@ -361,7 +446,7 @@ def update_cached_content( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_cached_content" not in self._stubs: - self._stubs["update_cached_content"] = self.grpc_channel.unary_unary( + self._stubs["update_cached_content"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.CacheService/UpdateCachedContent", request_serializer=cache_service.UpdateCachedContentRequest.serialize, response_deserializer=gag_cached_content.CachedContent.deserialize, @@ -389,7 +474,7 @@ def delete_cached_content( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_cached_content" not in self._stubs: - self._stubs["delete_cached_content"] = self.grpc_channel.unary_unary( + self._stubs["delete_cached_content"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.CacheService/DeleteCachedContent", request_serializer=cache_service.DeleteCachedContentRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -442,7 +527,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: @@ -458,7 +543,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, @@ -477,7 +562,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-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/cache_service/transports/rest.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/cache_service/transports/rest.py index 4168d2dbffc0..965f16b2493e 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/cache_service/transports/rest.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/cache_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 @@ -43,6 +43,14 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = logging.getLogger(__name__) DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, @@ -111,8 +119,11 @@ def post_update_cached_content(self, response): def pre_create_cached_content( self, request: cache_service.CreateCachedContentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cache_service.CreateCachedContentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cache_service.CreateCachedContentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_cached_content Override in a subclass to manipulate the request or metadata @@ -134,8 +145,11 @@ def post_create_cached_content( def pre_delete_cached_content( self, request: cache_service.DeleteCachedContentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cache_service.DeleteCachedContentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cache_service.DeleteCachedContentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_cached_content Override in a subclass to manipulate the request or metadata @@ -146,8 +160,10 @@ def pre_delete_cached_content( def pre_get_cached_content( self, request: cache_service.GetCachedContentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cache_service.GetCachedContentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cache_service.GetCachedContentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_cached_content Override in a subclass to manipulate the request or metadata @@ -169,8 +185,10 @@ def post_get_cached_content( def pre_list_cached_contents( self, request: cache_service.ListCachedContentsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cache_service.ListCachedContentsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cache_service.ListCachedContentsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_cached_contents Override in a subclass to manipulate the request or metadata @@ -192,8 +210,11 @@ def post_list_cached_contents( def pre_update_cached_content( self, request: cache_service.UpdateCachedContentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cache_service.UpdateCachedContentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cache_service.UpdateCachedContentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_cached_content Override in a subclass to manipulate the request or metadata @@ -215,8 +236,10 @@ def post_update_cached_content( 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 @@ -238,8 +261,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 @@ -384,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]]] = (), ) -> gag_cached_content.CachedContent: r"""Call the create cached content method over HTTP. @@ -394,8 +419,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gag_cached_content.CachedContent: @@ -411,6 +438,7 @@ def __call__( http_options = ( _BaseCacheServiceRestTransport._BaseCreateCachedContent._get_http_options() ) + request, metadata = self._interceptor.pre_create_cached_content( request, metadata ) @@ -427,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 = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.CacheServiceClient.CreateCachedContent", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.CacheService", + "rpcName": "CreateCachedContent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CacheServiceRestTransport._CreateCachedContent._get_response( self._host, @@ -448,7 +503,31 @@ def __call__( pb_resp = gag_cached_content.CachedContent.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_cached_content(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gag_cached_content.CachedContent.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.CacheServiceClient.create_cached_content", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.CacheService", + "rpcName": "CreateCachedContent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteCachedContent( @@ -485,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]]] = (), ): r"""Call the delete cached content method over HTTP. @@ -495,13 +574,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 = ( _BaseCacheServiceRestTransport._BaseDeleteCachedContent._get_http_options() ) + request, metadata = self._interceptor.pre_delete_cached_content( request, metadata ) @@ -514,6 +596,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.CacheServiceClient.DeleteCachedContent", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.CacheService", + "rpcName": "DeleteCachedContent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CacheServiceRestTransport._DeleteCachedContent._get_response( self._host, @@ -563,7 +672,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cached_content.CachedContent: r"""Call the get cached content method over HTTP. @@ -573,8 +682,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.cached_content.CachedContent: @@ -590,6 +701,7 @@ def __call__( http_options = ( _BaseCacheServiceRestTransport._BaseGetCachedContent._get_http_options() ) + request, metadata = self._interceptor.pre_get_cached_content( request, metadata ) @@ -602,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.ai.generativelanguage_v1beta.CacheServiceClient.GetCachedContent", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.CacheService", + "rpcName": "GetCachedContent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CacheServiceRestTransport._GetCachedContent._get_response( self._host, @@ -622,7 +761,29 @@ def __call__( pb_resp = cached_content.CachedContent.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_cached_content(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cached_content.CachedContent.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.CacheServiceClient.get_cached_content", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.CacheService", + "rpcName": "GetCachedContent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCachedContents( @@ -659,7 +820,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cache_service.ListCachedContentsResponse: r"""Call the list cached contents method over HTTP. @@ -669,8 +830,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.cache_service.ListCachedContentsResponse: @@ -680,6 +843,7 @@ def __call__( http_options = ( _BaseCacheServiceRestTransport._BaseListCachedContents._get_http_options() ) + request, metadata = self._interceptor.pre_list_cached_contents( request, metadata ) @@ -692,6 +856,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.CacheServiceClient.ListCachedContents", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.CacheService", + "rpcName": "ListCachedContents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CacheServiceRestTransport._ListCachedContents._get_response( self._host, @@ -712,7 +903,31 @@ def __call__( pb_resp = cache_service.ListCachedContentsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_cached_contents(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cache_service.ListCachedContentsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.CacheServiceClient.list_cached_contents", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.CacheService", + "rpcName": "ListCachedContents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCachedContent( @@ -750,7 +965,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gag_cached_content.CachedContent: r"""Call the update cached content method over HTTP. @@ -760,8 +975,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gag_cached_content.CachedContent: @@ -777,6 +994,7 @@ def __call__( http_options = ( _BaseCacheServiceRestTransport._BaseUpdateCachedContent._get_http_options() ) + request, metadata = self._interceptor.pre_update_cached_content( request, metadata ) @@ -793,6 +1011,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.CacheServiceClient.UpdateCachedContent", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.CacheService", + "rpcName": "UpdateCachedContent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CacheServiceRestTransport._UpdateCachedContent._get_response( self._host, @@ -814,7 +1059,31 @@ def __call__( pb_resp = gag_cached_content.CachedContent.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_cached_content(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gag_cached_content.CachedContent.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.CacheServiceClient.update_cached_content", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.CacheService", + "rpcName": "UpdateCachedContent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -904,7 +1173,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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. @@ -914,8 +1183,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: operations_pb2.Operation: Response from GetOperation method. @@ -924,6 +1195,7 @@ def __call__( http_options = ( _BaseCacheServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseCacheServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -936,6 +1208,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.CacheServiceClient.GetOperation", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.CacheService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CacheServiceRestTransport._GetOperation._get_response( self._host, @@ -955,6 +1254,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.ai.generativelanguage_v1beta.CacheServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.CacheService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -995,7 +1315,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1005,8 +1325,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1015,6 +1337,7 @@ def __call__( http_options = ( _BaseCacheServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseCacheServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1025,6 +1348,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.CacheServiceClient.ListOperations", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.CacheService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CacheServiceRestTransport._ListOperations._get_response( self._host, @@ -1044,6 +1394,27 @@ def __call__( resp = operations_pb2.ListOperationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_operations(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.CacheServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.CacheService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/discuss_service/async_client.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/discuss_service/async_client.py index f1dc33d1d495..afcf2f9ab0a3 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/discuss_service/async_client.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/discuss_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, @@ -50,6 +51,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, DiscussServiceTransport from .transports.grpc_asyncio import DiscussServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class DiscussServiceAsyncClient: """An API for using Generative Language Models (GLMs) in dialog @@ -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.ai.generativelanguage_v1beta.DiscussServiceAsyncClient`.", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.DiscussService", + "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.ai.generativelanguage.v1beta.DiscussService", + "credentialsType": None, + }, + ) + async def generate_message( self, request: Optional[Union[discuss_service.GenerateMessageRequest, dict]] = None, @@ -271,7 +303,7 @@ async def generate_message( top_k: Optional[int] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> discuss_service.GenerateMessageResponse: r"""Generates a response from the model given an input ``MessagePrompt``. @@ -377,8 +409,10 @@ async def sample_generate_message(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.GenerateMessageResponse: @@ -457,7 +491,7 @@ async def count_message_tokens( prompt: Optional[discuss_service.MessagePrompt] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> discuss_service.CountMessageTokensResponse: r"""Runs a model's tokenizer on a string and returns the token count. @@ -521,8 +555,10 @@ async def sample_count_message_tokens(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.CountMessageTokensResponse: @@ -585,7 +621,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. @@ -596,8 +632,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. @@ -638,7 +676,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. @@ -649,8 +687,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-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/discuss_service/client.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/discuss_service/client.py index 94aa35118ef5..5d236e1acefe 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/discuss_service/client.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/discuss_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.longrunning import operations_pb2 # type: ignore from google.ai.generativelanguage_v1beta.types import discuss_service, safety @@ -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( @@ -641,6 +655,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.ai.generativelanguage_v1beta.DiscussServiceClient`.", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.DiscussService", + "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.ai.generativelanguage.v1beta.DiscussService", + "credentialsType": None, + }, + ) + def generate_message( self, request: Optional[Union[discuss_service.GenerateMessageRequest, dict]] = None, @@ -653,7 +690,7 @@ def generate_message( top_k: Optional[int] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> discuss_service.GenerateMessageResponse: r"""Generates a response from the model given an input ``MessagePrompt``. @@ -759,8 +796,10 @@ def sample_generate_message(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.GenerateMessageResponse: @@ -836,7 +875,7 @@ def count_message_tokens( prompt: Optional[discuss_service.MessagePrompt] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> discuss_service.CountMessageTokensResponse: r"""Runs a model's tokenizer on a string and returns the token count. @@ -900,8 +939,10 @@ def sample_count_message_tokens(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.CountMessageTokensResponse: @@ -974,7 +1015,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. @@ -985,8 +1026,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. @@ -1027,7 +1070,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. @@ -1038,8 +1081,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-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/discuss_service/transports/grpc.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/discuss_service/transports/grpc.py index d457d47ffc24..273f4d5496f5 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/discuss_service/transports/grpc.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/discuss_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.ai.generativelanguage_v1beta.types import discuss_service from .base import DEFAULT_CLIENT_INFO, DiscussServiceTransport +try: + from google.api_core import client_logging # 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.ai.generativelanguage.v1beta.DiscussService", + "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.ai.generativelanguage.v1beta.DiscussService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class DiscussServiceGrpcTransport(DiscussServiceTransport): """gRPC backend transport for DiscussService. @@ -183,7 +264,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientInterceptor() + self._logged_channel = grpc.intercept_channel( + self._grpc_channel, self._interceptor + ) + + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @classmethod @@ -261,7 +347,7 @@ def generate_message( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_message" not in self._stubs: - self._stubs["generate_message"] = self.grpc_channel.unary_unary( + self._stubs["generate_message"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.DiscussService/GenerateMessage", request_serializer=discuss_service.GenerateMessageRequest.serialize, response_deserializer=discuss_service.GenerateMessageResponse.deserialize, @@ -291,7 +377,7 @@ def count_message_tokens( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "count_message_tokens" not in self._stubs: - self._stubs["count_message_tokens"] = self.grpc_channel.unary_unary( + self._stubs["count_message_tokens"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.DiscussService/CountMessageTokens", request_serializer=discuss_service.CountMessageTokensRequest.serialize, response_deserializer=discuss_service.CountMessageTokensResponse.deserialize, @@ -299,7 +385,7 @@ def count_message_tokens( return self._stubs["count_message_tokens"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -311,7 +397,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, @@ -330,7 +416,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-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/discuss_service/transports/grpc_asyncio.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/discuss_service/transports/grpc_asyncio.py index aa5a77891215..66efa070c923 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/discuss_service/transports/grpc_asyncio.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/discuss_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.ai.generativelanguage_v1beta.types import discuss_service from .base import DEFAULT_CLIENT_INFO, DiscussServiceTransport from .grpc import DiscussServiceGrpcTransport +try: + from google.api_core import client_logging # 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.ai.generativelanguage.v1beta.DiscussService", + "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.ai.generativelanguage.v1beta.DiscussService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class DiscussServiceGrpcAsyncIOTransport(DiscussServiceTransport): """gRPC AsyncIO backend transport for DiscussService. @@ -230,10 +312,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientAIOInterceptor() + self._grpc_channel._unary_unary_interceptors.append(self._interceptor) + self._logged_channel = self._grpc_channel self._wrap_with_kind = ( "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters ) + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @property @@ -269,7 +354,7 @@ def generate_message( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_message" not in self._stubs: - self._stubs["generate_message"] = self.grpc_channel.unary_unary( + self._stubs["generate_message"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.DiscussService/GenerateMessage", request_serializer=discuss_service.GenerateMessageRequest.serialize, response_deserializer=discuss_service.GenerateMessageResponse.deserialize, @@ -299,7 +384,7 @@ def count_message_tokens( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "count_message_tokens" not in self._stubs: - self._stubs["count_message_tokens"] = self.grpc_channel.unary_unary( + self._stubs["count_message_tokens"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.DiscussService/CountMessageTokens", request_serializer=discuss_service.CountMessageTokensRequest.serialize, response_deserializer=discuss_service.CountMessageTokensResponse.deserialize, @@ -355,7 +440,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: @@ -371,7 +456,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, @@ -390,7 +475,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-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/discuss_service/transports/rest.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/discuss_service/transports/rest.py index 3a1950832cfa..80a1cc50d0fc 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/discuss_service/transports/rest.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/discuss_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = logging.getLogger(__name__) DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, @@ -86,8 +94,11 @@ def post_generate_message(self, response): def pre_count_message_tokens( self, request: discuss_service.CountMessageTokensRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[discuss_service.CountMessageTokensRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + discuss_service.CountMessageTokensRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for count_message_tokens Override in a subclass to manipulate the request or metadata @@ -109,8 +120,10 @@ def post_count_message_tokens( def pre_generate_message( self, request: discuss_service.GenerateMessageRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[discuss_service.GenerateMessageRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + discuss_service.GenerateMessageRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for generate_message Override in a subclass to manipulate the request or metadata @@ -132,8 +145,10 @@ def post_generate_message( 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 @@ -155,8 +170,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 @@ -300,7 +317,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> discuss_service.CountMessageTokensResponse: r"""Call the count message tokens method over HTTP. @@ -314,8 +331,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.discuss_service.CountMessageTokensResponse: @@ -329,6 +348,7 @@ def __call__( http_options = ( _BaseDiscussServiceRestTransport._BaseCountMessageTokens._get_http_options() ) + request, metadata = self._interceptor.pre_count_message_tokens( request, metadata ) @@ -345,6 +365,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.DiscussServiceClient.CountMessageTokens", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.DiscussService", + "rpcName": "CountMessageTokens", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DiscussServiceRestTransport._CountMessageTokens._get_response( self._host, @@ -366,7 +413,31 @@ def __call__( pb_resp = discuss_service.CountMessageTokensResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_count_message_tokens(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + discuss_service.CountMessageTokensResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.DiscussServiceClient.count_message_tokens", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.DiscussService", + "rpcName": "CountMessageTokens", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GenerateMessage( @@ -404,7 +475,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> discuss_service.GenerateMessageResponse: r"""Call the generate message method over HTTP. @@ -415,8 +486,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.discuss_service.GenerateMessageResponse: @@ -431,6 +504,7 @@ def __call__( http_options = ( _BaseDiscussServiceRestTransport._BaseGenerateMessage._get_http_options() ) + request, metadata = self._interceptor.pre_generate_message( request, metadata ) @@ -447,6 +521,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.DiscussServiceClient.GenerateMessage", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.DiscussService", + "rpcName": "GenerateMessage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DiscussServiceRestTransport._GenerateMessage._get_response( self._host, @@ -468,7 +569,31 @@ def __call__( pb_resp = discuss_service.GenerateMessageResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_generate_message(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = discuss_service.GenerateMessageResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.DiscussServiceClient.generate_message", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.DiscussService", + "rpcName": "GenerateMessage", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -531,7 +656,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -541,8 +666,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: operations_pb2.Operation: Response from GetOperation method. @@ -551,6 +678,7 @@ def __call__( http_options = ( _BaseDiscussServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseDiscussServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -561,6 +689,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.DiscussServiceClient.GetOperation", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.DiscussService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DiscussServiceRestTransport._GetOperation._get_response( self._host, @@ -580,6 +735,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.ai.generativelanguage_v1beta.DiscussServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.DiscussService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -620,7 +796,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -630,8 +806,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must 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. @@ -640,6 +818,7 @@ def __call__( http_options = ( _BaseDiscussServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseDiscussServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -650,6 +829,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.DiscussServiceClient.ListOperations", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.DiscussService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DiscussServiceRestTransport._ListOperations._get_response( self._host, @@ -669,6 +875,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.ai.generativelanguage_v1beta.DiscussServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.DiscussService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/file_service/async_client.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/file_service/async_client.py index 83d2865cebce..cc4d74a856c1 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/file_service/async_client.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/file_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, FileServiceTransport from .transports.grpc_asyncio import FileServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class FileServiceAsyncClient: """An API for uploading and managing files.""" @@ -254,13 +264,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.ai.generativelanguage_v1beta.FileServiceAsyncClient`.", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.FileService", + "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.ai.generativelanguage.v1beta.FileService", + "credentialsType": None, + }, + ) + async def create_file( self, request: Optional[Union[file_service.CreateFileRequest, 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]]] = (), ) -> file_service.CreateFileResponse: r"""Creates a ``File``. @@ -295,8 +327,10 @@ async def sample_create_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.ai.generativelanguage_v1beta.types.CreateFileResponse: @@ -334,7 +368,7 @@ async def list_files( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListFilesAsyncPager: r"""Lists the metadata for ``File``\ s owned by the requesting project. @@ -371,8 +405,10 @@ async def sample_list_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.ai.generativelanguage_v1beta.services.file_service.pagers.ListFilesAsyncPager: @@ -426,7 +462,7 @@ async def get_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]]] = (), ) -> file.File: r"""Gets the metadata for the given ``File``. @@ -469,8 +505,10 @@ async def sample_get_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.ai.generativelanguage_v1beta.types.File: @@ -527,7 +565,7 @@ async def delete_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 the ``File``. @@ -567,8 +605,10 @@ async def sample_delete_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 @@ -619,7 +659,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. @@ -630,8 +670,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. @@ -672,7 +714,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. @@ -683,8 +725,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-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/file_service/client.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/file_service/client.py index 4f9bf6455796..3de779357670 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/file_service/client.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/file_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.longrunning import operations_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore from google.rpc import status_pb2 # type: ignore @@ -573,6 +583,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -635,13 +649,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.ai.generativelanguage_v1beta.FileServiceClient`.", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.FileService", + "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.ai.generativelanguage.v1beta.FileService", + "credentialsType": None, + }, + ) + def create_file( self, request: Optional[Union[file_service.CreateFileRequest, 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]]] = (), ) -> file_service.CreateFileResponse: r"""Creates a ``File``. @@ -676,8 +713,10 @@ def sample_create_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.ai.generativelanguage_v1beta.types.CreateFileResponse: @@ -713,7 +752,7 @@ def list_files( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListFilesPager: r"""Lists the metadata for ``File``\ s owned by the requesting project. @@ -750,8 +789,10 @@ def sample_list_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.ai.generativelanguage_v1beta.services.file_service.pagers.ListFilesPager: @@ -803,7 +844,7 @@ def get_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]]] = (), ) -> file.File: r"""Gets the metadata for the given ``File``. @@ -846,8 +887,10 @@ def sample_get_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.ai.generativelanguage_v1beta.types.File: @@ -903,7 +946,7 @@ def delete_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 the ``File``. @@ -943,8 +986,10 @@ def sample_delete_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 @@ -1005,7 +1050,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. @@ -1016,8 +1061,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. @@ -1058,7 +1105,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. @@ -1069,8 +1116,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-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/file_service/pagers.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/file_service/pagers.py index 6ca92bc6b18d..683b8d88086a 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/file_service/pagers.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/file_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 = file_service.ListFilesRequest(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 = file_service.ListFilesRequest(request) diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/file_service/transports/grpc.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/file_service/transports/grpc.py index 9294b89e861f..de6799449ab8 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/file_service/transports/grpc.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/file_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.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.ai.generativelanguage_v1beta.types import file, file_service from .base import DEFAULT_CLIENT_INFO, FileServiceTransport +try: + from google.api_core import client_logging # 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.ai.generativelanguage.v1beta.FileService", + "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.ai.generativelanguage.v1beta.FileService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class FileServiceGrpcTransport(FileServiceTransport): """gRPC backend transport for FileService. @@ -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 @@ -255,7 +341,7 @@ def create_file( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_file" not in self._stubs: - self._stubs["create_file"] = self.grpc_channel.unary_unary( + self._stubs["create_file"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.FileService/CreateFile", request_serializer=file_service.CreateFileRequest.serialize, response_deserializer=file_service.CreateFileResponse.deserialize, @@ -282,7 +368,7 @@ def list_files( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_files" not in self._stubs: - self._stubs["list_files"] = self.grpc_channel.unary_unary( + self._stubs["list_files"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.FileService/ListFiles", request_serializer=file_service.ListFilesRequest.serialize, response_deserializer=file_service.ListFilesResponse.deserialize, @@ -306,7 +392,7 @@ def get_file(self) -> Callable[[file_service.GetFileRequest], file.File]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_file" not in self._stubs: - self._stubs["get_file"] = self.grpc_channel.unary_unary( + self._stubs["get_file"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.FileService/GetFile", request_serializer=file_service.GetFileRequest.serialize, response_deserializer=file.File.deserialize, @@ -332,7 +418,7 @@ def delete_file( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_file" not in self._stubs: - self._stubs["delete_file"] = self.grpc_channel.unary_unary( + self._stubs["delete_file"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.FileService/DeleteFile", request_serializer=file_service.DeleteFileRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -340,7 +426,7 @@ def delete_file( return self._stubs["delete_file"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -352,7 +438,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, @@ -371,7 +457,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-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/file_service/transports/grpc_asyncio.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/file_service/transports/grpc_asyncio.py index 5d21dc7de23f..0af05beb7459 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/file_service/transports/grpc_asyncio.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/file_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.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.ai.generativelanguage_v1beta.types import file, file_service from .base import DEFAULT_CLIENT_INFO, FileServiceTransport from .grpc import FileServiceGrpcTransport +try: + from google.api_core import client_logging # 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.ai.generativelanguage.v1beta.FileService", + "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.ai.generativelanguage.v1beta.FileService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class FileServiceGrpcAsyncIOTransport(FileServiceTransport): """gRPC AsyncIO backend transport for FileService. @@ -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 @@ -265,7 +350,7 @@ def create_file( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_file" not in self._stubs: - self._stubs["create_file"] = self.grpc_channel.unary_unary( + self._stubs["create_file"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.FileService/CreateFile", request_serializer=file_service.CreateFileRequest.serialize, response_deserializer=file_service.CreateFileResponse.deserialize, @@ -294,7 +379,7 @@ def list_files( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_files" not in self._stubs: - self._stubs["list_files"] = self.grpc_channel.unary_unary( + self._stubs["list_files"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.FileService/ListFiles", request_serializer=file_service.ListFilesRequest.serialize, response_deserializer=file_service.ListFilesResponse.deserialize, @@ -318,7 +403,7 @@ def get_file(self) -> Callable[[file_service.GetFileRequest], Awaitable[file.Fil # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_file" not in self._stubs: - self._stubs["get_file"] = self.grpc_channel.unary_unary( + self._stubs["get_file"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.FileService/GetFile", request_serializer=file_service.GetFileRequest.serialize, response_deserializer=file.File.deserialize, @@ -344,7 +429,7 @@ def delete_file( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_file" not in self._stubs: - self._stubs["delete_file"] = self.grpc_channel.unary_unary( + self._stubs["delete_file"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.FileService/DeleteFile", request_serializer=file_service.DeleteFileRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -392,7 +477,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: @@ -408,7 +493,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -427,7 +512,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/file_service/transports/rest.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/file_service/transports/rest.py index b3be03bda2ce..ab839007a690 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/file_service/transports/rest.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/file_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, @@ -99,8 +107,8 @@ def post_list_files(self, response): def pre_create_file( self, request: file_service.CreateFileRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[file_service.CreateFileRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[file_service.CreateFileRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_file Override in a subclass to manipulate the request or metadata @@ -122,8 +130,8 @@ def post_create_file( def pre_delete_file( self, request: file_service.DeleteFileRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[file_service.DeleteFileRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[file_service.DeleteFileRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_file Override in a subclass to manipulate the request or metadata @@ -132,8 +140,10 @@ def pre_delete_file( return request, metadata def pre_get_file( - self, request: file_service.GetFileRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[file_service.GetFileRequest, Sequence[Tuple[str, str]]]: + self, + request: file_service.GetFileRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[file_service.GetFileRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_file Override in a subclass to manipulate the request or metadata @@ -153,8 +163,8 @@ def post_get_file(self, response: file.File) -> file.File: def pre_list_files( self, request: file_service.ListFilesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[file_service.ListFilesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[file_service.ListFilesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_files Override in a subclass to manipulate the request or metadata @@ -176,8 +186,10 @@ def post_list_files( 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 @@ -199,8 +211,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -341,7 +355,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> file_service.CreateFileResponse: r"""Call the create file method over HTTP. @@ -351,8 +365,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.file_service.CreateFileResponse: @@ -362,6 +378,7 @@ def __call__( http_options = ( _BaseFileServiceRestTransport._BaseCreateFile._get_http_options() ) + request, metadata = self._interceptor.pre_create_file(request, metadata) transcoded_request = ( _BaseFileServiceRestTransport._BaseCreateFile._get_transcoded_request( @@ -380,6 +397,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.FileServiceClient.CreateFile", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.FileService", + "rpcName": "CreateFile", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FileServiceRestTransport._CreateFile._get_response( self._host, @@ -401,7 +445,29 @@ def __call__( pb_resp = file_service.CreateFileResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_file(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = file_service.CreateFileResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.FileServiceClient.create_file", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.FileService", + "rpcName": "CreateFile", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteFile( @@ -438,7 +504,7 @@ 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 file method over HTTP. @@ -448,13 +514,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 = ( _BaseFileServiceRestTransport._BaseDeleteFile._get_http_options() ) + request, metadata = self._interceptor.pre_delete_file(request, metadata) transcoded_request = ( _BaseFileServiceRestTransport._BaseDeleteFile._get_transcoded_request( @@ -469,6 +538,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.FileServiceClient.DeleteFile", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.FileService", + "rpcName": "DeleteFile", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FileServiceRestTransport._DeleteFile._get_response( self._host, @@ -516,7 +612,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> file.File: r"""Call the get file method over HTTP. @@ -526,8 +622,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.file.File: @@ -537,6 +635,7 @@ def __call__( http_options = ( _BaseFileServiceRestTransport._BaseGetFile._get_http_options() ) + request, metadata = self._interceptor.pre_get_file(request, metadata) transcoded_request = ( _BaseFileServiceRestTransport._BaseGetFile._get_transcoded_request( @@ -551,6 +650,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.FileServiceClient.GetFile", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.FileService", + "rpcName": "GetFile", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FileServiceRestTransport._GetFile._get_response( self._host, @@ -571,7 +697,29 @@ def __call__( pb_resp = file.File.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_file(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = file.File.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.FileServiceClient.get_file", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.FileService", + "rpcName": "GetFile", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListFiles(_BaseFileServiceRestTransport._BaseListFiles, FileServiceRestStub): @@ -606,7 +754,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> file_service.ListFilesResponse: r"""Call the list files method over HTTP. @@ -616,8 +764,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.file_service.ListFilesResponse: @@ -627,6 +777,7 @@ def __call__( http_options = ( _BaseFileServiceRestTransport._BaseListFiles._get_http_options() ) + request, metadata = self._interceptor.pre_list_files(request, metadata) transcoded_request = ( _BaseFileServiceRestTransport._BaseListFiles._get_transcoded_request( @@ -641,6 +792,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.FileServiceClient.ListFiles", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.FileService", + "rpcName": "ListFiles", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FileServiceRestTransport._ListFiles._get_response( self._host, @@ -661,7 +839,29 @@ def __call__( pb_resp = file_service.ListFilesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_files(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = file_service.ListFilesResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.FileServiceClient.list_files", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.FileService", + "rpcName": "ListFiles", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -732,7 +932,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -742,8 +942,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -752,6 +954,7 @@ def __call__( http_options = ( _BaseFileServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseFileServiceRestTransport._BaseGetOperation._get_transcoded_request( @@ -766,6 +969,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.FileServiceClient.GetOperation", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.FileService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FileServiceRestTransport._GetOperation._get_response( self._host, @@ -785,6 +1015,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.ai.generativelanguage_v1beta.FileServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.FileService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -825,7 +1076,7 @@ def __call__( *, 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. @@ -835,8 +1086,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must 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. @@ -845,6 +1098,7 @@ def __call__( http_options = ( _BaseFileServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseFileServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -855,6 +1109,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.FileServiceClient.ListOperations", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.FileService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FileServiceRestTransport._ListOperations._get_response( self._host, @@ -874,6 +1155,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.ai.generativelanguage_v1beta.FileServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.FileService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/generative_service/async_client.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/generative_service/async_client.py index 1a5f5e64888b..535e5cff0d45 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/generative_service/async_client.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/generative_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, @@ -54,6 +55,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, GenerativeServiceTransport from .transports.grpc_asyncio import GenerativeServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class GenerativeServiceAsyncClient: """API for using Large Models that generate multimodal content @@ -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.ai.generativelanguage_v1beta.GenerativeServiceAsyncClient`.", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.GenerativeService", + "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.ai.generativelanguage.v1beta.GenerativeService", + "credentialsType": None, + }, + ) + async def generate_content( self, request: Optional[ @@ -279,7 +311,7 @@ async def generate_content( contents: Optional[MutableSequence[content.Content]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_service.GenerateContentResponse: r"""Generates a model response given an input ``GenerateContentRequest``. Refer to the `text generation @@ -346,8 +378,10 @@ async def sample_generate_content(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.GenerateContentResponse: @@ -425,7 +459,7 @@ async def generate_answer( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_service.GenerateAnswerResponse: r"""Generates a grounded answer from the model given an input ``GenerateAnswerRequest``. @@ -523,8 +557,10 @@ async def sample_generate_answer(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.GenerateAnswerResponse: @@ -594,7 +630,7 @@ def stream_generate_content( contents: Optional[MutableSequence[content.Content]] = None, retry: OptionalRetry = 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[generative_service.GenerateContentResponse]]: r"""Generates a `streamed response `__ @@ -656,8 +692,10 @@ async def sample_stream_generate_content(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: AsyncIterable[google.ai.generativelanguage_v1beta.types.GenerateContentResponse]: @@ -731,7 +769,7 @@ async def embed_content( content: Optional[gag_content.Content] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_service.EmbedContentResponse: r"""Generates a text embedding vector from the input ``Content`` using the specified `Gemini Embedding @@ -789,8 +827,10 @@ async def sample_embed_content(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.EmbedContentResponse: @@ -856,7 +896,7 @@ async def batch_embed_contents( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_service.BatchEmbedContentsResponse: r"""Generates multiple embedding vectors from the input ``Content`` which consists of a batch of strings represented as @@ -919,8 +959,10 @@ async def sample_batch_embed_contents(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.BatchEmbedContentsResponse: @@ -982,7 +1024,7 @@ async def count_tokens( contents: Optional[MutableSequence[content.Content]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_service.CountTokensResponse: r"""Runs a model's tokenizer on input ``Content`` and returns the token count. Refer to the `tokens @@ -1045,8 +1087,10 @@ async def sample_count_tokens(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.CountTokensResponse: @@ -1109,7 +1153,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. @@ -1120,8 +1164,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. @@ -1162,7 +1208,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. @@ -1173,8 +1219,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-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/generative_service/client.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/generative_service/client.py index abbc75bd353b..02c6b988a806 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/generative_service/client.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/generative_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 ( @@ -49,6 +50,15 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + from google.longrunning import operations_pb2 # type: ignore from google.ai.generativelanguage_v1beta.types import generative_service, safety @@ -596,6 +606,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -662,6 +676,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.ai.generativelanguage_v1beta.GenerativeServiceClient`.", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.GenerativeService", + "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.ai.generativelanguage.v1beta.GenerativeService", + "credentialsType": None, + }, + ) + def generate_content( self, request: Optional[ @@ -672,7 +709,7 @@ def generate_content( contents: Optional[MutableSequence[content.Content]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_service.GenerateContentResponse: r"""Generates a model response given an input ``GenerateContentRequest``. Refer to the `text generation @@ -739,8 +776,10 @@ def sample_generate_content(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.GenerateContentResponse: @@ -815,7 +854,7 @@ def generate_answer( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_service.GenerateAnswerResponse: r"""Generates a grounded answer from the model given an input ``GenerateAnswerRequest``. @@ -913,8 +952,10 @@ def sample_generate_answer(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.GenerateAnswerResponse: @@ -981,7 +1022,7 @@ def stream_generate_content( contents: Optional[MutableSequence[content.Content]] = None, retry: OptionalRetry = 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[generative_service.GenerateContentResponse]: r"""Generates a `streamed response `__ @@ -1043,8 +1084,10 @@ def sample_stream_generate_content(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: Iterable[google.ai.generativelanguage_v1beta.types.GenerateContentResponse]: @@ -1115,7 +1158,7 @@ def embed_content( content: Optional[gag_content.Content] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_service.EmbedContentResponse: r"""Generates a text embedding vector from the input ``Content`` using the specified `Gemini Embedding @@ -1173,8 +1216,10 @@ def sample_embed_content(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.EmbedContentResponse: @@ -1237,7 +1282,7 @@ def batch_embed_contents( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_service.BatchEmbedContentsResponse: r"""Generates multiple embedding vectors from the input ``Content`` which consists of a batch of strings represented as @@ -1300,8 +1345,10 @@ def sample_batch_embed_contents(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.BatchEmbedContentsResponse: @@ -1360,7 +1407,7 @@ def count_tokens( contents: Optional[MutableSequence[content.Content]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_service.CountTokensResponse: r"""Runs a model's tokenizer on input ``Content`` and returns the token count. Refer to the `tokens @@ -1423,8 +1470,10 @@ def sample_count_tokens(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.CountTokensResponse: @@ -1497,7 +1546,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. @@ -1508,8 +1557,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. @@ -1550,7 +1601,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. @@ -1561,8 +1612,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-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/generative_service/transports/grpc.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/generative_service/transports/grpc.py index 84d9dedae2e3..6d9945a1a332 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/generative_service/transports/grpc.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/generative_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.ai.generativelanguage_v1beta.types import generative_service from .base import DEFAULT_CLIENT_INFO, GenerativeServiceTransport +try: + from google.api_core import client_logging # 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.ai.generativelanguage.v1beta.GenerativeService", + "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.ai.generativelanguage.v1beta.GenerativeService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class GenerativeServiceGrpcTransport(GenerativeServiceTransport): """gRPC backend transport for GenerativeService. @@ -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 @@ -266,7 +352,7 @@ def generate_content( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_content" not in self._stubs: - self._stubs["generate_content"] = self.grpc_channel.unary_unary( + self._stubs["generate_content"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.GenerativeService/GenerateContent", request_serializer=generative_service.GenerateContentRequest.serialize, response_deserializer=generative_service.GenerateContentResponse.deserialize, @@ -296,7 +382,7 @@ def generate_answer( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_answer" not in self._stubs: - self._stubs["generate_answer"] = self.grpc_channel.unary_unary( + self._stubs["generate_answer"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.GenerativeService/GenerateAnswer", request_serializer=generative_service.GenerateAnswerRequest.serialize, response_deserializer=generative_service.GenerateAnswerResponse.deserialize, @@ -327,7 +413,7 @@ def stream_generate_content( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stream_generate_content" not in self._stubs: - self._stubs["stream_generate_content"] = self.grpc_channel.unary_stream( + self._stubs["stream_generate_content"] = self._logged_channel.unary_stream( "/google.ai.generativelanguage.v1beta.GenerativeService/StreamGenerateContent", request_serializer=generative_service.GenerateContentRequest.serialize, response_deserializer=generative_service.GenerateContentResponse.deserialize, @@ -358,7 +444,7 @@ def embed_content( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "embed_content" not in self._stubs: - self._stubs["embed_content"] = self.grpc_channel.unary_unary( + self._stubs["embed_content"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.GenerativeService/EmbedContent", request_serializer=generative_service.EmbedContentRequest.serialize, response_deserializer=generative_service.EmbedContentResponse.deserialize, @@ -389,7 +475,7 @@ def batch_embed_contents( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_embed_contents" not in self._stubs: - self._stubs["batch_embed_contents"] = self.grpc_channel.unary_unary( + self._stubs["batch_embed_contents"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.GenerativeService/BatchEmbedContents", request_serializer=generative_service.BatchEmbedContentsRequest.serialize, response_deserializer=generative_service.BatchEmbedContentsResponse.deserialize, @@ -420,7 +506,7 @@ def count_tokens( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "count_tokens" not in self._stubs: - self._stubs["count_tokens"] = self.grpc_channel.unary_unary( + self._stubs["count_tokens"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.GenerativeService/CountTokens", request_serializer=generative_service.CountTokensRequest.serialize, response_deserializer=generative_service.CountTokensResponse.deserialize, @@ -428,7 +514,7 @@ def count_tokens( return self._stubs["count_tokens"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -440,7 +526,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, @@ -459,7 +545,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-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/generative_service/transports/grpc_asyncio.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/generative_service/transports/grpc_asyncio.py index 5753df791ed4..b739ac182d5e 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/generative_service/transports/grpc_asyncio.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/generative_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.ai.generativelanguage_v1beta.types import generative_service from .base import DEFAULT_CLIENT_INFO, GenerativeServiceTransport from .grpc import GenerativeServiceGrpcTransport +try: + from google.api_core import client_logging # 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.ai.generativelanguage.v1beta.GenerativeService", + "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.ai.generativelanguage.v1beta.GenerativeService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class GenerativeServiceGrpcAsyncIOTransport(GenerativeServiceTransport): """gRPC AsyncIO backend transport for GenerativeService. @@ -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 @@ -274,7 +359,7 @@ def generate_content( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_content" not in self._stubs: - self._stubs["generate_content"] = self.grpc_channel.unary_unary( + self._stubs["generate_content"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.GenerativeService/GenerateContent", request_serializer=generative_service.GenerateContentRequest.serialize, response_deserializer=generative_service.GenerateContentResponse.deserialize, @@ -304,7 +389,7 @@ def generate_answer( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_answer" not in self._stubs: - self._stubs["generate_answer"] = self.grpc_channel.unary_unary( + self._stubs["generate_answer"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.GenerativeService/GenerateAnswer", request_serializer=generative_service.GenerateAnswerRequest.serialize, response_deserializer=generative_service.GenerateAnswerResponse.deserialize, @@ -335,7 +420,7 @@ def stream_generate_content( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stream_generate_content" not in self._stubs: - self._stubs["stream_generate_content"] = self.grpc_channel.unary_stream( + self._stubs["stream_generate_content"] = self._logged_channel.unary_stream( "/google.ai.generativelanguage.v1beta.GenerativeService/StreamGenerateContent", request_serializer=generative_service.GenerateContentRequest.serialize, response_deserializer=generative_service.GenerateContentResponse.deserialize, @@ -366,7 +451,7 @@ def embed_content( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "embed_content" not in self._stubs: - self._stubs["embed_content"] = self.grpc_channel.unary_unary( + self._stubs["embed_content"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.GenerativeService/EmbedContent", request_serializer=generative_service.EmbedContentRequest.serialize, response_deserializer=generative_service.EmbedContentResponse.deserialize, @@ -397,7 +482,7 @@ def batch_embed_contents( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_embed_contents" not in self._stubs: - self._stubs["batch_embed_contents"] = self.grpc_channel.unary_unary( + self._stubs["batch_embed_contents"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.GenerativeService/BatchEmbedContents", request_serializer=generative_service.BatchEmbedContentsRequest.serialize, response_deserializer=generative_service.BatchEmbedContentsResponse.deserialize, @@ -429,7 +514,7 @@ def count_tokens( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "count_tokens" not in self._stubs: - self._stubs["count_tokens"] = self.grpc_channel.unary_unary( + self._stubs["count_tokens"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.GenerativeService/CountTokens", request_serializer=generative_service.CountTokensRequest.serialize, response_deserializer=generative_service.CountTokensResponse.deserialize, @@ -541,7 +626,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: @@ -557,7 +642,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, @@ -576,7 +661,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-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/generative_service/transports/rest.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/generative_service/transports/rest.py index 0e6c3b6d76b8..e37b9eeb1a00 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/generative_service/transports/rest.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/generative_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, @@ -118,8 +126,11 @@ def post_stream_generate_content(self, response): def pre_batch_embed_contents( self, request: generative_service.BatchEmbedContentsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[generative_service.BatchEmbedContentsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + generative_service.BatchEmbedContentsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for batch_embed_contents Override in a subclass to manipulate the request or metadata @@ -141,8 +152,10 @@ def post_batch_embed_contents( def pre_count_tokens( self, request: generative_service.CountTokensRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[generative_service.CountTokensRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + generative_service.CountTokensRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for count_tokens Override in a subclass to manipulate the request or metadata @@ -164,8 +177,10 @@ def post_count_tokens( def pre_embed_content( self, request: generative_service.EmbedContentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[generative_service.EmbedContentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + generative_service.EmbedContentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for embed_content Override in a subclass to manipulate the request or metadata @@ -187,8 +202,11 @@ def post_embed_content( def pre_generate_answer( self, request: generative_service.GenerateAnswerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[generative_service.GenerateAnswerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + generative_service.GenerateAnswerRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for generate_answer Override in a subclass to manipulate the request or metadata @@ -210,8 +228,11 @@ def post_generate_answer( def pre_generate_content( self, request: generative_service.GenerateContentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[generative_service.GenerateContentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + generative_service.GenerateContentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for generate_content Override in a subclass to manipulate the request or metadata @@ -233,8 +254,11 @@ def post_generate_content( def pre_stream_generate_content( self, request: generative_service.GenerateContentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[generative_service.GenerateContentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + generative_service.GenerateContentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for stream_generate_content Override in a subclass to manipulate the request or metadata @@ -256,8 +280,10 @@ def post_stream_generate_content( 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 @@ -279,8 +305,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 @@ -423,7 +451,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_service.BatchEmbedContentsResponse: r"""Call the batch embed contents method over HTTP. @@ -434,8 +462,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.generative_service.BatchEmbedContentsResponse: @@ -445,6 +475,7 @@ def __call__( http_options = ( _BaseGenerativeServiceRestTransport._BaseBatchEmbedContents._get_http_options() ) + request, metadata = self._interceptor.pre_batch_embed_contents( request, metadata ) @@ -461,6 +492,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.GenerativeServiceClient.BatchEmbedContents", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.GenerativeService", + "rpcName": "BatchEmbedContents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GenerativeServiceRestTransport._BatchEmbedContents._get_response( self._host, @@ -482,7 +540,31 @@ def __call__( pb_resp = generative_service.BatchEmbedContentsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_embed_contents(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + generative_service.BatchEmbedContentsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.GenerativeServiceClient.batch_embed_contents", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.GenerativeService", + "rpcName": "BatchEmbedContents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CountTokens( @@ -520,7 +602,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_service.CountTokensResponse: r"""Call the count tokens method over HTTP. @@ -534,8 +616,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.generative_service.CountTokensResponse: @@ -549,6 +633,7 @@ def __call__( http_options = ( _BaseGenerativeServiceRestTransport._BaseCountTokens._get_http_options() ) + request, metadata = self._interceptor.pre_count_tokens(request, metadata) transcoded_request = _BaseGenerativeServiceRestTransport._BaseCountTokens._get_transcoded_request( http_options, request @@ -563,6 +648,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.GenerativeServiceClient.CountTokens", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.GenerativeService", + "rpcName": "CountTokens", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GenerativeServiceRestTransport._CountTokens._get_response( self._host, @@ -584,7 +696,31 @@ def __call__( pb_resp = generative_service.CountTokensResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_count_tokens(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = generative_service.CountTokensResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.GenerativeServiceClient.count_tokens", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.GenerativeService", + "rpcName": "CountTokens", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _EmbedContent( @@ -622,7 +758,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_service.EmbedContentResponse: r"""Call the embed content method over HTTP. @@ -633,8 +769,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.generative_service.EmbedContentResponse: @@ -644,6 +782,7 @@ def __call__( http_options = ( _BaseGenerativeServiceRestTransport._BaseEmbedContent._get_http_options() ) + request, metadata = self._interceptor.pre_embed_content(request, metadata) transcoded_request = _BaseGenerativeServiceRestTransport._BaseEmbedContent._get_transcoded_request( http_options, request @@ -658,6 +797,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.GenerativeServiceClient.EmbedContent", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.GenerativeService", + "rpcName": "EmbedContent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GenerativeServiceRestTransport._EmbedContent._get_response( self._host, @@ -679,7 +845,31 @@ def __call__( pb_resp = generative_service.EmbedContentResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_embed_content(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = generative_service.EmbedContentResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.GenerativeServiceClient.embed_content", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.GenerativeService", + "rpcName": "EmbedContent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GenerateAnswer( @@ -718,7 +908,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_service.GenerateAnswerResponse: r"""Call the generate answer method over HTTP. @@ -729,8 +919,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.generative_service.GenerateAnswerResponse: @@ -742,6 +934,7 @@ def __call__( http_options = ( _BaseGenerativeServiceRestTransport._BaseGenerateAnswer._get_http_options() ) + request, metadata = self._interceptor.pre_generate_answer(request, metadata) transcoded_request = _BaseGenerativeServiceRestTransport._BaseGenerateAnswer._get_transcoded_request( http_options, request @@ -756,6 +949,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.GenerativeServiceClient.GenerateAnswer", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.GenerativeService", + "rpcName": "GenerateAnswer", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GenerativeServiceRestTransport._GenerateAnswer._get_response( self._host, @@ -777,7 +997,31 @@ def __call__( pb_resp = generative_service.GenerateAnswerResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_generate_answer(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + generative_service.GenerateAnswerResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.GenerativeServiceClient.generate_answer", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.GenerativeService", + "rpcName": "GenerateAnswer", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GenerateContent( @@ -816,7 +1060,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> generative_service.GenerateContentResponse: r"""Call the generate content method over HTTP. @@ -827,8 +1071,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.generative_service.GenerateContentResponse: @@ -854,6 +1100,7 @@ def __call__( http_options = ( _BaseGenerativeServiceRestTransport._BaseGenerateContent._get_http_options() ) + request, metadata = self._interceptor.pre_generate_content( request, metadata ) @@ -870,6 +1117,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.GenerativeServiceClient.GenerateContent", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.GenerativeService", + "rpcName": "GenerateContent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GenerativeServiceRestTransport._GenerateContent._get_response( self._host, @@ -891,7 +1165,31 @@ def __call__( pb_resp = generative_service.GenerateContentResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_generate_content(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + generative_service.GenerateContentResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.GenerativeServiceClient.generate_content", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.GenerativeService", + "rpcName": "GenerateContent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StreamGenerateContent( @@ -931,7 +1229,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> rest_streaming.ResponseIterator: r"""Call the stream generate content method over HTTP. @@ -942,8 +1240,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.generative_service.GenerateContentResponse: @@ -969,6 +1269,7 @@ def __call__( http_options = ( _BaseGenerativeServiceRestTransport._BaseStreamGenerateContent._get_http_options() ) + request, metadata = self._interceptor.pre_stream_generate_content( request, metadata ) @@ -985,6 +1286,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.GenerativeServiceClient.StreamGenerateContent", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.GenerativeService", + "rpcName": "StreamGenerateContent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( GenerativeServiceRestTransport._StreamGenerateContent._get_response( @@ -1007,6 +1335,7 @@ def __call__( resp = rest_streaming.ResponseIterator( response, generative_service.GenerateContentResponse ) + resp = self._interceptor.post_stream_generate_content(resp) return resp @@ -1113,7 +1442,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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. @@ -1123,8 +1452,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: operations_pb2.Operation: Response from GetOperation method. @@ -1133,6 +1464,7 @@ def __call__( http_options = ( _BaseGenerativeServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseGenerativeServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1143,6 +1475,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.GenerativeServiceClient.GetOperation", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.GenerativeService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GenerativeServiceRestTransport._GetOperation._get_response( self._host, @@ -1162,6 +1521,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.ai.generativelanguage_v1beta.GenerativeServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.GenerativeService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1203,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.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1213,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.ListOperationsResponse: Response from ListOperations method. @@ -1223,6 +1605,7 @@ def __call__( http_options = ( _BaseGenerativeServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseGenerativeServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1233,6 +1616,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.GenerativeServiceClient.ListOperations", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.GenerativeService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = GenerativeServiceRestTransport._ListOperations._get_response( self._host, @@ -1252,6 +1662,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.ai.generativelanguage_v1beta.GenerativeServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.GenerativeService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/model_service/async_client.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/model_service/async_client.py index f9c433b54ace..209ad61b67c2 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/model_service/async_client.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/model_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -57,6 +58,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ModelServiceTransport from .transports.grpc_asyncio import ModelServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class ModelServiceAsyncClient: """Provides methods for getting metadata information about @@ -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.ai.generativelanguage_v1beta.ModelServiceAsyncClient`.", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.ModelService", + "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.ai.generativelanguage.v1beta.ModelService", + "credentialsType": None, + }, + ) + async def get_model( self, request: Optional[Union[model_service.GetModelRequest, dict]] = None, @@ -269,7 +301,7 @@ async def get_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model.Model: r"""Gets information about a specific ``Model`` such as its version number, token limits, @@ -322,8 +354,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.ai.generativelanguage_v1beta.types.Model: @@ -385,7 +419,7 @@ async def list_models( page_token: Optional[str] = None, retry: OptionalRetry = gapic_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 the ```Model``\ s `__ @@ -447,8 +481,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.ai.generativelanguage_v1beta.services.model_service.pagers.ListModelsAsyncPager: @@ -519,7 +555,7 @@ async def get_tuned_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]]] = (), ) -> tuned_model.TunedModel: r"""Gets information about a specific TunedModel. @@ -564,8 +600,10 @@ async def sample_get_tuned_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.ai.generativelanguage_v1beta.types.TunedModel: @@ -627,7 +665,7 @@ async def list_tuned_models( page_token: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTunedModelsAsyncPager: r"""Lists created tuned models. @@ -689,8 +727,10 @@ async def sample_list_tuned_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.ai.generativelanguage_v1beta.services.model_service.pagers.ListTunedModelsAsyncPager: @@ -762,7 +802,7 @@ async def create_tuned_model( tuned_model_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 tuned model. Check intermediate tuning progress (if any) through the [google.longrunning.Operations] service. @@ -820,8 +860,10 @@ async def sample_create_tuned_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: @@ -891,7 +933,7 @@ async def update_tuned_model( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gag_tuned_model.TunedModel: r"""Updates a tuned model. @@ -938,8 +980,10 @@ async def sample_update_tuned_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.ai.generativelanguage_v1beta.types.TunedModel: @@ -1004,7 +1048,7 @@ async def delete_tuned_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]]] = (), ) -> None: r"""Deletes a tuned model. @@ -1044,8 +1088,10 @@ async def sample_delete_tuned_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1096,7 +1142,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. @@ -1107,8 +1153,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. @@ -1149,7 +1197,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. @@ -1160,8 +1208,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-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/model_service/client.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/model_service/client.py index f8ea55b13a51..702523ff103f 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/model_service/client.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/model_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 @@ -594,6 +604,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -656,6 +670,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.ai.generativelanguage_v1beta.ModelServiceClient`.", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.ModelService", + "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.ai.generativelanguage.v1beta.ModelService", + "credentialsType": None, + }, + ) + def get_model( self, request: Optional[Union[model_service.GetModelRequest, dict]] = None, @@ -663,7 +700,7 @@ def get_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model.Model: r"""Gets information about a specific ``Model`` such as its version number, token limits, @@ -716,8 +753,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.ai.generativelanguage_v1beta.types.Model: @@ -776,7 +815,7 @@ def list_models( page_token: Optional[str] = None, retry: OptionalRetry = gapic_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 the ```Model``\ s `__ @@ -838,8 +877,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.ai.generativelanguage_v1beta.services.model_service.pagers.ListModelsPager: @@ -907,7 +948,7 @@ def get_tuned_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]]] = (), ) -> tuned_model.TunedModel: r"""Gets information about a specific TunedModel. @@ -952,8 +993,10 @@ def sample_get_tuned_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.ai.generativelanguage_v1beta.types.TunedModel: @@ -1012,7 +1055,7 @@ def list_tuned_models( page_token: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTunedModelsPager: r"""Lists created tuned models. @@ -1074,8 +1117,10 @@ def sample_list_tuned_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.ai.generativelanguage_v1beta.services.model_service.pagers.ListTunedModelsPager: @@ -1144,7 +1189,7 @@ def create_tuned_model( tuned_model_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 tuned model. Check intermediate tuning progress (if any) through the [google.longrunning.Operations] service. @@ -1202,8 +1247,10 @@ def sample_create_tuned_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: @@ -1270,7 +1317,7 @@ def update_tuned_model( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gag_tuned_model.TunedModel: r"""Updates a tuned model. @@ -1317,8 +1364,10 @@ def sample_update_tuned_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.ai.generativelanguage_v1beta.types.TunedModel: @@ -1380,7 +1429,7 @@ def delete_tuned_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]]] = (), ) -> None: r"""Deletes a tuned model. @@ -1420,8 +1469,10 @@ def sample_delete_tuned_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1482,7 +1533,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. @@ -1493,8 +1544,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. @@ -1535,7 +1588,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. @@ -1546,8 +1599,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-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/model_service/pagers.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/model_service/pagers.py index fa2507611b9b..a40e3811721e 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/model_service/pagers.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/model_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 = model_service.ListModelsRequest(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 = model_service.ListModelsRequest(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 = model_service.ListTunedModelsRequest(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 = model_service.ListTunedModelsRequest(request) diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/model_service/transports/grpc.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/model_service/transports/grpc.py index 0396076cd3a3..26fe26700c3d 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/model_service/transports/grpc.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/model_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,7 +25,10 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.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.ai.generativelanguage_v1beta.types import tuned_model as gag_tuned_model from google.ai.generativelanguage_v1beta.types import model, model_service @@ -30,6 +36,81 @@ from .base import DEFAULT_CLIENT_INFO, ModelServiceTransport +try: + from google.api_core import client_logging # 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.ai.generativelanguage.v1beta.ModelService", + "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.ai.generativelanguage.v1beta.ModelService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ModelServiceGrpcTransport(ModelServiceTransport): """gRPC backend transport for ModelService. @@ -185,7 +266,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientInterceptor() + self._logged_channel = grpc.intercept_channel( + self._grpc_channel, self._interceptor + ) + + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @classmethod @@ -249,7 +335,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -276,7 +364,7 @@ def get_model(self) -> Callable[[model_service.GetModelRequest], model.Model]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_model" not in self._stubs: - self._stubs["get_model"] = self.grpc_channel.unary_unary( + self._stubs["get_model"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.ModelService/GetModel", request_serializer=model_service.GetModelRequest.serialize, response_deserializer=model.Model.deserialize, @@ -304,7 +392,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.ai.generativelanguage.v1beta.ModelService/ListModels", request_serializer=model_service.ListModelsRequest.serialize, response_deserializer=model_service.ListModelsResponse.deserialize, @@ -330,7 +418,7 @@ def get_tuned_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_tuned_model" not in self._stubs: - self._stubs["get_tuned_model"] = self.grpc_channel.unary_unary( + self._stubs["get_tuned_model"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.ModelService/GetTunedModel", request_serializer=model_service.GetTunedModelRequest.serialize, response_deserializer=tuned_model.TunedModel.deserialize, @@ -358,7 +446,7 @@ def list_tuned_models( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_tuned_models" not in self._stubs: - self._stubs["list_tuned_models"] = self.grpc_channel.unary_unary( + self._stubs["list_tuned_models"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.ModelService/ListTunedModels", request_serializer=model_service.ListTunedModelsRequest.serialize, response_deserializer=model_service.ListTunedModelsResponse.deserialize, @@ -388,7 +476,7 @@ def create_tuned_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_tuned_model" not in self._stubs: - self._stubs["create_tuned_model"] = self.grpc_channel.unary_unary( + self._stubs["create_tuned_model"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.ModelService/CreateTunedModel", request_serializer=model_service.CreateTunedModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -414,7 +502,7 @@ def update_tuned_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_tuned_model" not in self._stubs: - self._stubs["update_tuned_model"] = self.grpc_channel.unary_unary( + self._stubs["update_tuned_model"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.ModelService/UpdateTunedModel", request_serializer=model_service.UpdateTunedModelRequest.serialize, response_deserializer=gag_tuned_model.TunedModel.deserialize, @@ -440,7 +528,7 @@ def delete_tuned_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_tuned_model" not in self._stubs: - self._stubs["delete_tuned_model"] = self.grpc_channel.unary_unary( + self._stubs["delete_tuned_model"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.ModelService/DeleteTunedModel", request_serializer=model_service.DeleteTunedModelRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -448,7 +536,7 @@ def delete_tuned_model( return self._stubs["delete_tuned_model"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -460,7 +548,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, @@ -479,7 +567,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-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/model_service/transports/grpc_asyncio.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/model_service/transports/grpc_asyncio.py index cb65fdae2fbc..9193dbee1e05 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/model_service/transports/grpc_asyncio.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/model_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.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.ai.generativelanguage_v1beta.types import tuned_model as gag_tuned_model from google.ai.generativelanguage_v1beta.types import model, model_service @@ -34,6 +40,82 @@ from .base import DEFAULT_CLIENT_INFO, ModelServiceTransport from .grpc import ModelServiceGrpcTransport +try: + from google.api_core import client_logging # 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.ai.generativelanguage.v1beta.ModelService", + "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.ai.generativelanguage.v1beta.ModelService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ModelServiceGrpcAsyncIOTransport(ModelServiceTransport): """gRPC AsyncIO backend transport for ModelService. @@ -232,10 +314,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientAIOInterceptor() + self._grpc_channel._unary_unary_interceptors.append(self._interceptor) + self._logged_channel = self._grpc_channel self._wrap_with_kind = ( "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters ) + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @property @@ -258,7 +343,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -288,7 +373,7 @@ def 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.ai.generativelanguage.v1beta.ModelService/GetModel", request_serializer=model_service.GetModelRequest.serialize, response_deserializer=model.Model.deserialize, @@ -318,7 +403,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.ai.generativelanguage.v1beta.ModelService/ListModels", request_serializer=model_service.ListModelsRequest.serialize, response_deserializer=model_service.ListModelsResponse.deserialize, @@ -346,7 +431,7 @@ def get_tuned_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_tuned_model" not in self._stubs: - self._stubs["get_tuned_model"] = self.grpc_channel.unary_unary( + self._stubs["get_tuned_model"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.ModelService/GetTunedModel", request_serializer=model_service.GetTunedModelRequest.serialize, response_deserializer=tuned_model.TunedModel.deserialize, @@ -375,7 +460,7 @@ def list_tuned_models( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_tuned_models" not in self._stubs: - self._stubs["list_tuned_models"] = self.grpc_channel.unary_unary( + self._stubs["list_tuned_models"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.ModelService/ListTunedModels", request_serializer=model_service.ListTunedModelsRequest.serialize, response_deserializer=model_service.ListTunedModelsResponse.deserialize, @@ -407,7 +492,7 @@ def create_tuned_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_tuned_model" not in self._stubs: - self._stubs["create_tuned_model"] = self.grpc_channel.unary_unary( + self._stubs["create_tuned_model"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.ModelService/CreateTunedModel", request_serializer=model_service.CreateTunedModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -435,7 +520,7 @@ def update_tuned_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_tuned_model" not in self._stubs: - self._stubs["update_tuned_model"] = self.grpc_channel.unary_unary( + self._stubs["update_tuned_model"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.ModelService/UpdateTunedModel", request_serializer=model_service.UpdateTunedModelRequest.serialize, response_deserializer=gag_tuned_model.TunedModel.deserialize, @@ -461,7 +546,7 @@ def delete_tuned_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_tuned_model" not in self._stubs: - self._stubs["delete_tuned_model"] = self.grpc_channel.unary_unary( + self._stubs["delete_tuned_model"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.ModelService/DeleteTunedModel", request_serializer=model_service.DeleteTunedModelRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -587,7 +672,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: @@ -603,7 +688,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -622,7 +707,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/model_service/transports/rest.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/model_service/transports/rest.py index 378e688cd29e..88613b2bba21 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/model_service/transports/rest.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/model_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, @@ -125,8 +133,10 @@ def post_update_tuned_model(self, response): def pre_create_tuned_model( self, request: model_service.CreateTunedModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.CreateTunedModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + model_service.CreateTunedModelRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_tuned_model Override in a subclass to manipulate the request or metadata @@ -148,8 +158,10 @@ def post_create_tuned_model( def pre_delete_tuned_model( self, request: model_service.DeleteTunedModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.DeleteTunedModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + model_service.DeleteTunedModelRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_tuned_model Override in a subclass to manipulate the request or metadata @@ -160,8 +172,8 @@ def pre_delete_tuned_model( def pre_get_model( self, request: model_service.GetModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.GetModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[model_service.GetModelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_model Override in a subclass to manipulate the request or metadata @@ -181,8 +193,10 @@ def post_get_model(self, response: model.Model) -> model.Model: def pre_get_tuned_model( self, request: model_service.GetTunedModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.GetTunedModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + model_service.GetTunedModelRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_tuned_model Override in a subclass to manipulate the request or metadata @@ -204,8 +218,10 @@ def post_get_tuned_model( def pre_list_models( self, request: model_service.ListModelsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.ListModelsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + model_service.ListModelsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_models Override in a subclass to manipulate the request or metadata @@ -227,8 +243,10 @@ def post_list_models( def pre_list_tuned_models( self, request: model_service.ListTunedModelsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.ListTunedModelsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + model_service.ListTunedModelsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_tuned_models Override in a subclass to manipulate the request or metadata @@ -250,8 +268,10 @@ def post_list_tuned_models( def pre_update_tuned_model( self, request: model_service.UpdateTunedModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.UpdateTunedModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + model_service.UpdateTunedModelRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_tuned_model Override in a subclass to manipulate the request or metadata @@ -273,8 +293,10 @@ def post_update_tuned_model( 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 @@ -296,8 +318,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 @@ -492,7 +516,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 tuned model method over HTTP. @@ -502,8 +526,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -516,6 +542,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseCreateTunedModel._get_http_options() ) + request, metadata = self._interceptor.pre_create_tuned_model( request, metadata ) @@ -532,6 +559,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.ModelServiceClient.CreateTunedModel", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.ModelService", + "rpcName": "CreateTunedModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._CreateTunedModel._get_response( self._host, @@ -551,7 +605,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_tuned_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.ai.generativelanguage_v1beta.ModelServiceClient.create_tuned_model", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.ModelService", + "rpcName": "CreateTunedModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteTunedModel( @@ -588,7 +664,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete tuned model method over HTTP. @@ -598,13 +674,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 = ( _BaseModelServiceRestTransport._BaseDeleteTunedModel._get_http_options() ) + request, metadata = self._interceptor.pre_delete_tuned_model( request, metadata ) @@ -617,6 +696,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.ModelServiceClient.DeleteTunedModel", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.ModelService", + "rpcName": "DeleteTunedModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._DeleteTunedModel._get_response( self._host, @@ -664,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]]] = (), ) -> model.Model: r"""Call the get model method over HTTP. @@ -675,8 +781,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.model.Model: @@ -688,6 +796,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseGetModel._get_http_options() ) + request, metadata = self._interceptor.pre_get_model(request, metadata) transcoded_request = ( _BaseModelServiceRestTransport._BaseGetModel._get_transcoded_request( @@ -702,6 +811,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.ModelServiceClient.GetModel", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.ModelService", + "rpcName": "GetModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._GetModel._get_response( self._host, @@ -722,7 +858,29 @@ def __call__( pb_resp = model.Model.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_model(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = model.Model.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.ModelServiceClient.get_model", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.ModelService", + "rpcName": "GetModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetTunedModel( @@ -759,7 +917,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tuned_model.TunedModel: r"""Call the get tuned model method over HTTP. @@ -770,8 +928,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.tuned_model.TunedModel: @@ -783,6 +943,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseGetTunedModel._get_http_options() ) + request, metadata = self._interceptor.pre_get_tuned_model(request, metadata) transcoded_request = _BaseModelServiceRestTransport._BaseGetTunedModel._get_transcoded_request( http_options, request @@ -793,6 +954,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.ModelServiceClient.GetTunedModel", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.ModelService", + "rpcName": "GetTunedModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._GetTunedModel._get_response( self._host, @@ -813,7 +1001,29 @@ def __call__( pb_resp = tuned_model.TunedModel.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_tuned_model(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = tuned_model.TunedModel.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.ModelServiceClient.get_tuned_model", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.ModelService", + "rpcName": "GetTunedModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListModels( @@ -850,7 +1060,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model_service.ListModelsResponse: r"""Call the list models method over HTTP. @@ -860,8 +1070,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.model_service.ListModelsResponse: @@ -873,6 +1085,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseListModels._get_http_options() ) + request, metadata = self._interceptor.pre_list_models(request, metadata) transcoded_request = ( _BaseModelServiceRestTransport._BaseListModels._get_transcoded_request( @@ -887,6 +1100,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.ModelServiceClient.ListModels", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.ModelService", + "rpcName": "ListModels", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._ListModels._get_response( self._host, @@ -907,7 +1147,31 @@ def __call__( pb_resp = model_service.ListModelsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_models(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = model_service.ListModelsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.ModelServiceClient.list_models", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.ModelService", + "rpcName": "ListModels", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTunedModels( @@ -944,7 +1208,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model_service.ListTunedModelsResponse: r"""Call the list tuned models method over HTTP. @@ -954,8 +1218,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.model_service.ListTunedModelsResponse: @@ -967,6 +1233,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseListTunedModels._get_http_options() ) + request, metadata = self._interceptor.pre_list_tuned_models( request, metadata ) @@ -979,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 = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.ModelServiceClient.ListTunedModels", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.ModelService", + "rpcName": "ListTunedModels", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._ListTunedModels._get_response( self._host, @@ -999,7 +1293,31 @@ def __call__( pb_resp = model_service.ListTunedModelsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_tuned_models(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = model_service.ListTunedModelsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.ModelServiceClient.list_tuned_models", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.ModelService", + "rpcName": "ListTunedModels", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateTunedModel( @@ -1037,7 +1355,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gag_tuned_model.TunedModel: r"""Call the update tuned model method over HTTP. @@ -1047,8 +1365,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gag_tuned_model.TunedModel: @@ -1060,6 +1380,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseUpdateTunedModel._get_http_options() ) + request, metadata = self._interceptor.pre_update_tuned_model( request, metadata ) @@ -1076,6 +1397,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.ModelServiceClient.UpdateTunedModel", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.ModelService", + "rpcName": "UpdateTunedModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._UpdateTunedModel._get_response( self._host, @@ -1097,7 +1445,29 @@ def __call__( pb_resp = gag_tuned_model.TunedModel.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_tuned_model(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gag_tuned_model.TunedModel.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.ModelServiceClient.update_tuned_model", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.ModelService", + "rpcName": "UpdateTunedModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1194,7 +1564,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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. @@ -1204,8 +1574,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: operations_pb2.Operation: Response from GetOperation method. @@ -1214,6 +1586,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseModelServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1226,6 +1599,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.ModelServiceClient.GetOperation", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.ModelService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._GetOperation._get_response( self._host, @@ -1245,6 +1645,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.ai.generativelanguage_v1beta.ModelServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.ModelService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1285,7 +1706,7 @@ def __call__( *, 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. @@ -1295,8 +1716,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must 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. @@ -1305,6 +1728,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseModelServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1315,6 +1739,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.ModelServiceClient.ListOperations", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.ModelService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._ListOperations._get_response( self._host, @@ -1334,6 +1785,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.ai.generativelanguage_v1beta.ModelServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.ModelService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/permission_service/async_client.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/permission_service/async_client.py index e0102adae8c9..43ada0834ac8 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/permission_service/async_client.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/permission_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, PermissionServiceTransport from .transports.grpc_asyncio import PermissionServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class PermissionServiceAsyncClient: """Provides methods for managing permissions to PaLM API @@ -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.ai.generativelanguage_v1beta.PermissionServiceAsyncClient`.", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.PermissionService", + "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.ai.generativelanguage.v1beta.PermissionService", + "credentialsType": None, + }, + ) + async def create_permission( self, request: Optional[ @@ -275,7 +307,7 @@ async def create_permission( permission: Optional[gag_permission.Permission] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gag_permission.Permission: r"""Create a permission to a specific resource. @@ -324,8 +356,10 @@ async def sample_create_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.ai.generativelanguage_v1beta.types.Permission: @@ -409,7 +443,7 @@ async def get_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]]] = (), ) -> permission.Permission: r"""Gets information about a specific Permission. @@ -456,8 +490,10 @@ async def sample_get_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.ai.generativelanguage_v1beta.types.Permission: @@ -541,7 +577,7 @@ async def list_permissions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPermissionsAsyncPager: r"""Lists permissions for the specific resource. @@ -586,8 +622,10 @@ async def sample_list_permissions(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.services.permission_service.pagers.ListPermissionsAsyncPager: @@ -665,7 +703,7 @@ async def update_permission( 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]]] = (), ) -> gag_permission.Permission: r"""Updates the permission. @@ -717,8 +755,10 @@ async def sample_update_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.ai.generativelanguage_v1beta.types.Permission: @@ -806,7 +846,7 @@ async def delete_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]]] = (), ) -> None: r"""Deletes the permission. @@ -847,8 +887,10 @@ async def sample_delete_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -901,7 +943,7 @@ async def transfer_ownership( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> permission_service.TransferOwnershipResponse: r"""Transfers ownership of the tuned model. This is the only way to change ownership of the tuned @@ -942,8 +984,10 @@ async def sample_transfer_ownership(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.TransferOwnershipResponse: @@ -987,7 +1031,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. @@ -998,8 +1042,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. @@ -1040,7 +1086,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. @@ -1051,8 +1097,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-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/permission_service/client.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/permission_service/client.py index e4b6864dd536..bc656856e4b8 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/permission_service/client.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/permission_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.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_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,6 +666,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.ai.generativelanguage_v1beta.PermissionServiceClient`.", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.PermissionService", + "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.ai.generativelanguage.v1beta.PermissionService", + "credentialsType": None, + }, + ) + def create_permission( self, request: Optional[ @@ -662,7 +699,7 @@ def create_permission( permission: Optional[gag_permission.Permission] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gag_permission.Permission: r"""Create a permission to a specific resource. @@ -711,8 +748,10 @@ def sample_create_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.ai.generativelanguage_v1beta.types.Permission: @@ -793,7 +832,7 @@ def get_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]]] = (), ) -> permission.Permission: r"""Gets information about a specific Permission. @@ -840,8 +879,10 @@ def sample_get_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.ai.generativelanguage_v1beta.types.Permission: @@ -922,7 +963,7 @@ def list_permissions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPermissionsPager: r"""Lists permissions for the specific resource. @@ -967,8 +1008,10 @@ def sample_list_permissions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.services.permission_service.pagers.ListPermissionsPager: @@ -1043,7 +1086,7 @@ def update_permission( 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]]] = (), ) -> gag_permission.Permission: r"""Updates the permission. @@ -1095,8 +1138,10 @@ def sample_update_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.ai.generativelanguage_v1beta.types.Permission: @@ -1181,7 +1226,7 @@ def delete_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]]] = (), ) -> None: r"""Deletes the permission. @@ -1222,8 +1267,10 @@ def sample_delete_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1273,7 +1320,7 @@ def transfer_ownership( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> permission_service.TransferOwnershipResponse: r"""Transfers ownership of the tuned model. This is the only way to change ownership of the tuned @@ -1314,8 +1361,10 @@ def sample_transfer_ownership(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.TransferOwnershipResponse: @@ -1370,7 +1419,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. @@ -1381,8 +1430,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. @@ -1423,7 +1474,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. @@ -1434,8 +1485,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-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/permission_service/pagers.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/permission_service/pagers.py index c85db9227279..6b8000ff697e 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/permission_service/pagers.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/permission_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 = permission_service.ListPermissionsRequest(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 = permission_service.ListPermissionsRequest(request) diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/permission_service/transports/grpc.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/permission_service/transports/grpc.py index d664208303d4..386c1be905d7 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/permission_service/transports/grpc.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/permission_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,7 +25,10 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.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.ai.generativelanguage_v1beta.types import permission as gag_permission from google.ai.generativelanguage_v1beta.types import permission @@ -30,6 +36,81 @@ from .base import DEFAULT_CLIENT_INFO, PermissionServiceTransport +try: + from google.api_core import client_logging # 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.ai.generativelanguage.v1beta.PermissionService", + "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.ai.generativelanguage.v1beta.PermissionService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class PermissionServiceGrpcTransport(PermissionServiceTransport): """gRPC backend transport for PermissionService. @@ -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_permission( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_permission" not in self._stubs: - self._stubs["create_permission"] = self.grpc_channel.unary_unary( + self._stubs["create_permission"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.PermissionService/CreatePermission", request_serializer=permission_service.CreatePermissionRequest.serialize, response_deserializer=gag_permission.Permission.deserialize, @@ -286,7 +372,7 @@ def get_permission( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_permission" not in self._stubs: - self._stubs["get_permission"] = self.grpc_channel.unary_unary( + self._stubs["get_permission"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.PermissionService/GetPermission", request_serializer=permission_service.GetPermissionRequest.serialize, response_deserializer=permission.Permission.deserialize, @@ -315,7 +401,7 @@ def list_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_permissions" not in self._stubs: - self._stubs["list_permissions"] = self.grpc_channel.unary_unary( + self._stubs["list_permissions"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.PermissionService/ListPermissions", request_serializer=permission_service.ListPermissionsRequest.serialize, response_deserializer=permission_service.ListPermissionsResponse.deserialize, @@ -343,7 +429,7 @@ def update_permission( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_permission" not in self._stubs: - self._stubs["update_permission"] = self.grpc_channel.unary_unary( + self._stubs["update_permission"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.PermissionService/UpdatePermission", request_serializer=permission_service.UpdatePermissionRequest.serialize, response_deserializer=gag_permission.Permission.deserialize, @@ -369,7 +455,7 @@ def delete_permission( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_permission" not in self._stubs: - self._stubs["delete_permission"] = self.grpc_channel.unary_unary( + self._stubs["delete_permission"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.PermissionService/DeletePermission", request_serializer=permission_service.DeletePermissionRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -401,7 +487,7 @@ def transfer_ownership( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "transfer_ownership" not in self._stubs: - self._stubs["transfer_ownership"] = self.grpc_channel.unary_unary( + self._stubs["transfer_ownership"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.PermissionService/TransferOwnership", request_serializer=permission_service.TransferOwnershipRequest.serialize, response_deserializer=permission_service.TransferOwnershipResponse.deserialize, @@ -409,7 +495,7 @@ def transfer_ownership( return self._stubs["transfer_ownership"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -421,7 +507,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -440,7 +526,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/permission_service/transports/grpc_asyncio.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/permission_service/transports/grpc_asyncio.py index 5552e15db2fd..88ad80e25c8b 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/permission_service/transports/grpc_asyncio.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/permission_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.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.ai.generativelanguage_v1beta.types import permission as gag_permission from google.ai.generativelanguage_v1beta.types import permission @@ -34,6 +40,82 @@ from .base import DEFAULT_CLIENT_INFO, PermissionServiceTransport from .grpc import PermissionServiceGrpcTransport +try: + from google.api_core import client_logging # 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.ai.generativelanguage.v1beta.PermissionService", + "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.ai.generativelanguage.v1beta.PermissionService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class PermissionServiceGrpcAsyncIOTransport(PermissionServiceTransport): """gRPC AsyncIO backend transport for PermissionService. @@ -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_permission( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_permission" not in self._stubs: - self._stubs["create_permission"] = self.grpc_channel.unary_unary( + self._stubs["create_permission"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.PermissionService/CreatePermission", request_serializer=permission_service.CreatePermissionRequest.serialize, response_deserializer=gag_permission.Permission.deserialize, @@ -297,7 +382,7 @@ def get_permission( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_permission" not in self._stubs: - self._stubs["get_permission"] = self.grpc_channel.unary_unary( + self._stubs["get_permission"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.PermissionService/GetPermission", request_serializer=permission_service.GetPermissionRequest.serialize, response_deserializer=permission.Permission.deserialize, @@ -326,7 +411,7 @@ def list_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_permissions" not in self._stubs: - self._stubs["list_permissions"] = self.grpc_channel.unary_unary( + self._stubs["list_permissions"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.PermissionService/ListPermissions", request_serializer=permission_service.ListPermissionsRequest.serialize, response_deserializer=permission_service.ListPermissionsResponse.deserialize, @@ -355,7 +440,7 @@ def update_permission( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_permission" not in self._stubs: - self._stubs["update_permission"] = self.grpc_channel.unary_unary( + self._stubs["update_permission"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.PermissionService/UpdatePermission", request_serializer=permission_service.UpdatePermissionRequest.serialize, response_deserializer=gag_permission.Permission.deserialize, @@ -383,7 +468,7 @@ def delete_permission( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_permission" not in self._stubs: - self._stubs["delete_permission"] = self.grpc_channel.unary_unary( + self._stubs["delete_permission"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.PermissionService/DeletePermission", request_serializer=permission_service.DeletePermissionRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -415,7 +500,7 @@ def transfer_ownership( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "transfer_ownership" not in self._stubs: - self._stubs["transfer_ownership"] = self.grpc_channel.unary_unary( + self._stubs["transfer_ownership"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.PermissionService/TransferOwnership", request_serializer=permission_service.TransferOwnershipRequest.serialize, response_deserializer=permission_service.TransferOwnershipResponse.deserialize, @@ -518,7 +603,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: @@ -534,7 +619,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -553,7 +638,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-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/permission_service/transports/rest.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/permission_service/transports/rest.py index 8911a0642c8f..8c8f5528a444 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/permission_service/transports/rest.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/permission_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, @@ -117,8 +125,11 @@ def post_update_permission(self, response): def pre_create_permission( self, request: permission_service.CreatePermissionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[permission_service.CreatePermissionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + permission_service.CreatePermissionRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_permission Override in a subclass to manipulate the request or metadata @@ -140,8 +151,11 @@ def post_create_permission( def pre_delete_permission( self, request: permission_service.DeletePermissionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[permission_service.DeletePermissionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + permission_service.DeletePermissionRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_permission Override in a subclass to manipulate the request or metadata @@ -152,8 +166,10 @@ def pre_delete_permission( def pre_get_permission( self, request: permission_service.GetPermissionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[permission_service.GetPermissionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + permission_service.GetPermissionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_permission Override in a subclass to manipulate the request or metadata @@ -175,8 +191,11 @@ def post_get_permission( def pre_list_permissions( self, request: permission_service.ListPermissionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[permission_service.ListPermissionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + permission_service.ListPermissionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_permissions Override in a subclass to manipulate the request or metadata @@ -198,8 +217,11 @@ def post_list_permissions( def pre_transfer_ownership( self, request: permission_service.TransferOwnershipRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[permission_service.TransferOwnershipRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + permission_service.TransferOwnershipRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for transfer_ownership Override in a subclass to manipulate the request or metadata @@ -221,8 +243,11 @@ def post_transfer_ownership( def pre_update_permission( self, request: permission_service.UpdatePermissionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[permission_service.UpdatePermissionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + permission_service.UpdatePermissionRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_permission Override in a subclass to manipulate the request or metadata @@ -244,8 +269,10 @@ def post_update_permission( 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 @@ -267,8 +294,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 @@ -411,7 +440,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gag_permission.Permission: r"""Call the create permission method over HTTP. @@ -421,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: ~.gag_permission.Permission: @@ -455,6 +486,7 @@ def __call__( http_options = ( _BasePermissionServiceRestTransport._BaseCreatePermission._get_http_options() ) + request, metadata = self._interceptor.pre_create_permission( request, metadata ) @@ -471,6 +503,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.PermissionServiceClient.CreatePermission", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.PermissionService", + "rpcName": "CreatePermission", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PermissionServiceRestTransport._CreatePermission._get_response( self._host, @@ -492,7 +551,29 @@ def __call__( pb_resp = gag_permission.Permission.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_permission(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gag_permission.Permission.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.PermissionServiceClient.create_permission", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.PermissionService", + "rpcName": "CreatePermission", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeletePermission( @@ -530,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]]] = (), ): r"""Call the delete permission method over HTTP. @@ -540,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 = ( _BasePermissionServiceRestTransport._BaseDeletePermission._get_http_options() ) + request, metadata = self._interceptor.pre_delete_permission( request, metadata ) @@ -559,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.ai.generativelanguage_v1beta.PermissionServiceClient.DeletePermission", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.PermissionService", + "rpcName": "DeletePermission", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PermissionServiceRestTransport._DeletePermission._get_response( self._host, @@ -609,7 +720,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> permission.Permission: r"""Call the get permission method over HTTP. @@ -620,8 +731,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.permission.Permission: @@ -654,6 +767,7 @@ def __call__( http_options = ( _BasePermissionServiceRestTransport._BaseGetPermission._get_http_options() ) + request, metadata = self._interceptor.pre_get_permission(request, metadata) transcoded_request = _BasePermissionServiceRestTransport._BaseGetPermission._get_transcoded_request( http_options, request @@ -664,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.ai.generativelanguage_v1beta.PermissionServiceClient.GetPermission", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.PermissionService", + "rpcName": "GetPermission", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PermissionServiceRestTransport._GetPermission._get_response( self._host, @@ -684,7 +825,29 @@ def __call__( pb_resp = permission.Permission.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_permission(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = permission.Permission.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.PermissionServiceClient.get_permission", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.PermissionService", + "rpcName": "GetPermission", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListPermissions( @@ -722,7 +885,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> permission_service.ListPermissionsResponse: r"""Call the list permissions method over HTTP. @@ -732,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: ~.permission_service.ListPermissionsResponse: @@ -745,6 +910,7 @@ def __call__( http_options = ( _BasePermissionServiceRestTransport._BaseListPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_list_permissions( request, metadata ) @@ -757,6 +923,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.PermissionServiceClient.ListPermissions", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.PermissionService", + "rpcName": "ListPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PermissionServiceRestTransport._ListPermissions._get_response( self._host, @@ -777,7 +970,31 @@ def __call__( pb_resp = permission_service.ListPermissionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_permissions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + permission_service.ListPermissionsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.PermissionServiceClient.list_permissions", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.PermissionService", + "rpcName": "ListPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TransferOwnership( @@ -816,7 +1033,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> permission_service.TransferOwnershipResponse: r"""Call the transfer ownership method over HTTP. @@ -827,8 +1044,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.permission_service.TransferOwnershipResponse: @@ -838,6 +1057,7 @@ def __call__( http_options = ( _BasePermissionServiceRestTransport._BaseTransferOwnership._get_http_options() ) + request, metadata = self._interceptor.pre_transfer_ownership( request, metadata ) @@ -854,6 +1074,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.PermissionServiceClient.TransferOwnership", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.PermissionService", + "rpcName": "TransferOwnership", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PermissionServiceRestTransport._TransferOwnership._get_response( self._host, @@ -875,7 +1122,31 @@ def __call__( pb_resp = permission_service.TransferOwnershipResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_transfer_ownership(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + permission_service.TransferOwnershipResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.PermissionServiceClient.transfer_ownership", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.PermissionService", + "rpcName": "TransferOwnership", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdatePermission( @@ -914,7 +1185,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gag_permission.Permission: r"""Call the update permission method over HTTP. @@ -924,8 +1195,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gag_permission.Permission: @@ -958,6 +1231,7 @@ def __call__( http_options = ( _BasePermissionServiceRestTransport._BaseUpdatePermission._get_http_options() ) + request, metadata = self._interceptor.pre_update_permission( request, metadata ) @@ -974,6 +1248,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.PermissionServiceClient.UpdatePermission", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.PermissionService", + "rpcName": "UpdatePermission", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PermissionServiceRestTransport._UpdatePermission._get_response( self._host, @@ -995,7 +1296,29 @@ def __call__( pb_resp = gag_permission.Permission.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_permission(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gag_permission.Permission.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.PermissionServiceClient.update_permission", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.PermissionService", + "rpcName": "UpdatePermission", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1094,7 +1417,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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. @@ -1104,8 +1427,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: operations_pb2.Operation: Response from GetOperation method. @@ -1114,6 +1439,7 @@ def __call__( http_options = ( _BasePermissionServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BasePermissionServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1124,6 +1450,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.PermissionServiceClient.GetOperation", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.PermissionService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PermissionServiceRestTransport._GetOperation._get_response( self._host, @@ -1143,6 +1496,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.ai.generativelanguage_v1beta.PermissionServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.PermissionService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1184,7 +1558,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1194,8 +1568,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must 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. @@ -1204,6 +1580,7 @@ def __call__( http_options = ( _BasePermissionServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BasePermissionServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1214,6 +1591,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.PermissionServiceClient.ListOperations", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.PermissionService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PermissionServiceRestTransport._ListOperations._get_response( self._host, @@ -1233,6 +1637,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.ai.generativelanguage_v1beta.PermissionServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.PermissionService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/prediction_service/async_client.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/prediction_service/async_client.py index 3e615bb35e09..92b9d5bddef5 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/prediction_service/async_client.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/prediction_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -51,6 +52,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, PredictionServiceTransport from .transports.grpc_asyncio import PredictionServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class PredictionServiceAsyncClient: """A service for online predictions and explanations.""" @@ -260,6 +270,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.ai.generativelanguage_v1beta.PredictionServiceAsyncClient`.", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.PredictionService", + "universeDomain": getattr( + self._client._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._client._transport._credentials).__module__}.{type(self._client._transport._credentials).__qualname__}", + "credentialsInfo": getattr( + self.transport._credentials, "get_cred_info", lambda: None + )(), + } + if hasattr(self._client._transport, "_credentials") + else { + "serviceName": "google.ai.generativelanguage.v1beta.PredictionService", + "credentialsType": None, + }, + ) + async def predict( self, request: Optional[Union[prediction_service.PredictRequest, dict]] = None, @@ -268,7 +300,7 @@ async def predict( instances: Optional[MutableSequence[struct_pb2.Value]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> prediction_service.PredictResponse: r"""Performs a prediction request. @@ -323,8 +355,10 @@ async def sample_predict(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.PredictResponse: @@ -382,7 +416,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. @@ -393,8 +427,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. @@ -435,7 +471,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. @@ -446,8 +482,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-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/prediction_service/client.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/prediction_service/client.py index 4fd8e80cd792..38034e60d0d8 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/prediction_service/client.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/prediction_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + from google.longrunning import operations_pb2 # type: ignore from google.protobuf import struct_pb2 # type: ignore @@ -577,6 +587,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -643,6 +657,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.ai.generativelanguage_v1beta.PredictionServiceClient`.", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.PredictionService", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__module__}.{type(self._transport._credentials).__qualname__}", + "credentialsInfo": getattr( + self.transport._credentials, "get_cred_info", lambda: None + )(), + } + if hasattr(self._transport, "_credentials") + else { + "serviceName": "google.ai.generativelanguage.v1beta.PredictionService", + "credentialsType": None, + }, + ) + def predict( self, request: Optional[Union[prediction_service.PredictRequest, dict]] = None, @@ -651,7 +688,7 @@ def predict( instances: Optional[MutableSequence[struct_pb2.Value]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> prediction_service.PredictResponse: r"""Performs a prediction request. @@ -706,8 +743,10 @@ def sample_predict(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.PredictResponse: @@ -777,7 +816,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. @@ -788,8 +827,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. @@ -830,7 +871,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. @@ -841,8 +882,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-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/prediction_service/transports/grpc.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/prediction_service/transports/grpc.py index d64d6dfa2747..ff1ea9d7d693 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/prediction_service/transports/grpc.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/prediction_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.ai.generativelanguage_v1beta.types import prediction_service from .base import DEFAULT_CLIENT_INFO, PredictionServiceTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + + +class _LoggingClientInterceptor(grpc.UnaryUnaryClientInterceptor): # pragma: NO COVER + def intercept_unary_unary(self, continuation, client_call_details, request): + logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ) + if logging_enabled: # pragma: NO COVER + request_metadata = client_call_details.metadata + if isinstance(request, proto.Message): + request_payload = type(request).to_json(request) + elif isinstance(request, google.protobuf.message.Message): + request_payload = MessageToJson(request) + else: + request_payload = f"{type(request).__name__}: {pickle.dumps(request)}" + + request_metadata = { + key: value.decode("utf-8") if isinstance(value, bytes) else value + for key, value in request_metadata + } + grpc_request = { + "payload": request_payload, + "requestMethod": "grpc", + "metadata": dict(request_metadata), + } + _LOGGER.debug( + f"Sending request for {client_call_details.method}", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.PredictionService", + "rpcName": client_call_details.method, + "request": grpc_request, + "metadata": grpc_request["metadata"], + }, + ) + + response = continuation(client_call_details, request) + if logging_enabled: # pragma: NO COVER + response_metadata = response.trailing_metadata() + # Convert gRPC metadata `` to list of tuples + metadata = ( + dict([(k, str(v)) for k, v in response_metadata]) + if response_metadata + else None + ) + result = response.result() + if isinstance(result, proto.Message): + response_payload = type(result).to_json(result) + elif isinstance(result, google.protobuf.message.Message): + response_payload = MessageToJson(result) + else: + response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" + grpc_response = { + "payload": response_payload, + "metadata": metadata, + "status": "OK", + } + _LOGGER.debug( + f"Received response for {client_call_details.method}.", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.PredictionService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class PredictionServiceGrpcTransport(PredictionServiceTransport): """gRPC backend transport for PredictionService. @@ -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 predict( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "predict" not in self._stubs: - self._stubs["predict"] = self.grpc_channel.unary_unary( + self._stubs["predict"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.PredictionService/Predict", request_serializer=prediction_service.PredictRequest.serialize, response_deserializer=prediction_service.PredictResponse.deserialize, @@ -264,7 +350,7 @@ def predict( return self._stubs["predict"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -276,7 +362,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, @@ -295,7 +381,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-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/prediction_service/transports/grpc_asyncio.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/prediction_service/transports/grpc_asyncio.py index 23a47b5875c3..58c84f198a1d 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/prediction_service/transports/grpc_asyncio.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/prediction_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.ai.generativelanguage_v1beta.types import prediction_service from .base import DEFAULT_CLIENT_INFO, PredictionServiceTransport from .grpc import PredictionServiceGrpcTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + + +class _LoggingClientAIOInterceptor( + grpc.aio.UnaryUnaryClientInterceptor +): # pragma: NO COVER + async def intercept_unary_unary(self, continuation, client_call_details, request): + logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ) + if logging_enabled: # pragma: NO COVER + request_metadata = client_call_details.metadata + if isinstance(request, proto.Message): + request_payload = type(request).to_json(request) + elif isinstance(request, google.protobuf.message.Message): + request_payload = MessageToJson(request) + else: + request_payload = f"{type(request).__name__}: {pickle.dumps(request)}" + + request_metadata = { + key: value.decode("utf-8") if isinstance(value, bytes) else value + for key, value in request_metadata + } + grpc_request = { + "payload": request_payload, + "requestMethod": "grpc", + "metadata": dict(request_metadata), + } + _LOGGER.debug( + f"Sending request for {client_call_details.method}", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.PredictionService", + "rpcName": str(client_call_details.method), + "request": grpc_request, + "metadata": grpc_request["metadata"], + }, + ) + response = await continuation(client_call_details, request) + if logging_enabled: # pragma: NO COVER + response_metadata = await response.trailing_metadata() + # Convert gRPC metadata `` to list of tuples + metadata = ( + dict([(k, str(v)) for k, v in response_metadata]) + if response_metadata + else None + ) + result = await response + if isinstance(result, proto.Message): + response_payload = type(result).to_json(result) + elif isinstance(result, google.protobuf.message.Message): + response_payload = MessageToJson(result) + else: + response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" + grpc_response = { + "payload": response_payload, + "metadata": metadata, + "status": "OK", + } + _LOGGER.debug( + f"Received response to rpc {client_call_details.method}.", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.PredictionService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class PredictionServiceGrpcAsyncIOTransport(PredictionServiceTransport): """gRPC AsyncIO backend transport for PredictionService. @@ -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 predict( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "predict" not in self._stubs: - self._stubs["predict"] = self.grpc_channel.unary_unary( + self._stubs["predict"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.PredictionService/Predict", request_serializer=prediction_service.PredictRequest.serialize, response_deserializer=prediction_service.PredictResponse.deserialize, @@ -298,7 +383,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: @@ -314,7 +399,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, @@ -333,7 +418,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-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/prediction_service/transports/rest.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/prediction_service/transports/rest.py index 7eb5a102895b..dcd026c2e771 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/prediction_service/transports/rest.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/prediction_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = logging.getLogger(__name__) DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, @@ -78,8 +86,10 @@ def post_predict(self, response): def pre_predict( self, request: prediction_service.PredictRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[prediction_service.PredictRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + prediction_service.PredictRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for predict Override in a subclass to manipulate the request or metadata @@ -101,8 +111,10 @@ def post_predict( 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 @@ -124,8 +136,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 @@ -266,7 +280,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> prediction_service.PredictResponse: r"""Call the predict method over HTTP. @@ -277,8 +291,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.prediction_service.PredictResponse: @@ -288,6 +304,7 @@ def __call__( http_options = ( _BasePredictionServiceRestTransport._BasePredict._get_http_options() ) + request, metadata = self._interceptor.pre_predict(request, metadata) transcoded_request = _BasePredictionServiceRestTransport._BasePredict._get_transcoded_request( http_options, request @@ -306,6 +323,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.PredictionServiceClient.Predict", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.PredictionService", + "rpcName": "Predict", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PredictionServiceRestTransport._Predict._get_response( self._host, @@ -327,7 +371,31 @@ def __call__( pb_resp = prediction_service.PredictResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_predict(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = prediction_service.PredictResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.PredictionServiceClient.predict", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.PredictionService", + "rpcName": "Predict", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -378,7 +446,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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. @@ -388,8 +456,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -398,6 +468,7 @@ def __call__( http_options = ( _BasePredictionServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BasePredictionServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -408,6 +479,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.PredictionServiceClient.GetOperation", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.PredictionService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PredictionServiceRestTransport._GetOperation._get_response( self._host, @@ -427,6 +525,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.ai.generativelanguage_v1beta.PredictionServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.PredictionService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -468,7 +587,7 @@ def __call__( *, 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. @@ -478,8 +597,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must 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. @@ -488,6 +609,7 @@ def __call__( http_options = ( _BasePredictionServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BasePredictionServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -498,6 +620,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.PredictionServiceClient.ListOperations", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.PredictionService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PredictionServiceRestTransport._ListOperations._get_response( self._host, @@ -517,6 +666,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.ai.generativelanguage_v1beta.PredictionServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.PredictionService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/retriever_service/async_client.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/retriever_service/async_client.py index 012a3188e1c2..684e3ae77592 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/retriever_service/async_client.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/retriever_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, RetrieverServiceTransport from .transports.grpc_asyncio import RetrieverServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class RetrieverServiceAsyncClient: """An API for semantic search over a corpus of user uploaded @@ -266,6 +276,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.ai.generativelanguage_v1beta.RetrieverServiceAsyncClient`.", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "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.ai.generativelanguage.v1beta.RetrieverService", + "credentialsType": None, + }, + ) + async def create_corpus( self, request: Optional[Union[retriever_service.CreateCorpusRequest, dict]] = None, @@ -273,7 +305,7 @@ async def create_corpus( corpus: Optional[retriever.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]]] = (), ) -> retriever.Corpus: r"""Creates an empty ``Corpus``. @@ -313,8 +345,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.ai.generativelanguage_v1beta.types.Corpus: @@ -369,7 +403,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]]] = (), ) -> retriever.Corpus: r"""Gets information about a specific ``Corpus``. @@ -413,8 +447,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.ai.generativelanguage_v1beta.types.Corpus: @@ -476,7 +512,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]]] = (), ) -> retriever.Corpus: r"""Updates a ``Corpus``. @@ -523,8 +559,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.ai.generativelanguage_v1beta.types.Corpus: @@ -589,7 +627,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``. @@ -629,8 +667,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 @@ -681,7 +721,7 @@ async def list_corpora( *, retry: OptionalRetry = gapic_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`` owned by the user. @@ -717,8 +757,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.ai.generativelanguage_v1beta.services.retriever_service.pagers.ListCorporaAsyncPager: @@ -773,7 +815,7 @@ async def query_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]]] = (), ) -> retriever_service.QueryCorpusResponse: r"""Performs semantic search over a ``Corpus``. @@ -810,8 +852,10 @@ async def sample_query_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.ai.generativelanguage_v1beta.types.QueryCorpusResponse: @@ -859,7 +903,7 @@ async def create_document( document: Optional[retriever.Document] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> retriever.Document: r"""Creates an empty ``Document``. @@ -908,8 +952,10 @@ async def sample_create_document(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.Document: @@ -972,7 +1018,7 @@ async def get_document( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> retriever.Document: r"""Gets information about a specific ``Document``. @@ -1016,8 +1062,10 @@ async def sample_get_document(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.Document: @@ -1079,7 +1127,7 @@ async def update_document( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> retriever.Document: r"""Updates a ``Document``. @@ -1127,8 +1175,10 @@ async def sample_update_document(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.Document: @@ -1193,7 +1243,7 @@ async def delete_document( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a ``Document``. @@ -1234,8 +1284,10 @@ async def sample_delete_document(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1287,7 +1339,7 @@ async def list_documents( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDocumentsAsyncPager: r"""Lists all ``Document``\ s in a ``Corpus``. @@ -1331,8 +1383,10 @@ async def sample_list_documents(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.services.retriever_service.pagers.ListDocumentsAsyncPager: @@ -1407,7 +1461,7 @@ async def query_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]]] = (), ) -> retriever_service.QueryDocumentResponse: r"""Performs semantic search over a ``Document``. @@ -1444,8 +1498,10 @@ async def sample_query_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.ai.generativelanguage_v1beta.types.QueryDocumentResponse: @@ -1493,7 +1549,7 @@ async def create_chunk( chunk: Optional[retriever.Chunk] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> retriever.Chunk: r"""Creates a ``Chunk``. @@ -1546,8 +1602,10 @@ async def sample_create_chunk(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.Chunk: @@ -1613,7 +1671,7 @@ async def batch_create_chunks( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> retriever_service.BatchCreateChunksResponse: r"""Batch create ``Chunk``\ s. @@ -1653,8 +1711,10 @@ async def sample_batch_create_chunks(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.BatchCreateChunksResponse: @@ -1701,7 +1761,7 @@ async def get_chunk( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> retriever.Chunk: r"""Gets information about a specific ``Chunk``. @@ -1746,8 +1806,10 @@ async def sample_get_chunk(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.Chunk: @@ -1811,7 +1873,7 @@ async def update_chunk( 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]]] = (), ) -> retriever.Chunk: r"""Updates a ``Chunk``. @@ -1862,8 +1924,10 @@ async def sample_update_chunk(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.Chunk: @@ -1931,7 +1995,7 @@ async def batch_update_chunks( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> retriever_service.BatchUpdateChunksResponse: r"""Batch update ``Chunk``\ s. @@ -1970,8 +2034,10 @@ async def sample_batch_update_chunks(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.BatchUpdateChunksResponse: @@ -2018,7 +2084,7 @@ async def delete_chunk( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 ``Chunk``. @@ -2059,8 +2125,10 @@ async def sample_delete_chunk(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -2113,7 +2181,7 @@ async def batch_delete_chunks( *, retry: OptionalRetry = gapic_v1.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 delete ``Chunk``\ s. @@ -2149,8 +2217,10 @@ async def sample_batch_delete_chunks(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -2188,7 +2258,7 @@ async def list_chunks( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListChunksAsyncPager: r"""Lists all ``Chunk``\ s in a ``Document``. @@ -2233,8 +2303,10 @@ async def sample_list_chunks(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.services.retriever_service.pagers.ListChunksAsyncPager: @@ -2308,7 +2380,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. @@ -2319,8 +2391,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. @@ -2361,7 +2435,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. @@ -2372,8 +2446,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-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/retriever_service/client.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/retriever_service/client.py index 1f90ed6a4239..61d6ebc8278a 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/retriever_service/client.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/retriever_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.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -618,6 +628,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -684,6 +698,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.ai.generativelanguage_v1beta.RetrieverServiceClient`.", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "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.ai.generativelanguage.v1beta.RetrieverService", + "credentialsType": None, + }, + ) + def create_corpus( self, request: Optional[Union[retriever_service.CreateCorpusRequest, dict]] = None, @@ -691,7 +728,7 @@ def create_corpus( corpus: Optional[retriever.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]]] = (), ) -> retriever.Corpus: r"""Creates an empty ``Corpus``. @@ -731,8 +768,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.ai.generativelanguage_v1beta.types.Corpus: @@ -784,7 +823,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]]] = (), ) -> retriever.Corpus: r"""Gets information about a specific ``Corpus``. @@ -828,8 +867,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.ai.generativelanguage_v1beta.types.Corpus: @@ -888,7 +929,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]]] = (), ) -> retriever.Corpus: r"""Updates a ``Corpus``. @@ -935,8 +976,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.ai.generativelanguage_v1beta.types.Corpus: @@ -998,7 +1041,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``. @@ -1038,8 +1081,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 @@ -1087,7 +1132,7 @@ def list_corpora( *, retry: OptionalRetry = gapic_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`` owned by the user. @@ -1123,8 +1168,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.ai.generativelanguage_v1beta.services.retriever_service.pagers.ListCorporaPager: @@ -1177,7 +1224,7 @@ def query_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]]] = (), ) -> retriever_service.QueryCorpusResponse: r"""Performs semantic search over a ``Corpus``. @@ -1214,8 +1261,10 @@ def sample_query_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.ai.generativelanguage_v1beta.types.QueryCorpusResponse: @@ -1261,7 +1310,7 @@ def create_document( document: Optional[retriever.Document] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> retriever.Document: r"""Creates an empty ``Document``. @@ -1310,8 +1359,10 @@ def sample_create_document(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.Document: @@ -1371,7 +1422,7 @@ def get_document( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> retriever.Document: r"""Gets information about a specific ``Document``. @@ -1415,8 +1466,10 @@ def sample_get_document(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.Document: @@ -1475,7 +1528,7 @@ def update_document( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> retriever.Document: r"""Updates a ``Document``. @@ -1523,8 +1576,10 @@ def sample_update_document(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.Document: @@ -1586,7 +1641,7 @@ def delete_document( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a ``Document``. @@ -1627,8 +1682,10 @@ def sample_delete_document(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1677,7 +1734,7 @@ def list_documents( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDocumentsPager: r"""Lists all ``Document``\ s in a ``Corpus``. @@ -1721,8 +1778,10 @@ def sample_list_documents(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.services.retriever_service.pagers.ListDocumentsPager: @@ -1794,7 +1853,7 @@ def query_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]]] = (), ) -> retriever_service.QueryDocumentResponse: r"""Performs semantic search over a ``Document``. @@ -1831,8 +1890,10 @@ def sample_query_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.ai.generativelanguage_v1beta.types.QueryDocumentResponse: @@ -1878,7 +1939,7 @@ def create_chunk( chunk: Optional[retriever.Chunk] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> retriever.Chunk: r"""Creates a ``Chunk``. @@ -1931,8 +1992,10 @@ def sample_create_chunk(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.Chunk: @@ -1995,7 +2058,7 @@ def batch_create_chunks( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> retriever_service.BatchCreateChunksResponse: r"""Batch create ``Chunk``\ s. @@ -2035,8 +2098,10 @@ def sample_batch_create_chunks(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.BatchCreateChunksResponse: @@ -2081,7 +2146,7 @@ def get_chunk( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> retriever.Chunk: r"""Gets information about a specific ``Chunk``. @@ -2126,8 +2191,10 @@ def sample_get_chunk(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.Chunk: @@ -2188,7 +2255,7 @@ def update_chunk( 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]]] = (), ) -> retriever.Chunk: r"""Updates a ``Chunk``. @@ -2239,8 +2306,10 @@ def sample_update_chunk(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.Chunk: @@ -2305,7 +2374,7 @@ def batch_update_chunks( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> retriever_service.BatchUpdateChunksResponse: r"""Batch update ``Chunk``\ s. @@ -2344,8 +2413,10 @@ def sample_batch_update_chunks(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.BatchUpdateChunksResponse: @@ -2390,7 +2461,7 @@ def delete_chunk( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 ``Chunk``. @@ -2431,8 +2502,10 @@ def sample_delete_chunk(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -2482,7 +2555,7 @@ def batch_delete_chunks( *, retry: OptionalRetry = gapic_v1.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 delete ``Chunk``\ s. @@ -2518,8 +2591,10 @@ def sample_batch_delete_chunks(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -2555,7 +2630,7 @@ def list_chunks( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListChunksPager: r"""Lists all ``Chunk``\ s in a ``Document``. @@ -2600,8 +2675,10 @@ def sample_list_chunks(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.services.retriever_service.pagers.ListChunksPager: @@ -2685,7 +2762,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. @@ -2696,8 +2773,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. @@ -2738,7 +2817,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. @@ -2749,8 +2828,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-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/retriever_service/pagers.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/retriever_service/pagers.py index 6108818f2099..322b16c25743 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/retriever_service/pagers.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/retriever_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 = retriever_service.ListCorporaRequest(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 = retriever_service.ListCorporaRequest(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 = retriever_service.ListDocumentsRequest(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 = retriever_service.ListDocumentsRequest(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 = retriever_service.ListChunksRequest(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 = retriever_service.ListChunksRequest(request) diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/retriever_service/transports/grpc.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/retriever_service/transports/grpc.py index c576e4b620f8..7b8347ca4567 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/retriever_service/transports/grpc.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/retriever_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.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.ai.generativelanguage_v1beta.types import retriever, retriever_service from .base import DEFAULT_CLIENT_INFO, RetrieverServiceTransport +try: + from google.api_core import client_logging # 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.ai.generativelanguage.v1beta.RetrieverService", + "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.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class RetrieverServiceGrpcTransport(RetrieverServiceTransport): """gRPC backend transport for RetrieverService. @@ -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 @@ -256,7 +342,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.ai.generativelanguage.v1beta.RetrieverService/CreateCorpus", request_serializer=retriever_service.CreateCorpusRequest.serialize, response_deserializer=retriever.Corpus.deserialize, @@ -282,7 +368,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.ai.generativelanguage.v1beta.RetrieverService/GetCorpus", request_serializer=retriever_service.GetCorpusRequest.serialize, response_deserializer=retriever.Corpus.deserialize, @@ -308,7 +394,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.ai.generativelanguage.v1beta.RetrieverService/UpdateCorpus", request_serializer=retriever_service.UpdateCorpusRequest.serialize, response_deserializer=retriever.Corpus.deserialize, @@ -334,7 +420,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.ai.generativelanguage.v1beta.RetrieverService/DeleteCorpus", request_serializer=retriever_service.DeleteCorpusRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -362,7 +448,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.ai.generativelanguage.v1beta.RetrieverService/ListCorpora", request_serializer=retriever_service.ListCorporaRequest.serialize, response_deserializer=retriever_service.ListCorporaResponse.deserialize, @@ -390,7 +476,7 @@ def query_corpus( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "query_corpus" not in self._stubs: - self._stubs["query_corpus"] = self.grpc_channel.unary_unary( + self._stubs["query_corpus"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.RetrieverService/QueryCorpus", request_serializer=retriever_service.QueryCorpusRequest.serialize, response_deserializer=retriever_service.QueryCorpusResponse.deserialize, @@ -416,7 +502,7 @@ def create_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_document" not in self._stubs: - self._stubs["create_document"] = self.grpc_channel.unary_unary( + self._stubs["create_document"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.RetrieverService/CreateDocument", request_serializer=retriever_service.CreateDocumentRequest.serialize, response_deserializer=retriever.Document.deserialize, @@ -442,7 +528,7 @@ def get_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_document" not in self._stubs: - self._stubs["get_document"] = self.grpc_channel.unary_unary( + self._stubs["get_document"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.RetrieverService/GetDocument", request_serializer=retriever_service.GetDocumentRequest.serialize, response_deserializer=retriever.Document.deserialize, @@ -468,7 +554,7 @@ def update_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_document" not in self._stubs: - self._stubs["update_document"] = self.grpc_channel.unary_unary( + self._stubs["update_document"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.RetrieverService/UpdateDocument", request_serializer=retriever_service.UpdateDocumentRequest.serialize, response_deserializer=retriever.Document.deserialize, @@ -494,7 +580,7 @@ def delete_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_document" not in self._stubs: - self._stubs["delete_document"] = self.grpc_channel.unary_unary( + self._stubs["delete_document"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.RetrieverService/DeleteDocument", request_serializer=retriever_service.DeleteDocumentRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -523,7 +609,7 @@ def list_documents( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_documents" not in self._stubs: - self._stubs["list_documents"] = self.grpc_channel.unary_unary( + self._stubs["list_documents"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.RetrieverService/ListDocuments", request_serializer=retriever_service.ListDocumentsRequest.serialize, response_deserializer=retriever_service.ListDocumentsResponse.deserialize, @@ -552,7 +638,7 @@ def query_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "query_document" not in self._stubs: - self._stubs["query_document"] = self.grpc_channel.unary_unary( + self._stubs["query_document"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.RetrieverService/QueryDocument", request_serializer=retriever_service.QueryDocumentRequest.serialize, response_deserializer=retriever_service.QueryDocumentResponse.deserialize, @@ -578,7 +664,7 @@ def create_chunk( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_chunk" not in self._stubs: - self._stubs["create_chunk"] = self.grpc_channel.unary_unary( + self._stubs["create_chunk"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.RetrieverService/CreateChunk", request_serializer=retriever_service.CreateChunkRequest.serialize, response_deserializer=retriever.Chunk.deserialize, @@ -607,7 +693,7 @@ def batch_create_chunks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_create_chunks" not in self._stubs: - self._stubs["batch_create_chunks"] = self.grpc_channel.unary_unary( + self._stubs["batch_create_chunks"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.RetrieverService/BatchCreateChunks", request_serializer=retriever_service.BatchCreateChunksRequest.serialize, response_deserializer=retriever_service.BatchCreateChunksResponse.deserialize, @@ -633,7 +719,7 @@ def get_chunk( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_chunk" not in self._stubs: - self._stubs["get_chunk"] = self.grpc_channel.unary_unary( + self._stubs["get_chunk"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.RetrieverService/GetChunk", request_serializer=retriever_service.GetChunkRequest.serialize, response_deserializer=retriever.Chunk.deserialize, @@ -659,7 +745,7 @@ def update_chunk( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_chunk" not in self._stubs: - self._stubs["update_chunk"] = self.grpc_channel.unary_unary( + self._stubs["update_chunk"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.RetrieverService/UpdateChunk", request_serializer=retriever_service.UpdateChunkRequest.serialize, response_deserializer=retriever.Chunk.deserialize, @@ -688,7 +774,7 @@ def batch_update_chunks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_update_chunks" not in self._stubs: - self._stubs["batch_update_chunks"] = self.grpc_channel.unary_unary( + self._stubs["batch_update_chunks"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.RetrieverService/BatchUpdateChunks", request_serializer=retriever_service.BatchUpdateChunksRequest.serialize, response_deserializer=retriever_service.BatchUpdateChunksResponse.deserialize, @@ -714,7 +800,7 @@ def delete_chunk( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_chunk" not in self._stubs: - self._stubs["delete_chunk"] = self.grpc_channel.unary_unary( + self._stubs["delete_chunk"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.RetrieverService/DeleteChunk", request_serializer=retriever_service.DeleteChunkRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -740,7 +826,7 @@ def batch_delete_chunks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_delete_chunks" not in self._stubs: - self._stubs["batch_delete_chunks"] = self.grpc_channel.unary_unary( + self._stubs["batch_delete_chunks"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.RetrieverService/BatchDeleteChunks", request_serializer=retriever_service.BatchDeleteChunksRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -768,7 +854,7 @@ def list_chunks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_chunks" not in self._stubs: - self._stubs["list_chunks"] = self.grpc_channel.unary_unary( + self._stubs["list_chunks"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.RetrieverService/ListChunks", request_serializer=retriever_service.ListChunksRequest.serialize, response_deserializer=retriever_service.ListChunksResponse.deserialize, @@ -776,7 +862,7 @@ def list_chunks( return self._stubs["list_chunks"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -788,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, @@ -807,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-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/retriever_service/transports/grpc_asyncio.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/retriever_service/transports/grpc_asyncio.py index 9295a03282dc..233b94eda9df 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/retriever_service/transports/grpc_asyncio.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/retriever_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.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.ai.generativelanguage_v1beta.types import retriever, retriever_service from .base import DEFAULT_CLIENT_INFO, RetrieverServiceTransport from .grpc import RetrieverServiceGrpcTransport +try: + from google.api_core import client_logging # 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.ai.generativelanguage.v1beta.RetrieverService", + "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.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class RetrieverServiceGrpcAsyncIOTransport(RetrieverServiceTransport): """gRPC AsyncIO backend transport for RetrieverService. @@ -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 @@ -264,7 +349,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.ai.generativelanguage.v1beta.RetrieverService/CreateCorpus", request_serializer=retriever_service.CreateCorpusRequest.serialize, response_deserializer=retriever.Corpus.deserialize, @@ -290,7 +375,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.ai.generativelanguage.v1beta.RetrieverService/GetCorpus", request_serializer=retriever_service.GetCorpusRequest.serialize, response_deserializer=retriever.Corpus.deserialize, @@ -316,7 +401,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.ai.generativelanguage.v1beta.RetrieverService/UpdateCorpus", request_serializer=retriever_service.UpdateCorpusRequest.serialize, response_deserializer=retriever.Corpus.deserialize, @@ -342,7 +427,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.ai.generativelanguage.v1beta.RetrieverService/DeleteCorpus", request_serializer=retriever_service.DeleteCorpusRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -371,7 +456,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.ai.generativelanguage.v1beta.RetrieverService/ListCorpora", request_serializer=retriever_service.ListCorporaRequest.serialize, response_deserializer=retriever_service.ListCorporaResponse.deserialize, @@ -400,7 +485,7 @@ def query_corpus( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "query_corpus" not in self._stubs: - self._stubs["query_corpus"] = self.grpc_channel.unary_unary( + self._stubs["query_corpus"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.RetrieverService/QueryCorpus", request_serializer=retriever_service.QueryCorpusRequest.serialize, response_deserializer=retriever_service.QueryCorpusResponse.deserialize, @@ -428,7 +513,7 @@ def create_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_document" not in self._stubs: - self._stubs["create_document"] = self.grpc_channel.unary_unary( + self._stubs["create_document"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.RetrieverService/CreateDocument", request_serializer=retriever_service.CreateDocumentRequest.serialize, response_deserializer=retriever.Document.deserialize, @@ -456,7 +541,7 @@ def get_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_document" not in self._stubs: - self._stubs["get_document"] = self.grpc_channel.unary_unary( + self._stubs["get_document"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.RetrieverService/GetDocument", request_serializer=retriever_service.GetDocumentRequest.serialize, response_deserializer=retriever.Document.deserialize, @@ -484,7 +569,7 @@ def update_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_document" not in self._stubs: - self._stubs["update_document"] = self.grpc_channel.unary_unary( + self._stubs["update_document"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.RetrieverService/UpdateDocument", request_serializer=retriever_service.UpdateDocumentRequest.serialize, response_deserializer=retriever.Document.deserialize, @@ -512,7 +597,7 @@ def delete_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_document" not in self._stubs: - self._stubs["delete_document"] = self.grpc_channel.unary_unary( + self._stubs["delete_document"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.RetrieverService/DeleteDocument", request_serializer=retriever_service.DeleteDocumentRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -541,7 +626,7 @@ def list_documents( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_documents" not in self._stubs: - self._stubs["list_documents"] = self.grpc_channel.unary_unary( + self._stubs["list_documents"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.RetrieverService/ListDocuments", request_serializer=retriever_service.ListDocumentsRequest.serialize, response_deserializer=retriever_service.ListDocumentsResponse.deserialize, @@ -570,7 +655,7 @@ def query_document( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "query_document" not in self._stubs: - self._stubs["query_document"] = self.grpc_channel.unary_unary( + self._stubs["query_document"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.RetrieverService/QueryDocument", request_serializer=retriever_service.QueryDocumentRequest.serialize, response_deserializer=retriever_service.QueryDocumentResponse.deserialize, @@ -596,7 +681,7 @@ def create_chunk( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_chunk" not in self._stubs: - self._stubs["create_chunk"] = self.grpc_channel.unary_unary( + self._stubs["create_chunk"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.RetrieverService/CreateChunk", request_serializer=retriever_service.CreateChunkRequest.serialize, response_deserializer=retriever.Chunk.deserialize, @@ -625,7 +710,7 @@ def batch_create_chunks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_create_chunks" not in self._stubs: - self._stubs["batch_create_chunks"] = self.grpc_channel.unary_unary( + self._stubs["batch_create_chunks"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.RetrieverService/BatchCreateChunks", request_serializer=retriever_service.BatchCreateChunksRequest.serialize, response_deserializer=retriever_service.BatchCreateChunksResponse.deserialize, @@ -651,7 +736,7 @@ def get_chunk( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_chunk" not in self._stubs: - self._stubs["get_chunk"] = self.grpc_channel.unary_unary( + self._stubs["get_chunk"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.RetrieverService/GetChunk", request_serializer=retriever_service.GetChunkRequest.serialize, response_deserializer=retriever.Chunk.deserialize, @@ -677,7 +762,7 @@ def update_chunk( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_chunk" not in self._stubs: - self._stubs["update_chunk"] = self.grpc_channel.unary_unary( + self._stubs["update_chunk"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.RetrieverService/UpdateChunk", request_serializer=retriever_service.UpdateChunkRequest.serialize, response_deserializer=retriever.Chunk.deserialize, @@ -706,7 +791,7 @@ def batch_update_chunks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_update_chunks" not in self._stubs: - self._stubs["batch_update_chunks"] = self.grpc_channel.unary_unary( + self._stubs["batch_update_chunks"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.RetrieverService/BatchUpdateChunks", request_serializer=retriever_service.BatchUpdateChunksRequest.serialize, response_deserializer=retriever_service.BatchUpdateChunksResponse.deserialize, @@ -732,7 +817,7 @@ def delete_chunk( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_chunk" not in self._stubs: - self._stubs["delete_chunk"] = self.grpc_channel.unary_unary( + self._stubs["delete_chunk"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.RetrieverService/DeleteChunk", request_serializer=retriever_service.DeleteChunkRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -760,7 +845,7 @@ def batch_delete_chunks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_delete_chunks" not in self._stubs: - self._stubs["batch_delete_chunks"] = self.grpc_channel.unary_unary( + self._stubs["batch_delete_chunks"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.RetrieverService/BatchDeleteChunks", request_serializer=retriever_service.BatchDeleteChunksRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -789,7 +874,7 @@ def list_chunks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_chunks" not in self._stubs: - self._stubs["list_chunks"] = self.grpc_channel.unary_unary( + self._stubs["list_chunks"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.RetrieverService/ListChunks", request_serializer=retriever_service.ListChunksRequest.serialize, response_deserializer=retriever_service.ListChunksResponse.deserialize, @@ -1061,7 +1146,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: @@ -1077,7 +1162,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, @@ -1096,7 +1181,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-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/retriever_service/transports/rest.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/retriever_service/transports/rest.py index 0cec388fcac9..ef7dafcc451e 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/retriever_service/transports/rest.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/retriever_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, @@ -215,8 +223,11 @@ def post_update_document(self, response): def pre_batch_create_chunks( self, request: retriever_service.BatchCreateChunksRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[retriever_service.BatchCreateChunksRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + retriever_service.BatchCreateChunksRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for batch_create_chunks Override in a subclass to manipulate the request or metadata @@ -238,8 +249,11 @@ def post_batch_create_chunks( def pre_batch_delete_chunks( self, request: retriever_service.BatchDeleteChunksRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[retriever_service.BatchDeleteChunksRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + retriever_service.BatchDeleteChunksRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for batch_delete_chunks Override in a subclass to manipulate the request or metadata @@ -250,8 +264,11 @@ def pre_batch_delete_chunks( def pre_batch_update_chunks( self, request: retriever_service.BatchUpdateChunksRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[retriever_service.BatchUpdateChunksRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + retriever_service.BatchUpdateChunksRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for batch_update_chunks Override in a subclass to manipulate the request or metadata @@ -273,8 +290,10 @@ def post_batch_update_chunks( def pre_create_chunk( self, request: retriever_service.CreateChunkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[retriever_service.CreateChunkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + retriever_service.CreateChunkRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_chunk Override in a subclass to manipulate the request or metadata @@ -294,8 +313,10 @@ def post_create_chunk(self, response: retriever.Chunk) -> retriever.Chunk: def pre_create_corpus( self, request: retriever_service.CreateCorpusRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[retriever_service.CreateCorpusRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + retriever_service.CreateCorpusRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_corpus Override in a subclass to manipulate the request or metadata @@ -315,8 +336,10 @@ def post_create_corpus(self, response: retriever.Corpus) -> retriever.Corpus: def pre_create_document( self, request: retriever_service.CreateDocumentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[retriever_service.CreateDocumentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + retriever_service.CreateDocumentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_document Override in a subclass to manipulate the request or metadata @@ -336,8 +359,10 @@ def post_create_document(self, response: retriever.Document) -> retriever.Docume def pre_delete_chunk( self, request: retriever_service.DeleteChunkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[retriever_service.DeleteChunkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + retriever_service.DeleteChunkRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_chunk Override in a subclass to manipulate the request or metadata @@ -348,8 +373,10 @@ def pre_delete_chunk( def pre_delete_corpus( self, request: retriever_service.DeleteCorpusRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[retriever_service.DeleteCorpusRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + retriever_service.DeleteCorpusRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_corpus Override in a subclass to manipulate the request or metadata @@ -360,8 +387,10 @@ def pre_delete_corpus( def pre_delete_document( self, request: retriever_service.DeleteDocumentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[retriever_service.DeleteDocumentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + retriever_service.DeleteDocumentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_document Override in a subclass to manipulate the request or metadata @@ -372,8 +401,10 @@ def pre_delete_document( def pre_get_chunk( self, request: retriever_service.GetChunkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[retriever_service.GetChunkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + retriever_service.GetChunkRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_chunk Override in a subclass to manipulate the request or metadata @@ -393,8 +424,10 @@ def post_get_chunk(self, response: retriever.Chunk) -> retriever.Chunk: def pre_get_corpus( self, request: retriever_service.GetCorpusRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[retriever_service.GetCorpusRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + retriever_service.GetCorpusRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_corpus Override in a subclass to manipulate the request or metadata @@ -414,8 +447,10 @@ def post_get_corpus(self, response: retriever.Corpus) -> retriever.Corpus: def pre_get_document( self, request: retriever_service.GetDocumentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[retriever_service.GetDocumentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + retriever_service.GetDocumentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_document Override in a subclass to manipulate the request or metadata @@ -435,8 +470,10 @@ def post_get_document(self, response: retriever.Document) -> retriever.Document: def pre_list_chunks( self, request: retriever_service.ListChunksRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[retriever_service.ListChunksRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + retriever_service.ListChunksRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_chunks Override in a subclass to manipulate the request or metadata @@ -458,8 +495,10 @@ def post_list_chunks( def pre_list_corpora( self, request: retriever_service.ListCorporaRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[retriever_service.ListCorporaRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + retriever_service.ListCorporaRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_corpora Override in a subclass to manipulate the request or metadata @@ -481,8 +520,10 @@ def post_list_corpora( def pre_list_documents( self, request: retriever_service.ListDocumentsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[retriever_service.ListDocumentsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + retriever_service.ListDocumentsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_documents Override in a subclass to manipulate the request or metadata @@ -504,8 +545,10 @@ def post_list_documents( def pre_query_corpus( self, request: retriever_service.QueryCorpusRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[retriever_service.QueryCorpusRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + retriever_service.QueryCorpusRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for query_corpus Override in a subclass to manipulate the request or metadata @@ -527,8 +570,10 @@ def post_query_corpus( def pre_query_document( self, request: retriever_service.QueryDocumentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[retriever_service.QueryDocumentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + retriever_service.QueryDocumentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for query_document Override in a subclass to manipulate the request or metadata @@ -550,8 +595,10 @@ def post_query_document( def pre_update_chunk( self, request: retriever_service.UpdateChunkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[retriever_service.UpdateChunkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + retriever_service.UpdateChunkRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_chunk Override in a subclass to manipulate the request or metadata @@ -571,8 +618,10 @@ def post_update_chunk(self, response: retriever.Chunk) -> retriever.Chunk: def pre_update_corpus( self, request: retriever_service.UpdateCorpusRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[retriever_service.UpdateCorpusRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + retriever_service.UpdateCorpusRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_corpus Override in a subclass to manipulate the request or metadata @@ -592,8 +641,10 @@ def post_update_corpus(self, response: retriever.Corpus) -> retriever.Corpus: def pre_update_document( self, request: retriever_service.UpdateDocumentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[retriever_service.UpdateDocumentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + retriever_service.UpdateDocumentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_document Override in a subclass to manipulate the request or metadata @@ -613,8 +664,10 @@ def post_update_document(self, response: retriever.Document) -> retriever.Docume 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 @@ -636,8 +689,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 @@ -780,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]]] = (), ) -> retriever_service.BatchCreateChunksResponse: r"""Call the batch create chunks method over HTTP. @@ -790,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: ~.retriever_service.BatchCreateChunksResponse: @@ -803,6 +860,7 @@ def __call__( http_options = ( _BaseRetrieverServiceRestTransport._BaseBatchCreateChunks._get_http_options() ) + request, metadata = self._interceptor.pre_batch_create_chunks( request, metadata ) @@ -819,6 +877,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.RetrieverServiceClient.BatchCreateChunks", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "BatchCreateChunks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RetrieverServiceRestTransport._BatchCreateChunks._get_response( self._host, @@ -840,7 +925,31 @@ def __call__( pb_resp = retriever_service.BatchCreateChunksResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_create_chunks(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + retriever_service.BatchCreateChunksResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.RetrieverServiceClient.batch_create_chunks", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "BatchCreateChunks", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchDeleteChunks( @@ -879,7 +988,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the batch delete chunks method over HTTP. @@ -889,13 +998,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 = ( _BaseRetrieverServiceRestTransport._BaseBatchDeleteChunks._get_http_options() ) + request, metadata = self._interceptor.pre_batch_delete_chunks( request, metadata ) @@ -912,6 +1024,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.RetrieverServiceClient.BatchDeleteChunks", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "BatchDeleteChunks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RetrieverServiceRestTransport._BatchDeleteChunks._get_response( self._host, @@ -964,7 +1103,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> retriever_service.BatchUpdateChunksResponse: r"""Call the batch update chunks method over HTTP. @@ -974,8 +1113,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.retriever_service.BatchUpdateChunksResponse: @@ -987,6 +1128,7 @@ def __call__( http_options = ( _BaseRetrieverServiceRestTransport._BaseBatchUpdateChunks._get_http_options() ) + request, metadata = self._interceptor.pre_batch_update_chunks( request, metadata ) @@ -1003,6 +1145,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.RetrieverServiceClient.BatchUpdateChunks", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "BatchUpdateChunks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RetrieverServiceRestTransport._BatchUpdateChunks._get_response( self._host, @@ -1024,7 +1193,31 @@ def __call__( pb_resp = retriever_service.BatchUpdateChunksResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_update_chunks(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + retriever_service.BatchUpdateChunksResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.RetrieverServiceClient.batch_update_chunks", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "BatchUpdateChunks", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateChunk( @@ -1062,7 +1255,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> retriever.Chunk: r"""Call the create chunk method over HTTP. @@ -1072,8 +1265,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.retriever.Chunk: @@ -1087,6 +1282,7 @@ def __call__( http_options = ( _BaseRetrieverServiceRestTransport._BaseCreateChunk._get_http_options() ) + request, metadata = self._interceptor.pre_create_chunk(request, metadata) transcoded_request = _BaseRetrieverServiceRestTransport._BaseCreateChunk._get_transcoded_request( http_options, request @@ -1101,6 +1297,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.RetrieverServiceClient.CreateChunk", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "CreateChunk", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RetrieverServiceRestTransport._CreateChunk._get_response( self._host, @@ -1122,7 +1345,29 @@ def __call__( pb_resp = retriever.Chunk.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_chunk(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = retriever.Chunk.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.RetrieverServiceClient.create_chunk", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "CreateChunk", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateCorpus( @@ -1160,7 +1405,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> retriever.Corpus: r"""Call the create corpus method over HTTP. @@ -1170,8 +1415,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.retriever.Corpus: @@ -1183,6 +1430,7 @@ def __call__( http_options = ( _BaseRetrieverServiceRestTransport._BaseCreateCorpus._get_http_options() ) + request, metadata = self._interceptor.pre_create_corpus(request, metadata) transcoded_request = _BaseRetrieverServiceRestTransport._BaseCreateCorpus._get_transcoded_request( http_options, request @@ -1197,6 +1445,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.RetrieverServiceClient.CreateCorpus", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "CreateCorpus", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RetrieverServiceRestTransport._CreateCorpus._get_response( self._host, @@ -1218,7 +1493,29 @@ def __call__( pb_resp = retriever.Corpus.pb(resp) json_format.Parse(response.content, pb_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 = retriever.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.ai.generativelanguage_v1beta.RetrieverServiceClient.create_corpus", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "CreateCorpus", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateDocument( @@ -1256,7 +1553,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> retriever.Document: r"""Call the create document method over HTTP. @@ -1266,8 +1563,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.retriever.Document: @@ -1279,6 +1578,7 @@ def __call__( http_options = ( _BaseRetrieverServiceRestTransport._BaseCreateDocument._get_http_options() ) + request, metadata = self._interceptor.pre_create_document(request, metadata) transcoded_request = _BaseRetrieverServiceRestTransport._BaseCreateDocument._get_transcoded_request( http_options, request @@ -1293,6 +1593,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.RetrieverServiceClient.CreateDocument", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "CreateDocument", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RetrieverServiceRestTransport._CreateDocument._get_response( self._host, @@ -1314,7 +1641,29 @@ def __call__( pb_resp = retriever.Document.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_document(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = retriever.Document.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.RetrieverServiceClient.create_document", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "CreateDocument", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteChunk( @@ -1351,7 +1700,7 @@ 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 chunk method over HTTP. @@ -1361,13 +1710,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 = ( _BaseRetrieverServiceRestTransport._BaseDeleteChunk._get_http_options() ) + request, metadata = self._interceptor.pre_delete_chunk(request, metadata) transcoded_request = _BaseRetrieverServiceRestTransport._BaseDeleteChunk._get_transcoded_request( http_options, request @@ -1378,6 +1730,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.RetrieverServiceClient.DeleteChunk", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "DeleteChunk", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RetrieverServiceRestTransport._DeleteChunk._get_response( self._host, @@ -1427,7 +1806,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete corpus method over HTTP. @@ -1437,13 +1816,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 = ( _BaseRetrieverServiceRestTransport._BaseDeleteCorpus._get_http_options() ) + request, metadata = self._interceptor.pre_delete_corpus(request, metadata) transcoded_request = _BaseRetrieverServiceRestTransport._BaseDeleteCorpus._get_transcoded_request( http_options, request @@ -1454,6 +1836,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.RetrieverServiceClient.DeleteCorpus", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "DeleteCorpus", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RetrieverServiceRestTransport._DeleteCorpus._get_response( self._host, @@ -1503,7 +1912,7 @@ 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 document method over HTTP. @@ -1513,13 +1922,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 = ( _BaseRetrieverServiceRestTransport._BaseDeleteDocument._get_http_options() ) + request, metadata = self._interceptor.pre_delete_document(request, metadata) transcoded_request = _BaseRetrieverServiceRestTransport._BaseDeleteDocument._get_transcoded_request( http_options, request @@ -1530,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.ai.generativelanguage_v1beta.RetrieverServiceClient.DeleteDocument", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "DeleteDocument", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RetrieverServiceRestTransport._DeleteDocument._get_response( self._host, @@ -1579,7 +2018,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> retriever.Chunk: r"""Call the get chunk method over HTTP. @@ -1590,8 +2029,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.retriever.Chunk: @@ -1605,6 +2046,7 @@ def __call__( http_options = ( _BaseRetrieverServiceRestTransport._BaseGetChunk._get_http_options() ) + request, metadata = self._interceptor.pre_get_chunk(request, metadata) transcoded_request = _BaseRetrieverServiceRestTransport._BaseGetChunk._get_transcoded_request( http_options, request @@ -1617,6 +2059,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.RetrieverServiceClient.GetChunk", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "GetChunk", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RetrieverServiceRestTransport._GetChunk._get_response( self._host, @@ -1637,7 +2106,29 @@ def __call__( pb_resp = retriever.Chunk.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_chunk(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = retriever.Chunk.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.RetrieverServiceClient.get_chunk", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "GetChunk", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCorpus( @@ -1674,7 +2165,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> retriever.Corpus: r"""Call the get corpus method over HTTP. @@ -1685,8 +2176,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.retriever.Corpus: @@ -1698,6 +2191,7 @@ def __call__( http_options = ( _BaseRetrieverServiceRestTransport._BaseGetCorpus._get_http_options() ) + request, metadata = self._interceptor.pre_get_corpus(request, metadata) transcoded_request = _BaseRetrieverServiceRestTransport._BaseGetCorpus._get_transcoded_request( http_options, request @@ -1708,6 +2202,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.RetrieverServiceClient.GetCorpus", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "GetCorpus", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RetrieverServiceRestTransport._GetCorpus._get_response( self._host, @@ -1728,7 +2249,29 @@ def __call__( pb_resp = retriever.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 = retriever.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.ai.generativelanguage_v1beta.RetrieverServiceClient.get_corpus", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "GetCorpus", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDocument( @@ -1765,7 +2308,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> retriever.Document: r"""Call the get document method over HTTP. @@ -1776,8 +2319,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.retriever.Document: @@ -1789,6 +2334,7 @@ def __call__( http_options = ( _BaseRetrieverServiceRestTransport._BaseGetDocument._get_http_options() ) + request, metadata = self._interceptor.pre_get_document(request, metadata) transcoded_request = _BaseRetrieverServiceRestTransport._BaseGetDocument._get_transcoded_request( http_options, request @@ -1799,6 +2345,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.RetrieverServiceClient.GetDocument", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "GetDocument", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RetrieverServiceRestTransport._GetDocument._get_response( self._host, @@ -1819,7 +2392,29 @@ def __call__( pb_resp = retriever.Document.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_document(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = retriever.Document.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.RetrieverServiceClient.get_document", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "GetDocument", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListChunks( @@ -1856,7 +2451,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> retriever_service.ListChunksResponse: r"""Call the list chunks method over HTTP. @@ -1866,8 +2461,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.retriever_service.ListChunksResponse: @@ -1880,6 +2477,7 @@ def __call__( http_options = ( _BaseRetrieverServiceRestTransport._BaseListChunks._get_http_options() ) + request, metadata = self._interceptor.pre_list_chunks(request, metadata) transcoded_request = _BaseRetrieverServiceRestTransport._BaseListChunks._get_transcoded_request( http_options, request @@ -1890,6 +2488,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.RetrieverServiceClient.ListChunks", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "ListChunks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RetrieverServiceRestTransport._ListChunks._get_response( self._host, @@ -1910,7 +2535,31 @@ def __call__( pb_resp = retriever_service.ListChunksResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_chunks(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = retriever_service.ListChunksResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.RetrieverServiceClient.list_chunks", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "ListChunks", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCorpora( @@ -1947,7 +2596,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> retriever_service.ListCorporaResponse: r"""Call the list corpora method over HTTP. @@ -1957,8 +2606,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.retriever_service.ListCorporaResponse: @@ -1971,6 +2622,7 @@ def __call__( http_options = ( _BaseRetrieverServiceRestTransport._BaseListCorpora._get_http_options() ) + request, metadata = self._interceptor.pre_list_corpora(request, metadata) transcoded_request = _BaseRetrieverServiceRestTransport._BaseListCorpora._get_transcoded_request( http_options, request @@ -1981,6 +2633,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.RetrieverServiceClient.ListCorpora", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "ListCorpora", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RetrieverServiceRestTransport._ListCorpora._get_response( self._host, @@ -2001,7 +2680,31 @@ def __call__( pb_resp = retriever_service.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 = retriever_service.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.ai.generativelanguage_v1beta.RetrieverServiceClient.list_corpora", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "ListCorpora", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDocuments( @@ -2038,7 +2741,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> retriever_service.ListDocumentsResponse: r"""Call the list documents method over HTTP. @@ -2048,8 +2751,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.retriever_service.ListDocumentsResponse: @@ -2062,6 +2767,7 @@ def __call__( http_options = ( _BaseRetrieverServiceRestTransport._BaseListDocuments._get_http_options() ) + request, metadata = self._interceptor.pre_list_documents(request, metadata) transcoded_request = _BaseRetrieverServiceRestTransport._BaseListDocuments._get_transcoded_request( http_options, request @@ -2072,6 +2778,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.RetrieverServiceClient.ListDocuments", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "ListDocuments", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RetrieverServiceRestTransport._ListDocuments._get_response( self._host, @@ -2092,7 +2825,31 @@ def __call__( pb_resp = retriever_service.ListDocumentsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_documents(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = retriever_service.ListDocumentsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.RetrieverServiceClient.list_documents", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "ListDocuments", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _QueryCorpus( @@ -2130,7 +2887,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> retriever_service.QueryCorpusResponse: r"""Call the query corpus method over HTTP. @@ -2140,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: ~.retriever_service.QueryCorpusResponse: @@ -2153,6 +2912,7 @@ def __call__( http_options = ( _BaseRetrieverServiceRestTransport._BaseQueryCorpus._get_http_options() ) + request, metadata = self._interceptor.pre_query_corpus(request, metadata) transcoded_request = _BaseRetrieverServiceRestTransport._BaseQueryCorpus._get_transcoded_request( http_options, request @@ -2167,6 +2927,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.RetrieverServiceClient.QueryCorpus", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "QueryCorpus", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RetrieverServiceRestTransport._QueryCorpus._get_response( self._host, @@ -2188,7 +2975,31 @@ def __call__( pb_resp = retriever_service.QueryCorpusResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_query_corpus(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = retriever_service.QueryCorpusResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.RetrieverServiceClient.query_corpus", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "QueryCorpus", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _QueryDocument( @@ -2226,7 +3037,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> retriever_service.QueryDocumentResponse: r"""Call the query document method over HTTP. @@ -2236,8 +3047,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.retriever_service.QueryDocumentResponse: @@ -2249,6 +3062,7 @@ def __call__( http_options = ( _BaseRetrieverServiceRestTransport._BaseQueryDocument._get_http_options() ) + request, metadata = self._interceptor.pre_query_document(request, metadata) transcoded_request = _BaseRetrieverServiceRestTransport._BaseQueryDocument._get_transcoded_request( http_options, request @@ -2263,6 +3077,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.RetrieverServiceClient.QueryDocument", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "QueryDocument", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RetrieverServiceRestTransport._QueryDocument._get_response( self._host, @@ -2284,7 +3125,31 @@ def __call__( pb_resp = retriever_service.QueryDocumentResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_query_document(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = retriever_service.QueryDocumentResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.RetrieverServiceClient.query_document", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "QueryDocument", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateChunk( @@ -2322,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]]] = (), ) -> retriever.Chunk: r"""Call the update chunk method over HTTP. @@ -2332,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: ~.retriever.Chunk: @@ -2347,6 +3214,7 @@ def __call__( http_options = ( _BaseRetrieverServiceRestTransport._BaseUpdateChunk._get_http_options() ) + request, metadata = self._interceptor.pre_update_chunk(request, metadata) transcoded_request = _BaseRetrieverServiceRestTransport._BaseUpdateChunk._get_transcoded_request( http_options, request @@ -2361,6 +3229,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.RetrieverServiceClient.UpdateChunk", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "UpdateChunk", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RetrieverServiceRestTransport._UpdateChunk._get_response( self._host, @@ -2382,7 +3277,29 @@ def __call__( pb_resp = retriever.Chunk.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_chunk(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = retriever.Chunk.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.RetrieverServiceClient.update_chunk", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "UpdateChunk", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCorpus( @@ -2420,7 +3337,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> retriever.Corpus: r"""Call the update corpus method over HTTP. @@ -2430,8 +3347,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.retriever.Corpus: @@ -2443,6 +3362,7 @@ def __call__( http_options = ( _BaseRetrieverServiceRestTransport._BaseUpdateCorpus._get_http_options() ) + request, metadata = self._interceptor.pre_update_corpus(request, metadata) transcoded_request = _BaseRetrieverServiceRestTransport._BaseUpdateCorpus._get_transcoded_request( http_options, request @@ -2457,6 +3377,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.RetrieverServiceClient.UpdateCorpus", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "UpdateCorpus", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RetrieverServiceRestTransport._UpdateCorpus._get_response( self._host, @@ -2478,7 +3425,29 @@ def __call__( pb_resp = retriever.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 = retriever.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.ai.generativelanguage_v1beta.RetrieverServiceClient.update_corpus", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "UpdateCorpus", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateDocument( @@ -2516,7 +3485,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> retriever.Document: r"""Call the update document method over HTTP. @@ -2526,8 +3495,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.retriever.Document: @@ -2539,6 +3510,7 @@ def __call__( http_options = ( _BaseRetrieverServiceRestTransport._BaseUpdateDocument._get_http_options() ) + request, metadata = self._interceptor.pre_update_document(request, metadata) transcoded_request = _BaseRetrieverServiceRestTransport._BaseUpdateDocument._get_transcoded_request( http_options, request @@ -2553,6 +3525,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.RetrieverServiceClient.UpdateDocument", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "UpdateDocument", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RetrieverServiceRestTransport._UpdateDocument._get_response( self._host, @@ -2574,7 +3573,29 @@ def __call__( pb_resp = retriever.Document.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_document(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = retriever.Document.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.RetrieverServiceClient.update_document", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "UpdateDocument", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -2793,7 +3814,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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. @@ -2803,8 +3824,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -2813,6 +3836,7 @@ def __call__( http_options = ( _BaseRetrieverServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseRetrieverServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -2823,6 +3847,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.RetrieverServiceClient.GetOperation", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RetrieverServiceRestTransport._GetOperation._get_response( self._host, @@ -2842,6 +3893,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.ai.generativelanguage_v1beta.RetrieverServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2882,7 +3954,7 @@ def __call__( *, 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. @@ -2892,8 +3964,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must 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. @@ -2902,6 +3976,7 @@ def __call__( http_options = ( _BaseRetrieverServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseRetrieverServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -2912,6 +3987,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.RetrieverServiceClient.ListOperations", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RetrieverServiceRestTransport._ListOperations._get_response( self._host, @@ -2931,6 +4033,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.ai.generativelanguage_v1beta.RetrieverServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.RetrieverService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/text_service/async_client.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/text_service/async_client.py index e9772454ca13..8bd2d85e3aa7 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/text_service/async_client.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/text_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, @@ -50,6 +51,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, TextServiceTransport from .transports.grpc_asyncio import TextServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class TextServiceAsyncClient: """API for using Generative Language Models (GLMs) trained to @@ -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.ai.generativelanguage_v1beta.TextServiceAsyncClient`.", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.TextService", + "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.ai.generativelanguage.v1beta.TextService", + "credentialsType": None, + }, + ) + async def generate_text( self, request: Optional[Union[text_service.GenerateTextRequest, dict]] = None, @@ -268,7 +300,7 @@ async def generate_text( top_k: Optional[int] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> text_service.GenerateTextResponse: r"""Generates a response from the model given an input message. @@ -398,8 +430,10 @@ async def sample_generate_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.ai.generativelanguage_v1beta.types.GenerateTextResponse: @@ -483,7 +517,7 @@ async def embed_text( text: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> text_service.EmbedTextResponse: r"""Generates an embedding from the model given an input message. @@ -536,8 +570,10 @@ async def sample_embed_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.ai.generativelanguage_v1beta.types.EmbedTextResponse: @@ -599,7 +635,7 @@ async def batch_embed_text( texts: 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]]] = (), ) -> text_service.BatchEmbedTextResponse: r"""Generates multiple embeddings from the model given input text in a synchronous call. @@ -655,8 +691,10 @@ async def sample_batch_embed_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.ai.generativelanguage_v1beta.types.BatchEmbedTextResponse: @@ -718,7 +756,7 @@ async def count_text_tokens( prompt: Optional[text_service.TextPrompt] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> text_service.CountTextTokensResponse: r"""Runs a model's tokenizer on a text and returns the token count. @@ -782,8 +820,10 @@ async def sample_count_text_tokens(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.CountTextTokensResponse: @@ -846,7 +886,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. @@ -857,8 +897,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. @@ -899,7 +941,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. @@ -910,8 +952,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-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/text_service/client.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/text_service/client.py index 86c6e81db70b..7043738543b9 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/text_service/client.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/text_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.longrunning import operations_pb2 # type: ignore from google.ai.generativelanguage_v1beta.types import safety, text_service @@ -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,6 +650,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.ai.generativelanguage_v1beta.TextServiceClient`.", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.TextService", + "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.ai.generativelanguage.v1beta.TextService", + "credentialsType": None, + }, + ) + def generate_text( self, request: Optional[Union[text_service.GenerateTextRequest, dict]] = None, @@ -649,7 +686,7 @@ def generate_text( top_k: Optional[int] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> text_service.GenerateTextResponse: r"""Generates a response from the model given an input message. @@ -779,8 +816,10 @@ def sample_generate_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.ai.generativelanguage_v1beta.types.GenerateTextResponse: @@ -861,7 +900,7 @@ def embed_text( text: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> text_service.EmbedTextResponse: r"""Generates an embedding from the model given an input message. @@ -914,8 +953,10 @@ def sample_embed_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.ai.generativelanguage_v1beta.types.EmbedTextResponse: @@ -974,7 +1015,7 @@ def batch_embed_text( texts: 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]]] = (), ) -> text_service.BatchEmbedTextResponse: r"""Generates multiple embeddings from the model given input text in a synchronous call. @@ -1030,8 +1071,10 @@ def sample_batch_embed_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.ai.generativelanguage_v1beta.types.BatchEmbedTextResponse: @@ -1090,7 +1133,7 @@ def count_text_tokens( prompt: Optional[text_service.TextPrompt] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> text_service.CountTextTokensResponse: r"""Runs a model's tokenizer on a text and returns the token count. @@ -1154,8 +1197,10 @@ def sample_count_text_tokens(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta.types.CountTextTokensResponse: @@ -1228,7 +1273,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. @@ -1239,8 +1284,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. @@ -1281,7 +1328,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. @@ -1292,8 +1339,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-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/text_service/transports/grpc.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/text_service/transports/grpc.py index 3466402b8b0a..15722a0eab9c 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/text_service/transports/grpc.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/text_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.ai.generativelanguage_v1beta.types import text_service from .base import DEFAULT_CLIENT_INFO, TextServiceTransport +try: + from google.api_core import client_logging # 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.ai.generativelanguage.v1beta.TextService", + "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.ai.generativelanguage.v1beta.TextService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TextServiceGrpcTransport(TextServiceTransport): """gRPC backend transport for TextService. @@ -183,7 +264,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientInterceptor() + self._logged_channel = grpc.intercept_channel( + self._grpc_channel, self._interceptor + ) + + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @classmethod @@ -260,7 +346,7 @@ def generate_text( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_text" not in self._stubs: - self._stubs["generate_text"] = self.grpc_channel.unary_unary( + self._stubs["generate_text"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.TextService/GenerateText", request_serializer=text_service.GenerateTextRequest.serialize, response_deserializer=text_service.GenerateTextResponse.deserialize, @@ -287,7 +373,7 @@ def embed_text( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "embed_text" not in self._stubs: - self._stubs["embed_text"] = self.grpc_channel.unary_unary( + self._stubs["embed_text"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.TextService/EmbedText", request_serializer=text_service.EmbedTextRequest.serialize, response_deserializer=text_service.EmbedTextResponse.deserialize, @@ -316,7 +402,7 @@ def batch_embed_text( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_embed_text" not in self._stubs: - self._stubs["batch_embed_text"] = self.grpc_channel.unary_unary( + self._stubs["batch_embed_text"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.TextService/BatchEmbedText", request_serializer=text_service.BatchEmbedTextRequest.serialize, response_deserializer=text_service.BatchEmbedTextResponse.deserialize, @@ -345,7 +431,7 @@ def count_text_tokens( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "count_text_tokens" not in self._stubs: - self._stubs["count_text_tokens"] = self.grpc_channel.unary_unary( + self._stubs["count_text_tokens"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.TextService/CountTextTokens", request_serializer=text_service.CountTextTokensRequest.serialize, response_deserializer=text_service.CountTextTokensResponse.deserialize, @@ -353,7 +439,7 @@ def count_text_tokens( return self._stubs["count_text_tokens"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -365,7 +451,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, @@ -384,7 +470,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-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/text_service/transports/grpc_asyncio.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/text_service/transports/grpc_asyncio.py index 687fa4cc0663..2227a7b5e3c5 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/text_service/transports/grpc_asyncio.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/text_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.ai.generativelanguage_v1beta.types import text_service from .base import DEFAULT_CLIENT_INFO, TextServiceTransport from .grpc import TextServiceGrpcTransport +try: + from google.api_core import client_logging # 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.ai.generativelanguage.v1beta.TextService", + "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.ai.generativelanguage.v1beta.TextService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TextServiceGrpcAsyncIOTransport(TextServiceTransport): """gRPC AsyncIO backend transport for TextService. @@ -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 generate_text( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_text" not in self._stubs: - self._stubs["generate_text"] = self.grpc_channel.unary_unary( + self._stubs["generate_text"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.TextService/GenerateText", request_serializer=text_service.GenerateTextRequest.serialize, response_deserializer=text_service.GenerateTextResponse.deserialize, @@ -297,7 +382,7 @@ def embed_text( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "embed_text" not in self._stubs: - self._stubs["embed_text"] = self.grpc_channel.unary_unary( + self._stubs["embed_text"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.TextService/EmbedText", request_serializer=text_service.EmbedTextRequest.serialize, response_deserializer=text_service.EmbedTextResponse.deserialize, @@ -327,7 +412,7 @@ def batch_embed_text( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_embed_text" not in self._stubs: - self._stubs["batch_embed_text"] = self.grpc_channel.unary_unary( + self._stubs["batch_embed_text"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.TextService/BatchEmbedText", request_serializer=text_service.BatchEmbedTextRequest.serialize, response_deserializer=text_service.BatchEmbedTextResponse.deserialize, @@ -357,7 +442,7 @@ def count_text_tokens( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "count_text_tokens" not in self._stubs: - self._stubs["count_text_tokens"] = self.grpc_channel.unary_unary( + self._stubs["count_text_tokens"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta.TextService/CountTextTokens", request_serializer=text_service.CountTextTokensRequest.serialize, response_deserializer=text_service.CountTextTokensResponse.deserialize, @@ -441,7 +526,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: @@ -457,7 +542,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, @@ -476,7 +561,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-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/text_service/transports/rest.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/text_service/transports/rest.py index 709daf154c4e..2fdc0c445f2e 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/text_service/transports/rest.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta/services/text_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, @@ -102,8 +110,10 @@ def post_generate_text(self, response): def pre_batch_embed_text( self, request: text_service.BatchEmbedTextRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[text_service.BatchEmbedTextRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + text_service.BatchEmbedTextRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for batch_embed_text Override in a subclass to manipulate the request or metadata @@ -125,8 +135,10 @@ def post_batch_embed_text( def pre_count_text_tokens( self, request: text_service.CountTextTokensRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[text_service.CountTextTokensRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + text_service.CountTextTokensRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for count_text_tokens Override in a subclass to manipulate the request or metadata @@ -148,8 +160,8 @@ def post_count_text_tokens( def pre_embed_text( self, request: text_service.EmbedTextRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[text_service.EmbedTextRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[text_service.EmbedTextRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for embed_text Override in a subclass to manipulate the request or metadata @@ -171,8 +183,10 @@ def post_embed_text( def pre_generate_text( self, request: text_service.GenerateTextRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[text_service.GenerateTextRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + text_service.GenerateTextRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for generate_text Override in a subclass to manipulate the request or metadata @@ -194,8 +208,10 @@ def post_generate_text( 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 @@ -217,8 +233,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 @@ -362,7 +380,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> text_service.BatchEmbedTextResponse: r"""Call the batch embed text method over HTTP. @@ -373,8 +391,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.text_service.BatchEmbedTextResponse: @@ -384,6 +404,7 @@ def __call__( http_options = ( _BaseTextServiceRestTransport._BaseBatchEmbedText._get_http_options() ) + request, metadata = self._interceptor.pre_batch_embed_text( request, metadata ) @@ -400,6 +421,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.TextServiceClient.BatchEmbedText", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.TextService", + "rpcName": "BatchEmbedText", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TextServiceRestTransport._BatchEmbedText._get_response( self._host, @@ -421,7 +469,31 @@ def __call__( pb_resp = text_service.BatchEmbedTextResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_embed_text(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = text_service.BatchEmbedTextResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.TextServiceClient.batch_embed_text", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.TextService", + "rpcName": "BatchEmbedText", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CountTextTokens( @@ -459,7 +531,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> text_service.CountTextTokensResponse: r"""Call the count text tokens method over HTTP. @@ -473,8 +545,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.text_service.CountTextTokensResponse: @@ -488,6 +562,7 @@ def __call__( http_options = ( _BaseTextServiceRestTransport._BaseCountTextTokens._get_http_options() ) + request, metadata = self._interceptor.pre_count_text_tokens( request, metadata ) @@ -504,6 +579,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.TextServiceClient.CountTextTokens", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.TextService", + "rpcName": "CountTextTokens", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TextServiceRestTransport._CountTextTokens._get_response( self._host, @@ -525,7 +627,31 @@ def __call__( pb_resp = text_service.CountTextTokensResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_count_text_tokens(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = text_service.CountTextTokensResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.TextServiceClient.count_text_tokens", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.TextService", + "rpcName": "CountTextTokens", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _EmbedText(_BaseTextServiceRestTransport._BaseEmbedText, TextServiceRestStub): @@ -561,7 +687,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> text_service.EmbedTextResponse: r"""Call the embed text method over HTTP. @@ -572,8 +698,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.text_service.EmbedTextResponse: @@ -583,6 +711,7 @@ def __call__( http_options = ( _BaseTextServiceRestTransport._BaseEmbedText._get_http_options() ) + request, metadata = self._interceptor.pre_embed_text(request, metadata) transcoded_request = ( _BaseTextServiceRestTransport._BaseEmbedText._get_transcoded_request( @@ -601,6 +730,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.TextServiceClient.EmbedText", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.TextService", + "rpcName": "EmbedText", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TextServiceRestTransport._EmbedText._get_response( self._host, @@ -622,7 +778,29 @@ def __call__( pb_resp = text_service.EmbedTextResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_embed_text(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = text_service.EmbedTextResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.TextServiceClient.embed_text", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.TextService", + "rpcName": "EmbedText", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GenerateText( @@ -660,7 +838,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> text_service.GenerateTextResponse: r"""Call the generate text method over HTTP. @@ -671,8 +849,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.text_service.GenerateTextResponse: @@ -684,6 +864,7 @@ def __call__( http_options = ( _BaseTextServiceRestTransport._BaseGenerateText._get_http_options() ) + request, metadata = self._interceptor.pre_generate_text(request, metadata) transcoded_request = ( _BaseTextServiceRestTransport._BaseGenerateText._get_transcoded_request( @@ -704,6 +885,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.TextServiceClient.GenerateText", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.TextService", + "rpcName": "GenerateText", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TextServiceRestTransport._GenerateText._get_response( self._host, @@ -725,7 +933,31 @@ def __call__( pb_resp = text_service.GenerateTextResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_generate_text(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = text_service.GenerateTextResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta.TextServiceClient.generate_text", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.TextService", + "rpcName": "GenerateText", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -804,7 +1036,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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. @@ -814,8 +1046,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -824,6 +1058,7 @@ def __call__( http_options = ( _BaseTextServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseTextServiceRestTransport._BaseGetOperation._get_transcoded_request( @@ -838,6 +1073,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.TextServiceClient.GetOperation", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.TextService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TextServiceRestTransport._GetOperation._get_response( self._host, @@ -857,6 +1119,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.ai.generativelanguage_v1beta.TextServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.TextService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -897,7 +1180,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -907,8 +1190,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -917,6 +1202,7 @@ def __call__( http_options = ( _BaseTextServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseTextServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -927,6 +1213,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta.TextServiceClient.ListOperations", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.TextService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TextServiceRestTransport._ListOperations._get_response( self._host, @@ -946,6 +1259,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.ai.generativelanguage_v1beta.TextServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta.TextService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/gapic_version.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/gapic_version.py index b72badcc1eca..558c8aab67c5 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/gapic_version.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.6.13" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/discuss_service/async_client.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/discuss_service/async_client.py index 6413d76f3cbd..1cee3d1af404 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/discuss_service/async_client.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/discuss_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, @@ -48,6 +49,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, DiscussServiceTransport from .transports.grpc_asyncio import DiscussServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class DiscussServiceAsyncClient: """An API for using Generative Language Models (GLMs) in dialog @@ -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.ai.generativelanguage_v1beta2.DiscussServiceAsyncClient`.", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta2.DiscussService", + "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.ai.generativelanguage.v1beta2.DiscussService", + "credentialsType": None, + }, + ) + async def generate_message( self, request: Optional[Union[discuss_service.GenerateMessageRequest, dict]] = None, @@ -269,7 +301,7 @@ async def generate_message( top_k: Optional[int] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> discuss_service.GenerateMessageResponse: r"""Generates a response from the model given an input ``MessagePrompt``. @@ -375,8 +407,10 @@ async def sample_generate_message(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta2.types.GenerateMessageResponse: @@ -455,7 +489,7 @@ async def count_message_tokens( prompt: Optional[discuss_service.MessagePrompt] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> discuss_service.CountMessageTokensResponse: r"""Runs a model's tokenizer on a string and returns the token count. @@ -519,8 +553,10 @@ async def sample_count_message_tokens(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta2.types.CountMessageTokensResponse: diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/discuss_service/client.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/discuss_service/client.py index 76d71583a294..4d2db83aacba 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/discuss_service/client.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/discuss_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.ai.generativelanguage_v1beta2.types import discuss_service, safety from .transports.base import DEFAULT_CLIENT_INFO, DiscussServiceTransport @@ -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,6 +653,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.ai.generativelanguage_v1beta2.DiscussServiceClient`.", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta2.DiscussService", + "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.ai.generativelanguage.v1beta2.DiscussService", + "credentialsType": None, + }, + ) + def generate_message( self, request: Optional[Union[discuss_service.GenerateMessageRequest, dict]] = None, @@ -651,7 +688,7 @@ def generate_message( top_k: Optional[int] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> discuss_service.GenerateMessageResponse: r"""Generates a response from the model given an input ``MessagePrompt``. @@ -757,8 +794,10 @@ def sample_generate_message(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta2.types.GenerateMessageResponse: @@ -834,7 +873,7 @@ def count_message_tokens( prompt: Optional[discuss_service.MessagePrompt] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> discuss_service.CountMessageTokensResponse: r"""Runs a model's tokenizer on a string and returns the token count. @@ -898,8 +937,10 @@ def sample_count_message_tokens(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta2.types.CountMessageTokensResponse: diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/discuss_service/transports/grpc.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/discuss_service/transports/grpc.py index 071541b8da85..6210c6584778 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/discuss_service/transports/grpc.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/discuss_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.ai.generativelanguage_v1beta2.types import discuss_service from .base import DEFAULT_CLIENT_INFO, DiscussServiceTransport +try: + from google.api_core import client_logging # 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.ai.generativelanguage.v1beta2.DiscussService", + "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.ai.generativelanguage.v1beta2.DiscussService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class DiscussServiceGrpcTransport(DiscussServiceTransport): """gRPC backend transport for DiscussService. @@ -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 generate_message( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_message" not in self._stubs: - self._stubs["generate_message"] = self.grpc_channel.unary_unary( + self._stubs["generate_message"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta2.DiscussService/GenerateMessage", request_serializer=discuss_service.GenerateMessageRequest.serialize, response_deserializer=discuss_service.GenerateMessageResponse.deserialize, @@ -290,7 +376,7 @@ def count_message_tokens( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "count_message_tokens" not in self._stubs: - self._stubs["count_message_tokens"] = self.grpc_channel.unary_unary( + self._stubs["count_message_tokens"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta2.DiscussService/CountMessageTokens", request_serializer=discuss_service.CountMessageTokensRequest.serialize, response_deserializer=discuss_service.CountMessageTokensResponse.deserialize, @@ -298,7 +384,7 @@ def count_message_tokens( return self._stubs["count_message_tokens"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/discuss_service/transports/grpc_asyncio.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/discuss_service/transports/grpc_asyncio.py index beca9f440809..34b1510e0eb2 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/discuss_service/transports/grpc_asyncio.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/discuss_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.ai.generativelanguage_v1beta2.types import discuss_service from .base import DEFAULT_CLIENT_INFO, DiscussServiceTransport from .grpc import DiscussServiceGrpcTransport +try: + from google.api_core import client_logging # 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.ai.generativelanguage.v1beta2.DiscussService", + "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.ai.generativelanguage.v1beta2.DiscussService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class DiscussServiceGrpcAsyncIOTransport(DiscussServiceTransport): """gRPC AsyncIO backend transport for DiscussService. @@ -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 generate_message( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_message" not in self._stubs: - self._stubs["generate_message"] = self.grpc_channel.unary_unary( + self._stubs["generate_message"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta2.DiscussService/GenerateMessage", request_serializer=discuss_service.GenerateMessageRequest.serialize, response_deserializer=discuss_service.GenerateMessageResponse.deserialize, @@ -298,7 +383,7 @@ def count_message_tokens( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "count_message_tokens" not in self._stubs: - self._stubs["count_message_tokens"] = self.grpc_channel.unary_unary( + self._stubs["count_message_tokens"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta2.DiscussService/CountMessageTokens", request_serializer=discuss_service.CountMessageTokensRequest.serialize, response_deserializer=discuss_service.CountMessageTokensResponse.deserialize, @@ -344,7 +429,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-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/discuss_service/transports/rest.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/discuss_service/transports/rest.py index 91facf39a903..a3f6d345ef27 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/discuss_service/transports/rest.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/discuss_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -37,6 +37,14 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = logging.getLogger(__name__) DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, @@ -85,8 +93,11 @@ def post_generate_message(self, response): def pre_count_message_tokens( self, request: discuss_service.CountMessageTokensRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[discuss_service.CountMessageTokensRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + discuss_service.CountMessageTokensRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for count_message_tokens Override in a subclass to manipulate the request or metadata @@ -108,8 +119,10 @@ def post_count_message_tokens( def pre_generate_message( self, request: discuss_service.GenerateMessageRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[discuss_service.GenerateMessageRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + discuss_service.GenerateMessageRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for generate_message Override in a subclass to manipulate the request or metadata @@ -253,7 +266,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> discuss_service.CountMessageTokensResponse: r"""Call the count message tokens method over HTTP. @@ -267,8 +280,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.discuss_service.CountMessageTokensResponse: @@ -282,6 +297,7 @@ def __call__( http_options = ( _BaseDiscussServiceRestTransport._BaseCountMessageTokens._get_http_options() ) + request, metadata = self._interceptor.pre_count_message_tokens( request, metadata ) @@ -298,6 +314,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta2.DiscussServiceClient.CountMessageTokens", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta2.DiscussService", + "rpcName": "CountMessageTokens", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DiscussServiceRestTransport._CountMessageTokens._get_response( self._host, @@ -319,7 +362,31 @@ def __call__( pb_resp = discuss_service.CountMessageTokensResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_count_message_tokens(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + discuss_service.CountMessageTokensResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta2.DiscussServiceClient.count_message_tokens", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta2.DiscussService", + "rpcName": "CountMessageTokens", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GenerateMessage( @@ -357,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]]] = (), ) -> discuss_service.GenerateMessageResponse: r"""Call the generate message method over HTTP. @@ -368,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: ~.discuss_service.GenerateMessageResponse: @@ -384,6 +453,7 @@ def __call__( http_options = ( _BaseDiscussServiceRestTransport._BaseGenerateMessage._get_http_options() ) + request, metadata = self._interceptor.pre_generate_message( request, metadata ) @@ -400,6 +470,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta2.DiscussServiceClient.GenerateMessage", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta2.DiscussService", + "rpcName": "GenerateMessage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DiscussServiceRestTransport._GenerateMessage._get_response( self._host, @@ -421,7 +518,31 @@ def __call__( pb_resp = discuss_service.GenerateMessageResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_generate_message(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = discuss_service.GenerateMessageResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta2.DiscussServiceClient.generate_message", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta2.DiscussService", + "rpcName": "GenerateMessage", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/model_service/async_client.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/model_service/async_client.py index 53f2c11e8a5c..fd413d3d300f 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/model_service/async_client.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/model_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, ModelServiceTransport from .transports.grpc_asyncio import ModelServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class ModelServiceAsyncClient: """Provides methods for getting metadata information about @@ -252,6 +262,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.ai.generativelanguage_v1beta2.ModelServiceAsyncClient`.", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta2.ModelService", + "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.ai.generativelanguage.v1beta2.ModelService", + "credentialsType": None, + }, + ) + async def get_model( self, request: Optional[Union[model_service.GetModelRequest, dict]] = None, @@ -259,7 +291,7 @@ async def get_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model.Model: r"""Gets information about a specific Model. @@ -307,8 +339,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.ai.generativelanguage_v1beta2.types.Model: @@ -370,7 +404,7 @@ async def list_models( page_token: Optional[str] = None, retry: OptionalRetry = gapic_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 available through the API. @@ -431,8 +465,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.ai.generativelanguage_v1beta2.services.model_service.pagers.ListModelsAsyncPager: diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/model_service/client.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/model_service/client.py index ded53d4a1793..81b78eb9aebb 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/model_service/client.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/model_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.ai.generativelanguage_v1beta2.services.model_service import pagers from google.ai.generativelanguage_v1beta2.types import model, model_service @@ -571,6 +581,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -633,6 +647,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.ai.generativelanguage_v1beta2.ModelServiceClient`.", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta2.ModelService", + "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.ai.generativelanguage.v1beta2.ModelService", + "credentialsType": None, + }, + ) + def get_model( self, request: Optional[Union[model_service.GetModelRequest, dict]] = None, @@ -640,7 +677,7 @@ def get_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model.Model: r"""Gets information about a specific Model. @@ -688,8 +725,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.ai.generativelanguage_v1beta2.types.Model: @@ -748,7 +787,7 @@ def list_models( page_token: Optional[str] = None, retry: OptionalRetry = gapic_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 available through the API. @@ -809,8 +848,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.ai.generativelanguage_v1beta2.services.model_service.pagers.ListModelsPager: diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/model_service/pagers.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/model_service/pagers.py index 2932c215d773..96cd5d265098 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/model_service/pagers.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/model_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 = model_service.ListModelsRequest(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 = model_service.ListModelsRequest(request) diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/model_service/transports/grpc.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/model_service/transports/grpc.py index 231167a74c9e..f9759e2f8fce 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/model_service/transports/grpc.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/model_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.ai.generativelanguage_v1beta2.types import model, model_service from .base import DEFAULT_CLIENT_INFO, ModelServiceTransport +try: + from google.api_core import client_logging # 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.ai.generativelanguage.v1beta2.ModelService", + "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.ai.generativelanguage.v1beta2.ModelService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ModelServiceGrpcTransport(ModelServiceTransport): """gRPC backend transport for ModelService. @@ -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 @@ -252,7 +338,7 @@ def get_model(self) -> Callable[[model_service.GetModelRequest], model.Model]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_model" not in self._stubs: - self._stubs["get_model"] = self.grpc_channel.unary_unary( + self._stubs["get_model"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta2.ModelService/GetModel", request_serializer=model_service.GetModelRequest.serialize, response_deserializer=model.Model.deserialize, @@ -278,7 +364,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.ai.generativelanguage.v1beta2.ModelService/ListModels", request_serializer=model_service.ListModelsRequest.serialize, response_deserializer=model_service.ListModelsResponse.deserialize, @@ -286,7 +372,7 @@ def list_models( return self._stubs["list_models"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/model_service/transports/grpc_asyncio.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/model_service/transports/grpc_asyncio.py index c6af1e3af3a6..fe90db867f5a 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/model_service/transports/grpc_asyncio.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/model_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.ai.generativelanguage_v1beta2.types import model, model_service from .base import DEFAULT_CLIENT_INFO, ModelServiceTransport from .grpc import ModelServiceGrpcTransport +try: + from google.api_core import client_logging # 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.ai.generativelanguage.v1beta2.ModelService", + "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.ai.generativelanguage.v1beta2.ModelService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ModelServiceGrpcAsyncIOTransport(ModelServiceTransport): """gRPC AsyncIO backend transport for ModelService. @@ -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 @@ -262,7 +347,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.ai.generativelanguage.v1beta2.ModelService/GetModel", request_serializer=model_service.GetModelRequest.serialize, response_deserializer=model.Model.deserialize, @@ -290,7 +375,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.ai.generativelanguage.v1beta2.ModelService/ListModels", request_serializer=model_service.ListModelsRequest.serialize, response_deserializer=model_service.ListModelsResponse.deserialize, @@ -336,7 +421,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-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/model_service/transports/rest.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/model_service/transports/rest.py index f3f3005a509e..87bc85f49a7e 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/model_service/transports/rest.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/model_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -37,6 +37,14 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = logging.getLogger(__name__) DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, @@ -85,8 +93,8 @@ def post_list_models(self, response): def pre_get_model( self, request: model_service.GetModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.GetModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[model_service.GetModelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_model Override in a subclass to manipulate the request or metadata @@ -106,8 +114,10 @@ def post_get_model(self, response: model.Model) -> model.Model: def pre_list_models( self, request: model_service.ListModelsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.ListModelsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + model_service.ListModelsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_models Override in a subclass to manipulate the request or metadata @@ -246,7 +256,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model.Model: r"""Call the get model method over HTTP. @@ -257,8 +267,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.model.Model: @@ -270,6 +282,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseGetModel._get_http_options() ) + request, metadata = self._interceptor.pre_get_model(request, metadata) transcoded_request = ( _BaseModelServiceRestTransport._BaseGetModel._get_transcoded_request( @@ -284,6 +297,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta2.ModelServiceClient.GetModel", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta2.ModelService", + "rpcName": "GetModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._GetModel._get_response( self._host, @@ -304,7 +344,29 @@ def __call__( pb_resp = model.Model.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_model(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = model.Model.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta2.ModelServiceClient.get_model", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta2.ModelService", + "rpcName": "GetModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListModels( @@ -341,7 +403,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model_service.ListModelsResponse: r"""Call the list models method over HTTP. @@ -351,8 +413,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.model_service.ListModelsResponse: @@ -364,6 +428,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseListModels._get_http_options() ) + request, metadata = self._interceptor.pre_list_models(request, metadata) transcoded_request = ( _BaseModelServiceRestTransport._BaseListModels._get_transcoded_request( @@ -378,6 +443,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta2.ModelServiceClient.ListModels", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta2.ModelService", + "rpcName": "ListModels", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._ListModels._get_response( self._host, @@ -398,7 +490,31 @@ def __call__( pb_resp = model_service.ListModelsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_models(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = model_service.ListModelsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta2.ModelServiceClient.list_models", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta2.ModelService", + "rpcName": "ListModels", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/text_service/async_client.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/text_service/async_client.py index 14b3d745095b..25ed85b7b3b5 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/text_service/async_client.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/text_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, @@ -48,6 +49,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, TextServiceTransport from .transports.grpc_asyncio import TextServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class TextServiceAsyncClient: """API for using Generative Language Models (GLMs) trained to @@ -253,6 +263,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.ai.generativelanguage_v1beta2.TextServiceAsyncClient`.", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta2.TextService", + "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.ai.generativelanguage.v1beta2.TextService", + "credentialsType": None, + }, + ) + async def generate_text( self, request: Optional[Union[text_service.GenerateTextRequest, dict]] = None, @@ -266,7 +298,7 @@ async def generate_text( top_k: Optional[int] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> text_service.GenerateTextResponse: r"""Generates a response from the model given an input message. @@ -391,8 +423,10 @@ async def sample_generate_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.ai.generativelanguage_v1beta2.types.GenerateTextResponse: @@ -476,7 +510,7 @@ async def embed_text( text: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> text_service.EmbedTextResponse: r"""Generates an embedding from the model given an input message. @@ -530,8 +564,10 @@ async def sample_embed_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.ai.generativelanguage_v1beta2.types.EmbedTextResponse: diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/text_service/client.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/text_service/client.py index 9663add6a459..0fffeee6b68b 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/text_service/client.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/text_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.ai.generativelanguage_v1beta2.types import safety, text_service from .transports.base import DEFAULT_CLIENT_INFO, TextServiceTransport @@ -572,6 +582,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( @@ -634,6 +648,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.ai.generativelanguage_v1beta2.TextServiceClient`.", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta2.TextService", + "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.ai.generativelanguage.v1beta2.TextService", + "credentialsType": None, + }, + ) + def generate_text( self, request: Optional[Union[text_service.GenerateTextRequest, dict]] = None, @@ -647,7 +684,7 @@ def generate_text( top_k: Optional[int] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> text_service.GenerateTextResponse: r"""Generates a response from the model given an input message. @@ -772,8 +809,10 @@ def sample_generate_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.ai.generativelanguage_v1beta2.types.GenerateTextResponse: @@ -854,7 +893,7 @@ def embed_text( text: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> text_service.EmbedTextResponse: r"""Generates an embedding from the model given an input message. @@ -908,8 +947,10 @@ def sample_embed_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.ai.generativelanguage_v1beta2.types.EmbedTextResponse: diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/text_service/transports/grpc.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/text_service/transports/grpc.py index fc4c7ba64f24..ff44bb7abe98 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/text_service/transports/grpc.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/text_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.ai.generativelanguage_v1beta2.types import text_service from .base import DEFAULT_CLIENT_INFO, TextServiceTransport +try: + from google.api_core import client_logging # 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.ai.generativelanguage.v1beta2.TextService", + "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.ai.generativelanguage.v1beta2.TextService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TextServiceGrpcTransport(TextServiceTransport): """gRPC backend transport for TextService. @@ -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 @@ -259,7 +345,7 @@ def generate_text( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_text" not in self._stubs: - self._stubs["generate_text"] = self.grpc_channel.unary_unary( + self._stubs["generate_text"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta2.TextService/GenerateText", request_serializer=text_service.GenerateTextRequest.serialize, response_deserializer=text_service.GenerateTextResponse.deserialize, @@ -286,7 +372,7 @@ def embed_text( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "embed_text" not in self._stubs: - self._stubs["embed_text"] = self.grpc_channel.unary_unary( + self._stubs["embed_text"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta2.TextService/EmbedText", request_serializer=text_service.EmbedTextRequest.serialize, response_deserializer=text_service.EmbedTextResponse.deserialize, @@ -294,7 +380,7 @@ def embed_text( return self._stubs["embed_text"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/text_service/transports/grpc_asyncio.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/text_service/transports/grpc_asyncio.py index 7d74042c47c6..668da8707f2b 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/text_service/transports/grpc_asyncio.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/text_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.ai.generativelanguage_v1beta2.types import text_service from .base import DEFAULT_CLIENT_INFO, TextServiceTransport from .grpc import TextServiceGrpcTransport +try: + from google.api_core import client_logging # 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.ai.generativelanguage.v1beta2.TextService", + "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.ai.generativelanguage.v1beta2.TextService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TextServiceGrpcAsyncIOTransport(TextServiceTransport): """gRPC AsyncIO backend transport for TextService. @@ -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 @@ -267,7 +352,7 @@ def generate_text( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_text" not in self._stubs: - self._stubs["generate_text"] = self.grpc_channel.unary_unary( + self._stubs["generate_text"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta2.TextService/GenerateText", request_serializer=text_service.GenerateTextRequest.serialize, response_deserializer=text_service.GenerateTextResponse.deserialize, @@ -296,7 +381,7 @@ def embed_text( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "embed_text" not in self._stubs: - self._stubs["embed_text"] = self.grpc_channel.unary_unary( + self._stubs["embed_text"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta2.TextService/EmbedText", request_serializer=text_service.EmbedTextRequest.serialize, response_deserializer=text_service.EmbedTextResponse.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-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/text_service/transports/rest.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/text_service/transports/rest.py index 6b804f764f1d..ece0f776739c 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/text_service/transports/rest.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta2/services/text_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -37,6 +37,14 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = logging.getLogger(__name__) DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, @@ -85,8 +93,8 @@ def post_generate_text(self, response): def pre_embed_text( self, request: text_service.EmbedTextRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[text_service.EmbedTextRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[text_service.EmbedTextRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for embed_text Override in a subclass to manipulate the request or metadata @@ -108,8 +116,10 @@ def post_embed_text( def pre_generate_text( self, request: text_service.GenerateTextRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[text_service.GenerateTextRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + text_service.GenerateTextRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for generate_text Override in a subclass to manipulate the request or metadata @@ -251,7 +261,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> text_service.EmbedTextResponse: r"""Call the embed text method over HTTP. @@ -262,8 +272,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.text_service.EmbedTextResponse: @@ -273,6 +285,7 @@ def __call__( http_options = ( _BaseTextServiceRestTransport._BaseEmbedText._get_http_options() ) + request, metadata = self._interceptor.pre_embed_text(request, metadata) transcoded_request = ( _BaseTextServiceRestTransport._BaseEmbedText._get_transcoded_request( @@ -291,6 +304,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta2.TextServiceClient.EmbedText", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta2.TextService", + "rpcName": "EmbedText", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TextServiceRestTransport._EmbedText._get_response( self._host, @@ -312,7 +352,29 @@ def __call__( pb_resp = text_service.EmbedTextResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_embed_text(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = text_service.EmbedTextResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta2.TextServiceClient.embed_text", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta2.TextService", + "rpcName": "EmbedText", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GenerateText( @@ -350,7 +412,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> text_service.GenerateTextResponse: r"""Call the generate text method over HTTP. @@ -361,8 +423,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.text_service.GenerateTextResponse: @@ -374,6 +438,7 @@ def __call__( http_options = ( _BaseTextServiceRestTransport._BaseGenerateText._get_http_options() ) + request, metadata = self._interceptor.pre_generate_text(request, metadata) transcoded_request = ( _BaseTextServiceRestTransport._BaseGenerateText._get_transcoded_request( @@ -394,6 +459,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta2.TextServiceClient.GenerateText", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta2.TextService", + "rpcName": "GenerateText", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TextServiceRestTransport._GenerateText._get_response( self._host, @@ -415,7 +507,31 @@ def __call__( pb_resp = text_service.GenerateTextResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_generate_text(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = text_service.GenerateTextResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta2.TextServiceClient.generate_text", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta2.TextService", + "rpcName": "GenerateText", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/gapic_version.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/gapic_version.py index b72badcc1eca..558c8aab67c5 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/gapic_version.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.6.13" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/discuss_service/async_client.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/discuss_service/async_client.py index 0683a984cae1..183bfbbc56ce 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/discuss_service/async_client.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/discuss_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, @@ -50,6 +51,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, DiscussServiceTransport from .transports.grpc_asyncio import DiscussServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class DiscussServiceAsyncClient: """An API for using Generative Language Models (GLMs) in dialog @@ -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.ai.generativelanguage_v1beta3.DiscussServiceAsyncClient`.", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.DiscussService", + "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.ai.generativelanguage.v1beta3.DiscussService", + "credentialsType": None, + }, + ) + async def generate_message( self, request: Optional[Union[discuss_service.GenerateMessageRequest, dict]] = None, @@ -271,7 +303,7 @@ async def generate_message( top_k: Optional[int] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> discuss_service.GenerateMessageResponse: r"""Generates a response from the model given an input ``MessagePrompt``. @@ -377,8 +409,10 @@ async def sample_generate_message(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta3.types.GenerateMessageResponse: @@ -457,7 +491,7 @@ async def count_message_tokens( prompt: Optional[discuss_service.MessagePrompt] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> discuss_service.CountMessageTokensResponse: r"""Runs a model's tokenizer on a string and returns the token count. @@ -521,8 +555,10 @@ async def sample_count_message_tokens(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta3.types.CountMessageTokensResponse: diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/discuss_service/client.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/discuss_service/client.py index 9c0f32e7be0a..8b0c864b00f4 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/discuss_service/client.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/discuss_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.longrunning import operations_pb2 # type: ignore from google.ai.generativelanguage_v1beta3.types import discuss_service, safety @@ -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( @@ -641,6 +655,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.ai.generativelanguage_v1beta3.DiscussServiceClient`.", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.DiscussService", + "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.ai.generativelanguage.v1beta3.DiscussService", + "credentialsType": None, + }, + ) + def generate_message( self, request: Optional[Union[discuss_service.GenerateMessageRequest, dict]] = None, @@ -653,7 +690,7 @@ def generate_message( top_k: Optional[int] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> discuss_service.GenerateMessageResponse: r"""Generates a response from the model given an input ``MessagePrompt``. @@ -759,8 +796,10 @@ def sample_generate_message(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta3.types.GenerateMessageResponse: @@ -836,7 +875,7 @@ def count_message_tokens( prompt: Optional[discuss_service.MessagePrompt] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> discuss_service.CountMessageTokensResponse: r"""Runs a model's tokenizer on a string and returns the token count. @@ -900,8 +939,10 @@ def sample_count_message_tokens(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta3.types.CountMessageTokensResponse: diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/discuss_service/transports/grpc.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/discuss_service/transports/grpc.py index 750e69de41c6..1af7f6a547da 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/discuss_service/transports/grpc.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/discuss_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.ai.generativelanguage_v1beta3.types import discuss_service from .base import DEFAULT_CLIENT_INFO, DiscussServiceTransport +try: + from google.api_core import client_logging # 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.ai.generativelanguage.v1beta3.DiscussService", + "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.ai.generativelanguage.v1beta3.DiscussService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class DiscussServiceGrpcTransport(DiscussServiceTransport): """gRPC backend transport for DiscussService. @@ -183,7 +264,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientInterceptor() + self._logged_channel = grpc.intercept_channel( + self._grpc_channel, self._interceptor + ) + + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @classmethod @@ -261,7 +347,7 @@ def generate_message( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_message" not in self._stubs: - self._stubs["generate_message"] = self.grpc_channel.unary_unary( + self._stubs["generate_message"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta3.DiscussService/GenerateMessage", request_serializer=discuss_service.GenerateMessageRequest.serialize, response_deserializer=discuss_service.GenerateMessageResponse.deserialize, @@ -291,7 +377,7 @@ def count_message_tokens( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "count_message_tokens" not in self._stubs: - self._stubs["count_message_tokens"] = self.grpc_channel.unary_unary( + self._stubs["count_message_tokens"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta3.DiscussService/CountMessageTokens", request_serializer=discuss_service.CountMessageTokensRequest.serialize, response_deserializer=discuss_service.CountMessageTokensResponse.deserialize, @@ -299,7 +385,7 @@ def count_message_tokens( return self._stubs["count_message_tokens"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/discuss_service/transports/grpc_asyncio.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/discuss_service/transports/grpc_asyncio.py index d3657d7af9f8..66043ae633e5 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/discuss_service/transports/grpc_asyncio.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/discuss_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.ai.generativelanguage_v1beta3.types import discuss_service from .base import DEFAULT_CLIENT_INFO, DiscussServiceTransport from .grpc import DiscussServiceGrpcTransport +try: + from google.api_core import client_logging # 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.ai.generativelanguage.v1beta3.DiscussService", + "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.ai.generativelanguage.v1beta3.DiscussService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class DiscussServiceGrpcAsyncIOTransport(DiscussServiceTransport): """gRPC AsyncIO backend transport for DiscussService. @@ -230,10 +312,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientAIOInterceptor() + self._grpc_channel._unary_unary_interceptors.append(self._interceptor) + self._logged_channel = self._grpc_channel self._wrap_with_kind = ( "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters ) + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @property @@ -269,7 +354,7 @@ def generate_message( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_message" not in self._stubs: - self._stubs["generate_message"] = self.grpc_channel.unary_unary( + self._stubs["generate_message"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta3.DiscussService/GenerateMessage", request_serializer=discuss_service.GenerateMessageRequest.serialize, response_deserializer=discuss_service.GenerateMessageResponse.deserialize, @@ -299,7 +384,7 @@ def count_message_tokens( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "count_message_tokens" not in self._stubs: - self._stubs["count_message_tokens"] = self.grpc_channel.unary_unary( + self._stubs["count_message_tokens"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta3.DiscussService/CountMessageTokens", request_serializer=discuss_service.CountMessageTokensRequest.serialize, response_deserializer=discuss_service.CountMessageTokensResponse.deserialize, @@ -327,7 +412,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-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/discuss_service/transports/rest.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/discuss_service/transports/rest.py index 394ae4fb977a..19d8130c40e8 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/discuss_service/transports/rest.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/discuss_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = logging.getLogger(__name__) DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, @@ -86,8 +94,11 @@ def post_generate_message(self, response): def pre_count_message_tokens( self, request: discuss_service.CountMessageTokensRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[discuss_service.CountMessageTokensRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + discuss_service.CountMessageTokensRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for count_message_tokens Override in a subclass to manipulate the request or metadata @@ -109,8 +120,10 @@ def post_count_message_tokens( def pre_generate_message( self, request: discuss_service.GenerateMessageRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[discuss_service.GenerateMessageRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + discuss_service.GenerateMessageRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for generate_message Override in a subclass to manipulate the request or metadata @@ -254,7 +267,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> discuss_service.CountMessageTokensResponse: r"""Call the count message tokens method over HTTP. @@ -268,8 +281,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.discuss_service.CountMessageTokensResponse: @@ -283,6 +298,7 @@ def __call__( http_options = ( _BaseDiscussServiceRestTransport._BaseCountMessageTokens._get_http_options() ) + request, metadata = self._interceptor.pre_count_message_tokens( request, metadata ) @@ -299,6 +315,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta3.DiscussServiceClient.CountMessageTokens", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.DiscussService", + "rpcName": "CountMessageTokens", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DiscussServiceRestTransport._CountMessageTokens._get_response( self._host, @@ -320,7 +363,31 @@ def __call__( pb_resp = discuss_service.CountMessageTokensResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_count_message_tokens(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + discuss_service.CountMessageTokensResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta3.DiscussServiceClient.count_message_tokens", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.DiscussService", + "rpcName": "CountMessageTokens", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GenerateMessage( @@ -358,7 +425,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> discuss_service.GenerateMessageResponse: r"""Call the generate message method over HTTP. @@ -369,8 +436,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.discuss_service.GenerateMessageResponse: @@ -385,6 +454,7 @@ def __call__( http_options = ( _BaseDiscussServiceRestTransport._BaseGenerateMessage._get_http_options() ) + request, metadata = self._interceptor.pre_generate_message( request, metadata ) @@ -401,6 +471,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta3.DiscussServiceClient.GenerateMessage", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.DiscussService", + "rpcName": "GenerateMessage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DiscussServiceRestTransport._GenerateMessage._get_response( self._host, @@ -422,7 +519,31 @@ def __call__( pb_resp = discuss_service.GenerateMessageResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_generate_message(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = discuss_service.GenerateMessageResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta3.DiscussServiceClient.generate_message", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.DiscussService", + "rpcName": "GenerateMessage", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/model_service/async_client.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/model_service/async_client.py index c51657477468..d56a4cd171d3 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/model_service/async_client.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/model_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -57,6 +58,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ModelServiceTransport from .transports.grpc_asyncio import ModelServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class ModelServiceAsyncClient: """Provides methods for getting metadata information about @@ -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.ai.generativelanguage_v1beta3.ModelServiceAsyncClient`.", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.ModelService", + "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.ai.generativelanguage.v1beta3.ModelService", + "credentialsType": None, + }, + ) + async def get_model( self, request: Optional[Union[model_service.GetModelRequest, dict]] = None, @@ -269,7 +301,7 @@ async def get_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model.Model: r"""Gets information about a specific Model. @@ -317,8 +349,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.ai.generativelanguage_v1beta3.types.Model: @@ -380,7 +414,7 @@ async def list_models( page_token: Optional[str] = None, retry: OptionalRetry = gapic_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 available through the API. @@ -441,8 +475,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.ai.generativelanguage_v1beta3.services.model_service.pagers.ListModelsAsyncPager: @@ -513,7 +549,7 @@ async def get_tuned_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]]] = (), ) -> tuned_model.TunedModel: r"""Gets information about a specific TunedModel. @@ -558,8 +594,10 @@ async def sample_get_tuned_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.ai.generativelanguage_v1beta3.types.TunedModel: @@ -621,7 +659,7 @@ async def list_tuned_models( page_token: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTunedModelsAsyncPager: r"""Lists tuned models owned by the user. @@ -683,8 +721,10 @@ async def sample_list_tuned_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.ai.generativelanguage_v1beta3.services.model_service.pagers.ListTunedModelsAsyncPager: @@ -756,7 +796,7 @@ async def create_tuned_model( tuned_model_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 tuned model. Intermediate tuning progress (if any) is accessed through the [google.longrunning.Operations] service. @@ -820,8 +860,10 @@ async def sample_create_tuned_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: @@ -891,7 +933,7 @@ async def update_tuned_model( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gag_tuned_model.TunedModel: r"""Updates a tuned model. @@ -943,8 +985,10 @@ async def sample_update_tuned_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.ai.generativelanguage_v1beta3.types.TunedModel: @@ -1009,7 +1053,7 @@ async def delete_tuned_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]]] = (), ) -> None: r"""Deletes a tuned model. @@ -1049,8 +1093,10 @@ async def sample_delete_tuned_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/model_service/client.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/model_service/client.py index 3e4196c6d5d8..0f6ab9afaf39 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/model_service/client.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/model_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 @@ -594,6 +604,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -656,6 +670,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.ai.generativelanguage_v1beta3.ModelServiceClient`.", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.ModelService", + "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.ai.generativelanguage.v1beta3.ModelService", + "credentialsType": None, + }, + ) + def get_model( self, request: Optional[Union[model_service.GetModelRequest, dict]] = None, @@ -663,7 +700,7 @@ def get_model( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model.Model: r"""Gets information about a specific Model. @@ -711,8 +748,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.ai.generativelanguage_v1beta3.types.Model: @@ -771,7 +810,7 @@ def list_models( page_token: Optional[str] = None, retry: OptionalRetry = gapic_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 available through the API. @@ -832,8 +871,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.ai.generativelanguage_v1beta3.services.model_service.pagers.ListModelsPager: @@ -901,7 +942,7 @@ def get_tuned_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]]] = (), ) -> tuned_model.TunedModel: r"""Gets information about a specific TunedModel. @@ -946,8 +987,10 @@ def sample_get_tuned_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.ai.generativelanguage_v1beta3.types.TunedModel: @@ -1006,7 +1049,7 @@ def list_tuned_models( page_token: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTunedModelsPager: r"""Lists tuned models owned by the user. @@ -1068,8 +1111,10 @@ def sample_list_tuned_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.ai.generativelanguage_v1beta3.services.model_service.pagers.ListTunedModelsPager: @@ -1138,7 +1183,7 @@ def create_tuned_model( tuned_model_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 tuned model. Intermediate tuning progress (if any) is accessed through the [google.longrunning.Operations] service. @@ -1202,8 +1247,10 @@ def sample_create_tuned_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: @@ -1270,7 +1317,7 @@ def update_tuned_model( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gag_tuned_model.TunedModel: r"""Updates a tuned model. @@ -1322,8 +1369,10 @@ def sample_update_tuned_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.ai.generativelanguage_v1beta3.types.TunedModel: @@ -1385,7 +1434,7 @@ def delete_tuned_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]]] = (), ) -> None: r"""Deletes a tuned model. @@ -1425,8 +1474,10 @@ def sample_delete_tuned_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/model_service/pagers.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/model_service/pagers.py index 5475247e18a9..af749a69ad98 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/model_service/pagers.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/model_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 = model_service.ListModelsRequest(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 = model_service.ListModelsRequest(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 = model_service.ListTunedModelsRequest(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 = model_service.ListTunedModelsRequest(request) diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/model_service/transports/grpc.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/model_service/transports/grpc.py index 5e91aaf1fb56..3f2080fcf10f 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/model_service/transports/grpc.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/model_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,7 +25,10 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.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.ai.generativelanguage_v1beta3.types import tuned_model as gag_tuned_model from google.ai.generativelanguage_v1beta3.types import model, model_service @@ -30,6 +36,81 @@ from .base import DEFAULT_CLIENT_INFO, ModelServiceTransport +try: + from google.api_core import client_logging # 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.ai.generativelanguage.v1beta3.ModelService", + "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.ai.generativelanguage.v1beta3.ModelService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ModelServiceGrpcTransport(ModelServiceTransport): """gRPC backend transport for ModelService. @@ -185,7 +266,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientInterceptor() + self._logged_channel = grpc.intercept_channel( + self._grpc_channel, self._interceptor + ) + + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @classmethod @@ -249,7 +335,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -271,7 +359,7 @@ def get_model(self) -> Callable[[model_service.GetModelRequest], model.Model]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_model" not in self._stubs: - self._stubs["get_model"] = self.grpc_channel.unary_unary( + self._stubs["get_model"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta3.ModelService/GetModel", request_serializer=model_service.GetModelRequest.serialize, response_deserializer=model.Model.deserialize, @@ -297,7 +385,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.ai.generativelanguage.v1beta3.ModelService/ListModels", request_serializer=model_service.ListModelsRequest.serialize, response_deserializer=model_service.ListModelsResponse.deserialize, @@ -323,7 +411,7 @@ def get_tuned_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_tuned_model" not in self._stubs: - self._stubs["get_tuned_model"] = self.grpc_channel.unary_unary( + self._stubs["get_tuned_model"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta3.ModelService/GetTunedModel", request_serializer=model_service.GetTunedModelRequest.serialize, response_deserializer=tuned_model.TunedModel.deserialize, @@ -351,7 +439,7 @@ def list_tuned_models( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_tuned_models" not in self._stubs: - self._stubs["list_tuned_models"] = self.grpc_channel.unary_unary( + self._stubs["list_tuned_models"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta3.ModelService/ListTunedModels", request_serializer=model_service.ListTunedModelsRequest.serialize, response_deserializer=model_service.ListTunedModelsResponse.deserialize, @@ -382,7 +470,7 @@ def create_tuned_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_tuned_model" not in self._stubs: - self._stubs["create_tuned_model"] = self.grpc_channel.unary_unary( + self._stubs["create_tuned_model"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta3.ModelService/CreateTunedModel", request_serializer=model_service.CreateTunedModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -408,7 +496,7 @@ def update_tuned_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_tuned_model" not in self._stubs: - self._stubs["update_tuned_model"] = self.grpc_channel.unary_unary( + self._stubs["update_tuned_model"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta3.ModelService/UpdateTunedModel", request_serializer=model_service.UpdateTunedModelRequest.serialize, response_deserializer=gag_tuned_model.TunedModel.deserialize, @@ -434,7 +522,7 @@ def delete_tuned_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_tuned_model" not in self._stubs: - self._stubs["delete_tuned_model"] = self.grpc_channel.unary_unary( + self._stubs["delete_tuned_model"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta3.ModelService/DeleteTunedModel", request_serializer=model_service.DeleteTunedModelRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -442,7 +530,7 @@ def delete_tuned_model( return self._stubs["delete_tuned_model"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/model_service/transports/grpc_asyncio.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/model_service/transports/grpc_asyncio.py index e8b470c1f9d2..3836fd554db8 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/model_service/transports/grpc_asyncio.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/model_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.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.ai.generativelanguage_v1beta3.types import tuned_model as gag_tuned_model from google.ai.generativelanguage_v1beta3.types import model, model_service @@ -34,6 +40,82 @@ from .base import DEFAULT_CLIENT_INFO, ModelServiceTransport from .grpc import ModelServiceGrpcTransport +try: + from google.api_core import client_logging # 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.ai.generativelanguage.v1beta3.ModelService", + "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.ai.generativelanguage.v1beta3.ModelService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ModelServiceGrpcAsyncIOTransport(ModelServiceTransport): """gRPC AsyncIO backend transport for ModelService. @@ -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 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.ai.generativelanguage.v1beta3.ModelService/GetModel", request_serializer=model_service.GetModelRequest.serialize, response_deserializer=model.Model.deserialize, @@ -311,7 +396,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.ai.generativelanguage.v1beta3.ModelService/ListModels", request_serializer=model_service.ListModelsRequest.serialize, response_deserializer=model_service.ListModelsResponse.deserialize, @@ -339,7 +424,7 @@ def get_tuned_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_tuned_model" not in self._stubs: - self._stubs["get_tuned_model"] = self.grpc_channel.unary_unary( + self._stubs["get_tuned_model"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta3.ModelService/GetTunedModel", request_serializer=model_service.GetTunedModelRequest.serialize, response_deserializer=tuned_model.TunedModel.deserialize, @@ -368,7 +453,7 @@ def list_tuned_models( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_tuned_models" not in self._stubs: - self._stubs["list_tuned_models"] = self.grpc_channel.unary_unary( + self._stubs["list_tuned_models"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta3.ModelService/ListTunedModels", request_serializer=model_service.ListTunedModelsRequest.serialize, response_deserializer=model_service.ListTunedModelsResponse.deserialize, @@ -401,7 +486,7 @@ def create_tuned_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_tuned_model" not in self._stubs: - self._stubs["create_tuned_model"] = self.grpc_channel.unary_unary( + self._stubs["create_tuned_model"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta3.ModelService/CreateTunedModel", request_serializer=model_service.CreateTunedModelRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -429,7 +514,7 @@ def update_tuned_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_tuned_model" not in self._stubs: - self._stubs["update_tuned_model"] = self.grpc_channel.unary_unary( + self._stubs["update_tuned_model"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta3.ModelService/UpdateTunedModel", request_serializer=model_service.UpdateTunedModelRequest.serialize, response_deserializer=gag_tuned_model.TunedModel.deserialize, @@ -455,7 +540,7 @@ def delete_tuned_model( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_tuned_model" not in self._stubs: - self._stubs["delete_tuned_model"] = self.grpc_channel.unary_unary( + self._stubs["delete_tuned_model"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta3.ModelService/DeleteTunedModel", request_serializer=model_service.DeleteTunedModelRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -508,7 +593,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-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/model_service/transports/rest.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/model_service/transports/rest.py index dfcb88d923f9..ba17fc8955bd 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/model_service/transports/rest.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/model_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, @@ -125,8 +133,10 @@ def post_update_tuned_model(self, response): def pre_create_tuned_model( self, request: model_service.CreateTunedModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.CreateTunedModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + model_service.CreateTunedModelRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_tuned_model Override in a subclass to manipulate the request or metadata @@ -148,8 +158,10 @@ def post_create_tuned_model( def pre_delete_tuned_model( self, request: model_service.DeleteTunedModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.DeleteTunedModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + model_service.DeleteTunedModelRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_tuned_model Override in a subclass to manipulate the request or metadata @@ -160,8 +172,8 @@ def pre_delete_tuned_model( def pre_get_model( self, request: model_service.GetModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.GetModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[model_service.GetModelRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_model Override in a subclass to manipulate the request or metadata @@ -181,8 +193,10 @@ def post_get_model(self, response: model.Model) -> model.Model: def pre_get_tuned_model( self, request: model_service.GetTunedModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.GetTunedModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + model_service.GetTunedModelRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_tuned_model Override in a subclass to manipulate the request or metadata @@ -204,8 +218,10 @@ def post_get_tuned_model( def pre_list_models( self, request: model_service.ListModelsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.ListModelsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + model_service.ListModelsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_models Override in a subclass to manipulate the request or metadata @@ -227,8 +243,10 @@ def post_list_models( def pre_list_tuned_models( self, request: model_service.ListTunedModelsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.ListTunedModelsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + model_service.ListTunedModelsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_tuned_models Override in a subclass to manipulate the request or metadata @@ -250,8 +268,10 @@ def post_list_tuned_models( def pre_update_tuned_model( self, request: model_service.UpdateTunedModelRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[model_service.UpdateTunedModelRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + model_service.UpdateTunedModelRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_tuned_model Override in a subclass to manipulate the request or metadata @@ -421,7 +441,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create tuned model method over HTTP. @@ -431,8 +451,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -445,6 +467,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseCreateTunedModel._get_http_options() ) + request, metadata = self._interceptor.pre_create_tuned_model( request, metadata ) @@ -461,6 +484,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta3.ModelServiceClient.CreateTunedModel", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.ModelService", + "rpcName": "CreateTunedModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._CreateTunedModel._get_response( self._host, @@ -480,7 +530,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_tuned_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.ai.generativelanguage_v1beta3.ModelServiceClient.create_tuned_model", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.ModelService", + "rpcName": "CreateTunedModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteTunedModel( @@ -517,7 +589,7 @@ 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 tuned model method over HTTP. @@ -527,13 +599,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 = ( _BaseModelServiceRestTransport._BaseDeleteTunedModel._get_http_options() ) + request, metadata = self._interceptor.pre_delete_tuned_model( request, metadata ) @@ -546,6 +621,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta3.ModelServiceClient.DeleteTunedModel", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.ModelService", + "rpcName": "DeleteTunedModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._DeleteTunedModel._get_response( self._host, @@ -593,7 +695,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model.Model: r"""Call the get model method over HTTP. @@ -604,8 +706,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.model.Model: @@ -617,6 +721,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseGetModel._get_http_options() ) + request, metadata = self._interceptor.pre_get_model(request, metadata) transcoded_request = ( _BaseModelServiceRestTransport._BaseGetModel._get_transcoded_request( @@ -631,6 +736,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta3.ModelServiceClient.GetModel", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.ModelService", + "rpcName": "GetModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._GetModel._get_response( self._host, @@ -651,7 +783,29 @@ def __call__( pb_resp = model.Model.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_model(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = model.Model.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta3.ModelServiceClient.get_model", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.ModelService", + "rpcName": "GetModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetTunedModel( @@ -688,7 +842,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tuned_model.TunedModel: r"""Call the get tuned model method over HTTP. @@ -699,8 +853,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.tuned_model.TunedModel: @@ -712,6 +868,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseGetTunedModel._get_http_options() ) + request, metadata = self._interceptor.pre_get_tuned_model(request, metadata) transcoded_request = _BaseModelServiceRestTransport._BaseGetTunedModel._get_transcoded_request( http_options, request @@ -722,6 +879,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta3.ModelServiceClient.GetTunedModel", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.ModelService", + "rpcName": "GetTunedModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._GetTunedModel._get_response( self._host, @@ -742,7 +926,29 @@ def __call__( pb_resp = tuned_model.TunedModel.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_tuned_model(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = tuned_model.TunedModel.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta3.ModelServiceClient.get_tuned_model", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.ModelService", + "rpcName": "GetTunedModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListModels( @@ -779,7 +985,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model_service.ListModelsResponse: r"""Call the list models method over HTTP. @@ -789,8 +995,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.model_service.ListModelsResponse: @@ -802,6 +1010,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseListModels._get_http_options() ) + request, metadata = self._interceptor.pre_list_models(request, metadata) transcoded_request = ( _BaseModelServiceRestTransport._BaseListModels._get_transcoded_request( @@ -816,6 +1025,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta3.ModelServiceClient.ListModels", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.ModelService", + "rpcName": "ListModels", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._ListModels._get_response( self._host, @@ -836,7 +1072,31 @@ def __call__( pb_resp = model_service.ListModelsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_models(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = model_service.ListModelsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta3.ModelServiceClient.list_models", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.ModelService", + "rpcName": "ListModels", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTunedModels( @@ -873,7 +1133,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> model_service.ListTunedModelsResponse: r"""Call the list tuned models method over HTTP. @@ -883,8 +1143,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.model_service.ListTunedModelsResponse: @@ -896,6 +1158,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseListTunedModels._get_http_options() ) + request, metadata = self._interceptor.pre_list_tuned_models( request, metadata ) @@ -908,6 +1171,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta3.ModelServiceClient.ListTunedModels", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.ModelService", + "rpcName": "ListTunedModels", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._ListTunedModels._get_response( self._host, @@ -928,7 +1218,31 @@ def __call__( pb_resp = model_service.ListTunedModelsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_tuned_models(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = model_service.ListTunedModelsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta3.ModelServiceClient.list_tuned_models", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.ModelService", + "rpcName": "ListTunedModels", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateTunedModel( @@ -966,7 +1280,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gag_tuned_model.TunedModel: r"""Call the update tuned model method over HTTP. @@ -976,8 +1290,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gag_tuned_model.TunedModel: @@ -989,6 +1305,7 @@ def __call__( http_options = ( _BaseModelServiceRestTransport._BaseUpdateTunedModel._get_http_options() ) + request, metadata = self._interceptor.pre_update_tuned_model( request, metadata ) @@ -1005,6 +1322,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta3.ModelServiceClient.UpdateTunedModel", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.ModelService", + "rpcName": "UpdateTunedModel", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ModelServiceRestTransport._UpdateTunedModel._get_response( self._host, @@ -1026,7 +1370,29 @@ def __call__( pb_resp = gag_tuned_model.TunedModel.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_tuned_model(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gag_tuned_model.TunedModel.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta3.ModelServiceClient.update_tuned_model", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.ModelService", + "rpcName": "UpdateTunedModel", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/permission_service/async_client.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/permission_service/async_client.py index bc1bb058d9ff..d481bdaf40dc 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/permission_service/async_client.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/permission_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, PermissionServiceTransport from .transports.grpc_asyncio import PermissionServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class PermissionServiceAsyncClient: """Provides methods for managing permissions to PaLM API @@ -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.ai.generativelanguage_v1beta3.PermissionServiceAsyncClient`.", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.PermissionService", + "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.ai.generativelanguage.v1beta3.PermissionService", + "credentialsType": None, + }, + ) + async def create_permission( self, request: Optional[ @@ -279,7 +311,7 @@ async def create_permission( permission: Optional[gag_permission.Permission] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gag_permission.Permission: r"""Create a permission to a specific resource. @@ -327,8 +359,10 @@ async def sample_create_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.ai.generativelanguage_v1beta3.types.Permission: @@ -412,7 +446,7 @@ async def get_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]]] = (), ) -> permission.Permission: r"""Gets information about a specific Permission. @@ -458,8 +492,10 @@ async def sample_get_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.ai.generativelanguage_v1beta3.types.Permission: @@ -543,7 +579,7 @@ async def list_permissions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPermissionsAsyncPager: r"""Lists permissions for the specific resource. @@ -587,8 +623,10 @@ async def sample_list_permissions(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta3.services.permission_service.pagers.ListPermissionsAsyncPager: @@ -666,7 +704,7 @@ async def update_permission( 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]]] = (), ) -> gag_permission.Permission: r"""Updates the permission. @@ -718,8 +756,10 @@ async def sample_update_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.ai.generativelanguage_v1beta3.types.Permission: @@ -807,7 +847,7 @@ async def delete_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]]] = (), ) -> None: r"""Deletes the permission. @@ -847,8 +887,10 @@ async def sample_delete_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -901,7 +943,7 @@ async def transfer_ownership( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> permission_service.TransferOwnershipResponse: r"""Transfers ownership of the tuned model. This is the only way to change ownership of the tuned @@ -942,8 +984,10 @@ async def sample_transfer_ownership(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta3.types.TransferOwnershipResponse: diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/permission_service/client.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/permission_service/client.py index 6d126b1d3c03..c3ce5cd4cb63 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/permission_service/client.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/permission_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.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -601,6 +611,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -667,6 +681,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.ai.generativelanguage_v1beta3.PermissionServiceClient`.", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.PermissionService", + "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.ai.generativelanguage.v1beta3.PermissionService", + "credentialsType": None, + }, + ) + def create_permission( self, request: Optional[ @@ -677,7 +714,7 @@ def create_permission( permission: Optional[gag_permission.Permission] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gag_permission.Permission: r"""Create a permission to a specific resource. @@ -725,8 +762,10 @@ def sample_create_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.ai.generativelanguage_v1beta3.types.Permission: @@ -807,7 +846,7 @@ def get_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]]] = (), ) -> permission.Permission: r"""Gets information about a specific Permission. @@ -853,8 +892,10 @@ def sample_get_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.ai.generativelanguage_v1beta3.types.Permission: @@ -935,7 +976,7 @@ def list_permissions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPermissionsPager: r"""Lists permissions for the specific resource. @@ -979,8 +1020,10 @@ def sample_list_permissions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta3.services.permission_service.pagers.ListPermissionsPager: @@ -1055,7 +1098,7 @@ def update_permission( 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]]] = (), ) -> gag_permission.Permission: r"""Updates the permission. @@ -1107,8 +1150,10 @@ def sample_update_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.ai.generativelanguage_v1beta3.types.Permission: @@ -1193,7 +1238,7 @@ def delete_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]]] = (), ) -> None: r"""Deletes the permission. @@ -1233,8 +1278,10 @@ def sample_delete_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1284,7 +1331,7 @@ def transfer_ownership( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> permission_service.TransferOwnershipResponse: r"""Transfers ownership of the tuned model. This is the only way to change ownership of the tuned @@ -1325,8 +1372,10 @@ def sample_transfer_ownership(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta3.types.TransferOwnershipResponse: diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/permission_service/pagers.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/permission_service/pagers.py index 6af6796cb18f..5fff820601cf 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/permission_service/pagers.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/permission_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 = permission_service.ListPermissionsRequest(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 = permission_service.ListPermissionsRequest(request) diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/permission_service/transports/grpc.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/permission_service/transports/grpc.py index 1e9fb355ecc4..fd3937409e73 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/permission_service/transports/grpc.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/permission_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,7 +25,10 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.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.ai.generativelanguage_v1beta3.types import permission as gag_permission from google.ai.generativelanguage_v1beta3.types import permission @@ -30,6 +36,81 @@ from .base import DEFAULT_CLIENT_INFO, PermissionServiceTransport +try: + from google.api_core import client_logging # 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.ai.generativelanguage.v1beta3.PermissionService", + "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.ai.generativelanguage.v1beta3.PermissionService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class PermissionServiceGrpcTransport(PermissionServiceTransport): """gRPC backend transport for PermissionService. @@ -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_permission( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_permission" not in self._stubs: - self._stubs["create_permission"] = self.grpc_channel.unary_unary( + self._stubs["create_permission"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta3.PermissionService/CreatePermission", request_serializer=permission_service.CreatePermissionRequest.serialize, response_deserializer=gag_permission.Permission.deserialize, @@ -286,7 +372,7 @@ def get_permission( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_permission" not in self._stubs: - self._stubs["get_permission"] = self.grpc_channel.unary_unary( + self._stubs["get_permission"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta3.PermissionService/GetPermission", request_serializer=permission_service.GetPermissionRequest.serialize, response_deserializer=permission.Permission.deserialize, @@ -315,7 +401,7 @@ def list_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_permissions" not in self._stubs: - self._stubs["list_permissions"] = self.grpc_channel.unary_unary( + self._stubs["list_permissions"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta3.PermissionService/ListPermissions", request_serializer=permission_service.ListPermissionsRequest.serialize, response_deserializer=permission_service.ListPermissionsResponse.deserialize, @@ -343,7 +429,7 @@ def update_permission( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_permission" not in self._stubs: - self._stubs["update_permission"] = self.grpc_channel.unary_unary( + self._stubs["update_permission"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta3.PermissionService/UpdatePermission", request_serializer=permission_service.UpdatePermissionRequest.serialize, response_deserializer=gag_permission.Permission.deserialize, @@ -369,7 +455,7 @@ def delete_permission( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_permission" not in self._stubs: - self._stubs["delete_permission"] = self.grpc_channel.unary_unary( + self._stubs["delete_permission"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta3.PermissionService/DeletePermission", request_serializer=permission_service.DeletePermissionRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -401,7 +487,7 @@ def transfer_ownership( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "transfer_ownership" not in self._stubs: - self._stubs["transfer_ownership"] = self.grpc_channel.unary_unary( + self._stubs["transfer_ownership"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta3.PermissionService/TransferOwnership", request_serializer=permission_service.TransferOwnershipRequest.serialize, response_deserializer=permission_service.TransferOwnershipResponse.deserialize, @@ -409,7 +495,7 @@ def transfer_ownership( return self._stubs["transfer_ownership"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/permission_service/transports/grpc_asyncio.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/permission_service/transports/grpc_asyncio.py index eecfbeec55ed..00864746f976 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/permission_service/transports/grpc_asyncio.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/permission_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.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.ai.generativelanguage_v1beta3.types import permission as gag_permission from google.ai.generativelanguage_v1beta3.types import permission @@ -34,6 +40,82 @@ from .base import DEFAULT_CLIENT_INFO, PermissionServiceTransport from .grpc import PermissionServiceGrpcTransport +try: + from google.api_core import client_logging # 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.ai.generativelanguage.v1beta3.PermissionService", + "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.ai.generativelanguage.v1beta3.PermissionService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class PermissionServiceGrpcAsyncIOTransport(PermissionServiceTransport): """gRPC AsyncIO backend transport for PermissionService. @@ -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_permission( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_permission" not in self._stubs: - self._stubs["create_permission"] = self.grpc_channel.unary_unary( + self._stubs["create_permission"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta3.PermissionService/CreatePermission", request_serializer=permission_service.CreatePermissionRequest.serialize, response_deserializer=gag_permission.Permission.deserialize, @@ -297,7 +382,7 @@ def get_permission( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_permission" not in self._stubs: - self._stubs["get_permission"] = self.grpc_channel.unary_unary( + self._stubs["get_permission"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta3.PermissionService/GetPermission", request_serializer=permission_service.GetPermissionRequest.serialize, response_deserializer=permission.Permission.deserialize, @@ -326,7 +411,7 @@ def list_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_permissions" not in self._stubs: - self._stubs["list_permissions"] = self.grpc_channel.unary_unary( + self._stubs["list_permissions"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta3.PermissionService/ListPermissions", request_serializer=permission_service.ListPermissionsRequest.serialize, response_deserializer=permission_service.ListPermissionsResponse.deserialize, @@ -355,7 +440,7 @@ def update_permission( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_permission" not in self._stubs: - self._stubs["update_permission"] = self.grpc_channel.unary_unary( + self._stubs["update_permission"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta3.PermissionService/UpdatePermission", request_serializer=permission_service.UpdatePermissionRequest.serialize, response_deserializer=gag_permission.Permission.deserialize, @@ -383,7 +468,7 @@ def delete_permission( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_permission" not in self._stubs: - self._stubs["delete_permission"] = self.grpc_channel.unary_unary( + self._stubs["delete_permission"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta3.PermissionService/DeletePermission", request_serializer=permission_service.DeletePermissionRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -415,7 +500,7 @@ def transfer_ownership( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "transfer_ownership" not in self._stubs: - self._stubs["transfer_ownership"] = self.grpc_channel.unary_unary( + self._stubs["transfer_ownership"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta3.PermissionService/TransferOwnership", request_serializer=permission_service.TransferOwnershipRequest.serialize, response_deserializer=permission_service.TransferOwnershipResponse.deserialize, @@ -463,7 +548,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-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/permission_service/transports/rest.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/permission_service/transports/rest.py index f01988273d68..b97f34e8cd62 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/permission_service/transports/rest.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/permission_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, @@ -117,8 +125,11 @@ def post_update_permission(self, response): def pre_create_permission( self, request: permission_service.CreatePermissionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[permission_service.CreatePermissionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + permission_service.CreatePermissionRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_permission Override in a subclass to manipulate the request or metadata @@ -140,8 +151,11 @@ def post_create_permission( def pre_delete_permission( self, request: permission_service.DeletePermissionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[permission_service.DeletePermissionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + permission_service.DeletePermissionRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_permission Override in a subclass to manipulate the request or metadata @@ -152,8 +166,10 @@ def pre_delete_permission( def pre_get_permission( self, request: permission_service.GetPermissionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[permission_service.GetPermissionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + permission_service.GetPermissionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_permission Override in a subclass to manipulate the request or metadata @@ -175,8 +191,11 @@ def post_get_permission( def pre_list_permissions( self, request: permission_service.ListPermissionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[permission_service.ListPermissionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + permission_service.ListPermissionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_permissions Override in a subclass to manipulate the request or metadata @@ -198,8 +217,11 @@ def post_list_permissions( def pre_transfer_ownership( self, request: permission_service.TransferOwnershipRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[permission_service.TransferOwnershipRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + permission_service.TransferOwnershipRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for transfer_ownership Override in a subclass to manipulate the request or metadata @@ -221,8 +243,11 @@ def post_transfer_ownership( def pre_update_permission( self, request: permission_service.UpdatePermissionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[permission_service.UpdatePermissionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + permission_service.UpdatePermissionRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_permission Override in a subclass to manipulate the request or metadata @@ -365,7 +390,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gag_permission.Permission: r"""Call the create permission method over HTTP. @@ -375,8 +400,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gag_permission.Permission: @@ -409,6 +436,7 @@ def __call__( http_options = ( _BasePermissionServiceRestTransport._BaseCreatePermission._get_http_options() ) + request, metadata = self._interceptor.pre_create_permission( request, metadata ) @@ -425,6 +453,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta3.PermissionServiceClient.CreatePermission", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.PermissionService", + "rpcName": "CreatePermission", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PermissionServiceRestTransport._CreatePermission._get_response( self._host, @@ -446,7 +501,29 @@ def __call__( pb_resp = gag_permission.Permission.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_permission(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gag_permission.Permission.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta3.PermissionServiceClient.create_permission", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.PermissionService", + "rpcName": "CreatePermission", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeletePermission( @@ -484,7 +561,7 @@ 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 permission method over HTTP. @@ -494,13 +571,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 = ( _BasePermissionServiceRestTransport._BaseDeletePermission._get_http_options() ) + request, metadata = self._interceptor.pre_delete_permission( request, metadata ) @@ -513,6 +593,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta3.PermissionServiceClient.DeletePermission", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.PermissionService", + "rpcName": "DeletePermission", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PermissionServiceRestTransport._DeletePermission._get_response( self._host, @@ -563,7 +670,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> permission.Permission: r"""Call the get permission method over HTTP. @@ -574,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: ~.permission.Permission: @@ -608,6 +717,7 @@ def __call__( http_options = ( _BasePermissionServiceRestTransport._BaseGetPermission._get_http_options() ) + request, metadata = self._interceptor.pre_get_permission(request, metadata) transcoded_request = _BasePermissionServiceRestTransport._BaseGetPermission._get_transcoded_request( http_options, request @@ -618,6 +728,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta3.PermissionServiceClient.GetPermission", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.PermissionService", + "rpcName": "GetPermission", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PermissionServiceRestTransport._GetPermission._get_response( self._host, @@ -638,7 +775,29 @@ def __call__( pb_resp = permission.Permission.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_permission(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = permission.Permission.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta3.PermissionServiceClient.get_permission", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.PermissionService", + "rpcName": "GetPermission", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListPermissions( @@ -676,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]]] = (), ) -> permission_service.ListPermissionsResponse: r"""Call the list permissions method over HTTP. @@ -686,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: ~.permission_service.ListPermissionsResponse: @@ -699,6 +860,7 @@ def __call__( http_options = ( _BasePermissionServiceRestTransport._BaseListPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_list_permissions( request, metadata ) @@ -711,6 +873,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta3.PermissionServiceClient.ListPermissions", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.PermissionService", + "rpcName": "ListPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PermissionServiceRestTransport._ListPermissions._get_response( self._host, @@ -731,7 +920,31 @@ def __call__( pb_resp = permission_service.ListPermissionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_permissions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + permission_service.ListPermissionsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta3.PermissionServiceClient.list_permissions", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.PermissionService", + "rpcName": "ListPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TransferOwnership( @@ -770,7 +983,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> permission_service.TransferOwnershipResponse: r"""Call the transfer ownership method over HTTP. @@ -781,8 +994,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.permission_service.TransferOwnershipResponse: @@ -792,6 +1007,7 @@ def __call__( http_options = ( _BasePermissionServiceRestTransport._BaseTransferOwnership._get_http_options() ) + request, metadata = self._interceptor.pre_transfer_ownership( request, metadata ) @@ -808,6 +1024,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta3.PermissionServiceClient.TransferOwnership", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.PermissionService", + "rpcName": "TransferOwnership", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PermissionServiceRestTransport._TransferOwnership._get_response( self._host, @@ -829,7 +1072,31 @@ def __call__( pb_resp = permission_service.TransferOwnershipResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_transfer_ownership(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + permission_service.TransferOwnershipResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta3.PermissionServiceClient.transfer_ownership", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.PermissionService", + "rpcName": "TransferOwnership", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdatePermission( @@ -868,7 +1135,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gag_permission.Permission: r"""Call the update permission method over HTTP. @@ -878,8 +1145,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gag_permission.Permission: @@ -912,6 +1181,7 @@ def __call__( http_options = ( _BasePermissionServiceRestTransport._BaseUpdatePermission._get_http_options() ) + request, metadata = self._interceptor.pre_update_permission( request, metadata ) @@ -928,6 +1198,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta3.PermissionServiceClient.UpdatePermission", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.PermissionService", + "rpcName": "UpdatePermission", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = PermissionServiceRestTransport._UpdatePermission._get_response( self._host, @@ -949,7 +1246,29 @@ def __call__( pb_resp = gag_permission.Permission.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_permission(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gag_permission.Permission.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta3.PermissionServiceClient.update_permission", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.PermissionService", + "rpcName": "UpdatePermission", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/text_service/async_client.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/text_service/async_client.py index 69c1df66a614..dc4b8063f78c 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/text_service/async_client.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/text_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, @@ -50,6 +51,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, TextServiceTransport from .transports.grpc_asyncio import TextServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class TextServiceAsyncClient: """API for using Generative Language Models (GLMs) trained to @@ -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.ai.generativelanguage_v1beta3.TextServiceAsyncClient`.", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.TextService", + "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.ai.generativelanguage.v1beta3.TextService", + "credentialsType": None, + }, + ) + async def generate_text( self, request: Optional[Union[text_service.GenerateTextRequest, dict]] = None, @@ -268,7 +300,7 @@ async def generate_text( top_k: Optional[int] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> text_service.GenerateTextResponse: r"""Generates a response from the model given an input message. @@ -398,8 +430,10 @@ async def sample_generate_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.ai.generativelanguage_v1beta3.types.GenerateTextResponse: @@ -483,7 +517,7 @@ async def embed_text( text: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> text_service.EmbedTextResponse: r"""Generates an embedding from the model given an input message. @@ -537,8 +571,10 @@ async def sample_embed_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.ai.generativelanguage_v1beta3.types.EmbedTextResponse: @@ -600,7 +636,7 @@ async def batch_embed_text( texts: 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]]] = (), ) -> text_service.BatchEmbedTextResponse: r"""Generates multiple embeddings from the model given input text in a synchronous call. @@ -657,8 +693,10 @@ async def sample_batch_embed_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.ai.generativelanguage_v1beta3.types.BatchEmbedTextResponse: @@ -720,7 +758,7 @@ async def count_text_tokens( prompt: Optional[text_service.TextPrompt] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> text_service.CountTextTokensResponse: r"""Runs a model's tokenizer on a text and returns the token count. @@ -784,8 +822,10 @@ async def sample_count_text_tokens(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta3.types.CountTextTokensResponse: diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/text_service/client.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/text_service/client.py index a9ca258b4b31..7e3cdb3458fe 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/text_service/client.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/text_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.longrunning import operations_pb2 # type: ignore from google.ai.generativelanguage_v1beta3.types import safety, text_service @@ -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,6 +650,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.ai.generativelanguage_v1beta3.TextServiceClient`.", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.TextService", + "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.ai.generativelanguage.v1beta3.TextService", + "credentialsType": None, + }, + ) + def generate_text( self, request: Optional[Union[text_service.GenerateTextRequest, dict]] = None, @@ -649,7 +686,7 @@ def generate_text( top_k: Optional[int] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> text_service.GenerateTextResponse: r"""Generates a response from the model given an input message. @@ -779,8 +816,10 @@ def sample_generate_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.ai.generativelanguage_v1beta3.types.GenerateTextResponse: @@ -861,7 +900,7 @@ def embed_text( text: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> text_service.EmbedTextResponse: r"""Generates an embedding from the model given an input message. @@ -915,8 +954,10 @@ def sample_embed_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.ai.generativelanguage_v1beta3.types.EmbedTextResponse: @@ -975,7 +1016,7 @@ def batch_embed_text( texts: 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]]] = (), ) -> text_service.BatchEmbedTextResponse: r"""Generates multiple embeddings from the model given input text in a synchronous call. @@ -1032,8 +1073,10 @@ def sample_batch_embed_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.ai.generativelanguage_v1beta3.types.BatchEmbedTextResponse: @@ -1092,7 +1135,7 @@ def count_text_tokens( prompt: Optional[text_service.TextPrompt] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> text_service.CountTextTokensResponse: r"""Runs a model's tokenizer on a text and returns the token count. @@ -1156,8 +1199,10 @@ def sample_count_text_tokens(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.ai.generativelanguage_v1beta3.types.CountTextTokensResponse: diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/text_service/transports/grpc.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/text_service/transports/grpc.py index 93be6e7f2784..081dca677a18 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/text_service/transports/grpc.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/text_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.ai.generativelanguage_v1beta3.types import text_service from .base import DEFAULT_CLIENT_INFO, TextServiceTransport +try: + from google.api_core import client_logging # 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.ai.generativelanguage.v1beta3.TextService", + "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.ai.generativelanguage.v1beta3.TextService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TextServiceGrpcTransport(TextServiceTransport): """gRPC backend transport for TextService. @@ -183,7 +264,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientInterceptor() + self._logged_channel = grpc.intercept_channel( + self._grpc_channel, self._interceptor + ) + + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @classmethod @@ -260,7 +346,7 @@ def generate_text( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_text" not in self._stubs: - self._stubs["generate_text"] = self.grpc_channel.unary_unary( + self._stubs["generate_text"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta3.TextService/GenerateText", request_serializer=text_service.GenerateTextRequest.serialize, response_deserializer=text_service.GenerateTextResponse.deserialize, @@ -287,7 +373,7 @@ def embed_text( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "embed_text" not in self._stubs: - self._stubs["embed_text"] = self.grpc_channel.unary_unary( + self._stubs["embed_text"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta3.TextService/EmbedText", request_serializer=text_service.EmbedTextRequest.serialize, response_deserializer=text_service.EmbedTextResponse.deserialize, @@ -316,7 +402,7 @@ def batch_embed_text( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_embed_text" not in self._stubs: - self._stubs["batch_embed_text"] = self.grpc_channel.unary_unary( + self._stubs["batch_embed_text"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta3.TextService/BatchEmbedText", request_serializer=text_service.BatchEmbedTextRequest.serialize, response_deserializer=text_service.BatchEmbedTextResponse.deserialize, @@ -345,7 +431,7 @@ def count_text_tokens( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "count_text_tokens" not in self._stubs: - self._stubs["count_text_tokens"] = self.grpc_channel.unary_unary( + self._stubs["count_text_tokens"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta3.TextService/CountTextTokens", request_serializer=text_service.CountTextTokensRequest.serialize, response_deserializer=text_service.CountTextTokensResponse.deserialize, @@ -353,7 +439,7 @@ def count_text_tokens( return self._stubs["count_text_tokens"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/text_service/transports/grpc_asyncio.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/text_service/transports/grpc_asyncio.py index 983c7d42f906..a0ef11df8bcb 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/text_service/transports/grpc_asyncio.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/text_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.ai.generativelanguage_v1beta3.types import text_service from .base import DEFAULT_CLIENT_INFO, TextServiceTransport from .grpc import TextServiceGrpcTransport +try: + from google.api_core import client_logging # 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.ai.generativelanguage.v1beta3.TextService", + "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.ai.generativelanguage.v1beta3.TextService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TextServiceGrpcAsyncIOTransport(TextServiceTransport): """gRPC AsyncIO backend transport for TextService. @@ -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 generate_text( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_text" not in self._stubs: - self._stubs["generate_text"] = self.grpc_channel.unary_unary( + self._stubs["generate_text"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta3.TextService/GenerateText", request_serializer=text_service.GenerateTextRequest.serialize, response_deserializer=text_service.GenerateTextResponse.deserialize, @@ -297,7 +382,7 @@ def embed_text( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "embed_text" not in self._stubs: - self._stubs["embed_text"] = self.grpc_channel.unary_unary( + self._stubs["embed_text"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta3.TextService/EmbedText", request_serializer=text_service.EmbedTextRequest.serialize, response_deserializer=text_service.EmbedTextResponse.deserialize, @@ -327,7 +412,7 @@ def batch_embed_text( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_embed_text" not in self._stubs: - self._stubs["batch_embed_text"] = self.grpc_channel.unary_unary( + self._stubs["batch_embed_text"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta3.TextService/BatchEmbedText", request_serializer=text_service.BatchEmbedTextRequest.serialize, response_deserializer=text_service.BatchEmbedTextResponse.deserialize, @@ -357,7 +442,7 @@ def count_text_tokens( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "count_text_tokens" not in self._stubs: - self._stubs["count_text_tokens"] = self.grpc_channel.unary_unary( + self._stubs["count_text_tokens"] = self._logged_channel.unary_unary( "/google.ai.generativelanguage.v1beta3.TextService/CountTextTokens", request_serializer=text_service.CountTextTokensRequest.serialize, response_deserializer=text_service.CountTextTokensResponse.deserialize, @@ -395,7 +480,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-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/text_service/transports/rest.py b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/text_service/transports/rest.py index 3ec2c8cd804d..033bddb0f427 100644 --- a/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/text_service/transports/rest.py +++ b/packages/google-ai-generativelanguage/google/ai/generativelanguage_v1beta3/services/text_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, @@ -102,8 +110,10 @@ def post_generate_text(self, response): def pre_batch_embed_text( self, request: text_service.BatchEmbedTextRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[text_service.BatchEmbedTextRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + text_service.BatchEmbedTextRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for batch_embed_text Override in a subclass to manipulate the request or metadata @@ -125,8 +135,10 @@ def post_batch_embed_text( def pre_count_text_tokens( self, request: text_service.CountTextTokensRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[text_service.CountTextTokensRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + text_service.CountTextTokensRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for count_text_tokens Override in a subclass to manipulate the request or metadata @@ -148,8 +160,8 @@ def post_count_text_tokens( def pre_embed_text( self, request: text_service.EmbedTextRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[text_service.EmbedTextRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[text_service.EmbedTextRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for embed_text Override in a subclass to manipulate the request or metadata @@ -171,8 +183,10 @@ def post_embed_text( def pre_generate_text( self, request: text_service.GenerateTextRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[text_service.GenerateTextRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + text_service.GenerateTextRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for generate_text Override in a subclass to manipulate the request or metadata @@ -316,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]]] = (), ) -> text_service.BatchEmbedTextResponse: r"""Call the batch embed text method over HTTP. @@ -327,8 +341,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.text_service.BatchEmbedTextResponse: @@ -338,6 +354,7 @@ def __call__( http_options = ( _BaseTextServiceRestTransport._BaseBatchEmbedText._get_http_options() ) + request, metadata = self._interceptor.pre_batch_embed_text( request, metadata ) @@ -354,6 +371,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta3.TextServiceClient.BatchEmbedText", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.TextService", + "rpcName": "BatchEmbedText", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TextServiceRestTransport._BatchEmbedText._get_response( self._host, @@ -375,7 +419,31 @@ def __call__( pb_resp = text_service.BatchEmbedTextResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_embed_text(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = text_service.BatchEmbedTextResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta3.TextServiceClient.batch_embed_text", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.TextService", + "rpcName": "BatchEmbedText", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CountTextTokens( @@ -413,7 +481,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> text_service.CountTextTokensResponse: r"""Call the count text tokens method over HTTP. @@ -427,8 +495,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.text_service.CountTextTokensResponse: @@ -442,6 +512,7 @@ def __call__( http_options = ( _BaseTextServiceRestTransport._BaseCountTextTokens._get_http_options() ) + request, metadata = self._interceptor.pre_count_text_tokens( request, metadata ) @@ -458,6 +529,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta3.TextServiceClient.CountTextTokens", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.TextService", + "rpcName": "CountTextTokens", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TextServiceRestTransport._CountTextTokens._get_response( self._host, @@ -479,7 +577,31 @@ def __call__( pb_resp = text_service.CountTextTokensResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_count_text_tokens(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = text_service.CountTextTokensResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta3.TextServiceClient.count_text_tokens", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.TextService", + "rpcName": "CountTextTokens", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _EmbedText(_BaseTextServiceRestTransport._BaseEmbedText, TextServiceRestStub): @@ -515,7 +637,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> text_service.EmbedTextResponse: r"""Call the embed text method over HTTP. @@ -526,8 +648,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.text_service.EmbedTextResponse: @@ -537,6 +661,7 @@ def __call__( http_options = ( _BaseTextServiceRestTransport._BaseEmbedText._get_http_options() ) + request, metadata = self._interceptor.pre_embed_text(request, metadata) transcoded_request = ( _BaseTextServiceRestTransport._BaseEmbedText._get_transcoded_request( @@ -555,6 +680,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta3.TextServiceClient.EmbedText", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.TextService", + "rpcName": "EmbedText", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TextServiceRestTransport._EmbedText._get_response( self._host, @@ -576,7 +728,29 @@ def __call__( pb_resp = text_service.EmbedTextResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_embed_text(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = text_service.EmbedTextResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta3.TextServiceClient.embed_text", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.TextService", + "rpcName": "EmbedText", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GenerateText( @@ -614,7 +788,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> text_service.GenerateTextResponse: r"""Call the generate text method over HTTP. @@ -625,8 +799,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.text_service.GenerateTextResponse: @@ -638,6 +814,7 @@ def __call__( http_options = ( _BaseTextServiceRestTransport._BaseGenerateText._get_http_options() ) + request, metadata = self._interceptor.pre_generate_text(request, metadata) transcoded_request = ( _BaseTextServiceRestTransport._BaseGenerateText._get_transcoded_request( @@ -658,6 +835,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.ai.generativelanguage_v1beta3.TextServiceClient.GenerateText", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.TextService", + "rpcName": "GenerateText", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TextServiceRestTransport._GenerateText._get_response( self._host, @@ -679,7 +883,31 @@ def __call__( pb_resp = text_service.GenerateTextResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_generate_text(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = text_service.GenerateTextResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.ai.generativelanguage_v1beta3.TextServiceClient.generate_text", + extra={ + "serviceName": "google.ai.generativelanguage.v1beta3.TextService", + "rpcName": "GenerateText", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-ai-generativelanguage/samples/generated_samples/snippet_metadata_google.ai.generativelanguage.v1.json b/packages/google-ai-generativelanguage/samples/generated_samples/snippet_metadata_google.ai.generativelanguage.v1.json index bfb0d898350d..87bcca60fb53 100644 --- a/packages/google-ai-generativelanguage/samples/generated_samples/snippet_metadata_google.ai.generativelanguage.v1.json +++ b/packages/google-ai-generativelanguage/samples/generated_samples/snippet_metadata_google.ai.generativelanguage.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-ai-generativelanguage", - "version": "0.6.13" + "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.ai.generativelanguage_v1.types.BatchEmbedContentsResponse", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1.types.BatchEmbedContentsResponse", @@ -220,7 +220,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1.types.CountTokensResponse", @@ -304,7 +304,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1.types.CountTokensResponse", @@ -389,7 +389,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1.types.EmbedContentResponse", @@ -473,7 +473,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1.types.EmbedContentResponse", @@ -558,7 +558,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1.types.GenerateContentResponse", @@ -642,7 +642,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1.types.GenerateContentResponse", @@ -727,7 +727,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.ai.generativelanguage_v1.types.GenerateContentResponse]", @@ -811,7 +811,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.ai.generativelanguage_v1.types.GenerateContentResponse]", @@ -892,7 +892,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1.types.Model", @@ -972,7 +972,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1.types.Model", @@ -1057,7 +1057,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1.services.model_service.pagers.ListModelsAsyncPager", @@ -1141,7 +1141,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1.services.model_service.pagers.ListModelsPager", diff --git a/packages/google-ai-generativelanguage/samples/generated_samples/snippet_metadata_google.ai.generativelanguage.v1beta.json b/packages/google-ai-generativelanguage/samples/generated_samples/snippet_metadata_google.ai.generativelanguage.v1beta.json index 5ae07141c0da..ad4cc6847367 100644 --- a/packages/google-ai-generativelanguage/samples/generated_samples/snippet_metadata_google.ai.generativelanguage.v1beta.json +++ b/packages/google-ai-generativelanguage/samples/generated_samples/snippet_metadata_google.ai.generativelanguage.v1beta.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-ai-generativelanguage", - "version": "0.6.13" + "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.ai.generativelanguage_v1beta.types.CachedContent", @@ -127,7 +127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.CachedContent", @@ -208,7 +208,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_cached_content" @@ -285,7 +285,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_cached_content" @@ -363,7 +363,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.CachedContent", @@ -443,7 +443,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.CachedContent", @@ -520,7 +520,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.services.cache_service.pagers.ListCachedContentsAsyncPager", @@ -596,7 +596,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.services.cache_service.pagers.ListCachedContentsPager", @@ -681,7 +681,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.CachedContent", @@ -765,7 +765,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.CachedContent", @@ -850,7 +850,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.CountMessageTokensResponse", @@ -934,7 +934,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.CountMessageTokensResponse", @@ -1035,7 +1035,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.GenerateMessageResponse", @@ -1135,7 +1135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.GenerateMessageResponse", @@ -1212,7 +1212,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.CreateFileResponse", @@ -1288,7 +1288,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.CreateFileResponse", @@ -1369,7 +1369,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_file" @@ -1446,7 +1446,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_file" @@ -1524,7 +1524,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.File", @@ -1604,7 +1604,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.File", @@ -1681,7 +1681,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.services.file_service.pagers.ListFilesAsyncPager", @@ -1757,7 +1757,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.services.file_service.pagers.ListFilesPager", @@ -1842,7 +1842,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.BatchEmbedContentsResponse", @@ -1926,7 +1926,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.BatchEmbedContentsResponse", @@ -2011,7 +2011,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.CountTokensResponse", @@ -2095,7 +2095,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.CountTokensResponse", @@ -2180,7 +2180,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.EmbedContentResponse", @@ -2264,7 +2264,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.EmbedContentResponse", @@ -2357,7 +2357,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.GenerateAnswerResponse", @@ -2449,7 +2449,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.GenerateAnswerResponse", @@ -2534,7 +2534,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.GenerateContentResponse", @@ -2618,7 +2618,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.GenerateContentResponse", @@ -2703,7 +2703,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.ai.generativelanguage_v1beta.types.GenerateContentResponse]", @@ -2787,7 +2787,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.ai.generativelanguage_v1beta.types.GenerateContentResponse]", @@ -2872,7 +2872,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2956,7 +2956,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3037,7 +3037,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_tuned_model" @@ -3114,7 +3114,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_tuned_model" @@ -3192,7 +3192,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.Model", @@ -3272,7 +3272,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.Model", @@ -3353,7 +3353,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.TunedModel", @@ -3433,7 +3433,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.TunedModel", @@ -3518,7 +3518,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.services.model_service.pagers.ListModelsAsyncPager", @@ -3602,7 +3602,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.services.model_service.pagers.ListModelsPager", @@ -3687,7 +3687,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.services.model_service.pagers.ListTunedModelsAsyncPager", @@ -3771,7 +3771,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.services.model_service.pagers.ListTunedModelsPager", @@ -3856,7 +3856,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.TunedModel", @@ -3940,7 +3940,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.TunedModel", @@ -4025,7 +4025,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.Permission", @@ -4109,7 +4109,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.Permission", @@ -4190,7 +4190,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_permission" @@ -4267,7 +4267,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_permission" @@ -4345,7 +4345,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.Permission", @@ -4425,7 +4425,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.Permission", @@ -4506,7 +4506,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.services.permission_service.pagers.ListPermissionsAsyncPager", @@ -4586,7 +4586,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.services.permission_service.pagers.ListPermissionsPager", @@ -4663,7 +4663,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.TransferOwnershipResponse", @@ -4739,7 +4739,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.TransferOwnershipResponse", @@ -4824,7 +4824,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.Permission", @@ -4908,7 +4908,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.Permission", @@ -4993,7 +4993,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.PredictResponse", @@ -5077,7 +5077,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.PredictResponse", @@ -5154,7 +5154,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.BatchCreateChunksResponse", @@ -5230,7 +5230,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.BatchCreateChunksResponse", @@ -5307,7 +5307,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "batch_delete_chunks" @@ -5380,7 +5380,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "batch_delete_chunks" @@ -5454,7 +5454,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.BatchUpdateChunksResponse", @@ -5530,7 +5530,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.BatchUpdateChunksResponse", @@ -5615,7 +5615,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.Chunk", @@ -5699,7 +5699,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.Chunk", @@ -5780,7 +5780,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.Corpus", @@ -5860,7 +5860,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.Corpus", @@ -5945,7 +5945,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.Document", @@ -6029,7 +6029,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.Document", @@ -6110,7 +6110,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_chunk" @@ -6187,7 +6187,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_chunk" @@ -6265,7 +6265,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_corpus" @@ -6342,7 +6342,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_corpus" @@ -6420,7 +6420,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_document" @@ -6497,7 +6497,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_document" @@ -6575,7 +6575,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.Chunk", @@ -6655,7 +6655,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.Chunk", @@ -6736,7 +6736,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.Corpus", @@ -6816,7 +6816,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.Corpus", @@ -6897,7 +6897,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.Document", @@ -6977,7 +6977,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.Document", @@ -7058,7 +7058,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.services.retriever_service.pagers.ListChunksAsyncPager", @@ -7138,7 +7138,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.services.retriever_service.pagers.ListChunksPager", @@ -7215,7 +7215,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.services.retriever_service.pagers.ListCorporaAsyncPager", @@ -7291,7 +7291,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.services.retriever_service.pagers.ListCorporaPager", @@ -7372,7 +7372,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.services.retriever_service.pagers.ListDocumentsAsyncPager", @@ -7452,7 +7452,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.services.retriever_service.pagers.ListDocumentsPager", @@ -7529,7 +7529,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.QueryCorpusResponse", @@ -7605,7 +7605,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.QueryCorpusResponse", @@ -7682,7 +7682,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.QueryDocumentResponse", @@ -7758,7 +7758,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.QueryDocumentResponse", @@ -7843,7 +7843,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.Chunk", @@ -7927,7 +7927,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.Chunk", @@ -8012,7 +8012,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.Corpus", @@ -8096,7 +8096,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.Corpus", @@ -8181,7 +8181,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.Document", @@ -8265,7 +8265,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.Document", @@ -8350,7 +8350,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.BatchEmbedTextResponse", @@ -8434,7 +8434,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.BatchEmbedTextResponse", @@ -8519,7 +8519,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.CountTextTokensResponse", @@ -8603,7 +8603,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.CountTextTokensResponse", @@ -8688,7 +8688,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.EmbedTextResponse", @@ -8772,7 +8772,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.EmbedTextResponse", @@ -8877,7 +8877,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.GenerateTextResponse", @@ -8981,7 +8981,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta.types.GenerateTextResponse", diff --git a/packages/google-ai-generativelanguage/samples/generated_samples/snippet_metadata_google.ai.generativelanguage.v1beta2.json b/packages/google-ai-generativelanguage/samples/generated_samples/snippet_metadata_google.ai.generativelanguage.v1beta2.json index 7b5e11c820f3..8eb2001adab2 100644 --- a/packages/google-ai-generativelanguage/samples/generated_samples/snippet_metadata_google.ai.generativelanguage.v1beta2.json +++ b/packages/google-ai-generativelanguage/samples/generated_samples/snippet_metadata_google.ai.generativelanguage.v1beta2.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-ai-generativelanguage", - "version": "0.6.13" + "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.ai.generativelanguage_v1beta2.types.CountMessageTokensResponse", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta2.types.CountMessageTokensResponse", @@ -236,7 +236,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta2.types.GenerateMessageResponse", @@ -336,7 +336,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta2.types.GenerateMessageResponse", @@ -417,7 +417,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta2.types.Model", @@ -497,7 +497,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta2.types.Model", @@ -582,7 +582,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta2.services.model_service.pagers.ListModelsAsyncPager", @@ -666,7 +666,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta2.services.model_service.pagers.ListModelsPager", @@ -751,7 +751,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta2.types.EmbedTextResponse", @@ -835,7 +835,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta2.types.EmbedTextResponse", @@ -940,7 +940,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta2.types.GenerateTextResponse", @@ -1044,7 +1044,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta2.types.GenerateTextResponse", diff --git a/packages/google-ai-generativelanguage/samples/generated_samples/snippet_metadata_google.ai.generativelanguage.v1beta3.json b/packages/google-ai-generativelanguage/samples/generated_samples/snippet_metadata_google.ai.generativelanguage.v1beta3.json index e4b3562047a0..2d108f936e84 100644 --- a/packages/google-ai-generativelanguage/samples/generated_samples/snippet_metadata_google.ai.generativelanguage.v1beta3.json +++ b/packages/google-ai-generativelanguage/samples/generated_samples/snippet_metadata_google.ai.generativelanguage.v1beta3.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-ai-generativelanguage", - "version": "0.6.13" + "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.ai.generativelanguage_v1beta3.types.CountMessageTokensResponse", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta3.types.CountMessageTokensResponse", @@ -236,7 +236,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta3.types.GenerateMessageResponse", @@ -336,7 +336,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta3.types.GenerateMessageResponse", @@ -421,7 +421,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -505,7 +505,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]]]" } ], "shortName": "delete_tuned_model" @@ -663,7 +663,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_tuned_model" @@ -741,7 +741,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta3.types.Model", @@ -821,7 +821,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta3.types.Model", @@ -902,7 +902,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta3.types.TunedModel", @@ -982,7 +982,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta3.types.TunedModel", @@ -1067,7 +1067,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta3.services.model_service.pagers.ListModelsAsyncPager", @@ -1151,7 +1151,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta3.services.model_service.pagers.ListModelsPager", @@ -1236,7 +1236,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta3.services.model_service.pagers.ListTunedModelsAsyncPager", @@ -1320,7 +1320,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta3.services.model_service.pagers.ListTunedModelsPager", @@ -1405,7 +1405,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta3.types.TunedModel", @@ -1489,7 +1489,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta3.types.TunedModel", @@ -1574,7 +1574,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta3.types.Permission", @@ -1658,7 +1658,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta3.types.Permission", @@ -1739,7 +1739,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_permission" @@ -1816,7 +1816,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_permission" @@ -1894,7 +1894,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta3.types.Permission", @@ -1974,7 +1974,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta3.types.Permission", @@ -2055,7 +2055,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta3.services.permission_service.pagers.ListPermissionsAsyncPager", @@ -2135,7 +2135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta3.services.permission_service.pagers.ListPermissionsPager", @@ -2212,7 +2212,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta3.types.TransferOwnershipResponse", @@ -2288,7 +2288,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta3.types.TransferOwnershipResponse", @@ -2373,7 +2373,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta3.types.Permission", @@ -2457,7 +2457,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta3.types.Permission", @@ -2542,7 +2542,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta3.types.BatchEmbedTextResponse", @@ -2626,7 +2626,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta3.types.BatchEmbedTextResponse", @@ -2711,7 +2711,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta3.types.CountTextTokensResponse", @@ -2795,7 +2795,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta3.types.CountTextTokensResponse", @@ -2880,7 +2880,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta3.types.EmbedTextResponse", @@ -2964,7 +2964,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta3.types.EmbedTextResponse", @@ -3069,7 +3069,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta3.types.GenerateTextResponse", @@ -3173,7 +3173,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.ai.generativelanguage_v1beta3.types.GenerateTextResponse", diff --git a/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1/test_generative_service.py b/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1/test_generative_service.py index 7701a4b9a677..3f811fb7f4af 100644 --- a/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1/test_generative_service.py +++ b/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1/test_generative_service.py @@ -2898,6 +2898,7 @@ def test_generate_content_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.generate_content(request) @@ -2952,6 +2953,7 @@ def test_generate_content_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.generate_content(**mock_args) @@ -3089,6 +3091,7 @@ def test_stream_generate_content_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} with mock.patch.object(response_value, "iter_content") as iter_content: iter_content.return_value = iter(json_return_value) @@ -3146,6 +3149,7 @@ def test_stream_generate_content_rest_flattened(): json_return_value = "[{}]".format(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"} with mock.patch.object(response_value, "iter_content") as iter_content: iter_content.return_value = iter(json_return_value) @@ -3280,6 +3284,7 @@ def test_embed_content_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.embed_content(request) @@ -3334,6 +3339,7 @@ def test_embed_content_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.embed_content(**mock_args) @@ -3471,6 +3477,7 @@ def test_batch_embed_contents_rest_required_fields( response_value._content = json_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_embed_contents(request) @@ -3525,6 +3532,7 @@ def test_batch_embed_contents_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_embed_contents(**mock_args) @@ -3657,6 +3665,7 @@ def test_count_tokens_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.count_tokens(request) @@ -3703,6 +3712,7 @@ def test_count_tokens_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.count_tokens(**mock_args) @@ -4122,6 +4132,7 @@ def test_generate_content_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.generate_content(request) @@ -4157,6 +4168,7 @@ def test_generate_content_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.generate_content(request) # Establish that the response is the type that we expect. @@ -4197,6 +4209,7 @@ def test_generate_content_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = generative_service.GenerateContentResponse.to_json( generative_service.GenerateContentResponse() ) @@ -4243,6 +4256,7 @@ def test_stream_generate_content_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.stream_generate_content(request) @@ -4279,6 +4293,7 @@ def test_stream_generate_content_rest_call_success(request_type): json_return_value = "[{}]".format(json_return_value) response_value.iter_content = mock.Mock(return_value=iter(json_return_value)) req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.stream_generate_content(request) assert isinstance(response, Iterable) @@ -4322,6 +4337,7 @@ def test_stream_generate_content_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = generative_service.GenerateContentResponse.to_json( generative_service.GenerateContentResponse() ) @@ -4368,6 +4384,7 @@ def test_embed_content_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.embed_content(request) @@ -4401,6 +4418,7 @@ def test_embed_content_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.embed_content(request) # Establish that the response is the type that we expect. @@ -4440,6 +4458,7 @@ def test_embed_content_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = generative_service.EmbedContentResponse.to_json( generative_service.EmbedContentResponse() ) @@ -4486,6 +4505,7 @@ def test_batch_embed_contents_rest_bad_request( response_value.status_code = 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_embed_contents(request) @@ -4519,6 +4539,7 @@ def test_batch_embed_contents_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_embed_contents(request) # Establish that the response is the type that we expect. @@ -4558,6 +4579,7 @@ def test_batch_embed_contents_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = generative_service.BatchEmbedContentsResponse.to_json( generative_service.BatchEmbedContentsResponse() ) @@ -4604,6 +4626,7 @@ def test_count_tokens_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.count_tokens(request) @@ -4639,6 +4662,7 @@ def test_count_tokens_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.count_tokens(request) # Establish that the response is the type that we expect. @@ -4679,6 +4703,7 @@ def test_count_tokens_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = generative_service.CountTokensResponse.to_json( generative_service.CountTokensResponse() ) @@ -4727,6 +4752,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) @@ -4757,6 +4783,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) @@ -4787,6 +4814,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) @@ -4817,6 +4845,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) @@ -4845,6 +4874,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) @@ -4875,6 +4905,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-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1/test_model_service.py b/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1/test_model_service.py index 4321e032b0e9..d2403acffb14 100644 --- a/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1/test_model_service.py +++ b/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1/test_model_service.py @@ -1966,6 +1966,7 @@ def test_get_model_rest_required_fields(request_type=model_service.GetModelReque response_value._content = json_return_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) @@ -2011,6 +2012,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) @@ -2103,6 +2105,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) @@ -2443,6 +2446,7 @@ def test_get_model_rest_bad_request(request_type=model_service.GetModelRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_model(request) @@ -2489,6 +2493,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. @@ -2540,6 +2545,7 @@ def test_get_model_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = model.Model.to_json(model.Model()) req.return_value.content = return_value @@ -2582,6 +2588,7 @@ def test_list_models_rest_bad_request(request_type=model_service.ListModelsReque response_value.status_code = 400 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) @@ -2617,6 +2624,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. @@ -2657,6 +2665,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 = model_service.ListModelsResponse.to_json( model_service.ListModelsResponse() ) @@ -2705,6 +2714,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) @@ -2735,6 +2745,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) @@ -2765,6 +2776,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) @@ -2795,6 +2807,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) @@ -2823,6 +2836,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) @@ -2853,6 +2867,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-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta/test_cache_service.py b/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta/test_cache_service.py index 72d28f53bf74..94bb3702eed2 100644 --- a/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta/test_cache_service.py +++ b/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta/test_cache_service.py @@ -2986,6 +2986,7 @@ def test_create_cached_content_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_cached_content(request) @@ -3033,6 +3034,7 @@ def test_create_cached_content_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_cached_content(**mock_args) @@ -3168,6 +3170,7 @@ def test_get_cached_content_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_cached_content(request) @@ -3213,6 +3216,7 @@ def test_get_cached_content_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_cached_content(**mock_args) @@ -3345,6 +3349,7 @@ def test_update_cached_content_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_cached_content(request) @@ -3393,6 +3398,7 @@ def test_update_cached_content_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_cached_content(**mock_args) @@ -3528,6 +3534,7 @@ def test_delete_cached_content_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_cached_content(request) @@ -3571,6 +3578,7 @@ def test_delete_cached_content_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_cached_content(**mock_args) @@ -4008,6 +4016,7 @@ def test_list_cached_contents_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_cached_contents(request) @@ -4043,6 +4052,7 @@ def test_list_cached_contents_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_cached_contents(request) # Establish that the response is the type that we expect. @@ -4083,6 +4093,7 @@ def test_list_cached_contents_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = cache_service.ListCachedContentsResponse.to_json( cache_service.ListCachedContentsResponse() ) @@ -4129,6 +4140,7 @@ def test_create_cached_content_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_cached_content(request) @@ -4299,6 +4311,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_cached_content(request) # Establish that the response is the type that we expect. @@ -4341,6 +4354,7 @@ def test_create_cached_content_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = gag_cached_content.CachedContent.to_json( gag_cached_content.CachedContent() ) @@ -4387,6 +4401,7 @@ def test_get_cached_content_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_cached_content(request) @@ -4424,6 +4439,7 @@ def test_get_cached_content_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_cached_content(request) # Establish that the response is the type that we expect. @@ -4466,6 +4482,7 @@ def test_get_cached_content_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = cached_content.CachedContent.to_json( cached_content.CachedContent() ) @@ -4512,6 +4529,7 @@ def test_update_cached_content_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_cached_content(request) @@ -4682,6 +4700,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_cached_content(request) # Establish that the response is the type that we expect. @@ -4724,6 +4743,7 @@ def test_update_cached_content_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = gag_cached_content.CachedContent.to_json( gag_cached_content.CachedContent() ) @@ -4770,6 +4790,7 @@ def test_delete_cached_content_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_cached_content(request) @@ -4800,6 +4821,7 @@ def test_delete_cached_content_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_cached_content(request) # Establish that the response is the type that we expect. @@ -4836,6 +4858,7 @@ def test_delete_cached_content_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = cache_service.DeleteCachedContentRequest() metadata = [ @@ -4878,6 +4901,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) @@ -4908,6 +4932,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) @@ -4936,6 +4961,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) @@ -4966,6 +4992,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-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta/test_discuss_service.py b/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta/test_discuss_service.py index 83030f8d9f57..0f0e41c98c2c 100644 --- a/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta/test_discuss_service.py +++ b/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta/test_discuss_service.py @@ -1878,6 +1878,7 @@ def test_generate_message_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.generate_message(request) @@ -1936,6 +1937,7 @@ def test_generate_message_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.generate_message(**mock_args) @@ -2076,6 +2078,7 @@ def test_count_message_tokens_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.count_message_tokens(request) @@ -2130,6 +2133,7 @@ def test_count_message_tokens_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.count_message_tokens(**mock_args) @@ -2405,6 +2409,7 @@ def test_generate_message_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.generate_message(request) @@ -2438,6 +2443,7 @@ def test_generate_message_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.generate_message(request) # Establish that the response is the type that we expect. @@ -2477,6 +2483,7 @@ def test_generate_message_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = discuss_service.GenerateMessageResponse.to_json( discuss_service.GenerateMessageResponse() ) @@ -2523,6 +2530,7 @@ def test_count_message_tokens_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.count_message_tokens(request) @@ -2558,6 +2566,7 @@ def test_count_message_tokens_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.count_message_tokens(request) # Establish that the response is the type that we expect. @@ -2598,6 +2607,7 @@ def test_count_message_tokens_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = discuss_service.CountMessageTokensResponse.to_json( discuss_service.CountMessageTokensResponse() ) @@ -2646,6 +2656,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) @@ -2676,6 +2687,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) @@ -2704,6 +2716,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) @@ -2734,6 +2747,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-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta/test_file_service.py b/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta/test_file_service.py index 0c08de78bec9..dba74cbfa712 100644 --- a/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta/test_file_service.py +++ b/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta/test_file_service.py @@ -2452,6 +2452,7 @@ def test_get_file_rest_required_fields(request_type=file_service.GetFileRequest) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_file(request) @@ -2497,6 +2498,7 @@ def test_get_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_file(**mock_args) @@ -2621,6 +2623,7 @@ def test_delete_file_rest_required_fields(request_type=file_service.DeleteFileRe response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_file(request) @@ -2664,6 +2667,7 @@ def test_delete_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_file(**mock_args) @@ -3029,6 +3033,7 @@ def test_create_file_rest_bad_request(request_type=file_service.CreateFileReques response_value.status_code = 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_file(request) @@ -3062,6 +3067,7 @@ def test_create_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.create_file(request) # Establish that the response is the type that we expect. @@ -3099,6 +3105,7 @@ def test_create_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 = file_service.CreateFileResponse.to_json( file_service.CreateFileResponse() ) @@ -3143,6 +3150,7 @@ def test_list_files_rest_bad_request(request_type=file_service.ListFilesRequest) response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_files(request) @@ -3178,6 +3186,7 @@ def test_list_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_files(request) # Establish that the response is the type that we expect. @@ -3216,6 +3225,7 @@ def test_list_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 = file_service.ListFilesResponse.to_json( file_service.ListFilesResponse() ) @@ -3260,6 +3270,7 @@ def test_get_file_rest_bad_request(request_type=file_service.GetFileRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_file(request) @@ -3301,6 +3312,7 @@ def test_get_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_file(request) # Establish that the response is the type that we expect. @@ -3345,6 +3357,7 @@ def test_get_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 = file.File.to_json(file.File()) req.return_value.content = return_value @@ -3387,6 +3400,7 @@ def test_delete_file_rest_bad_request(request_type=file_service.DeleteFileReques response_value.status_code = 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_file(request) @@ -3417,6 +3431,7 @@ def test_delete_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_file(request) # Establish that the response is the type that we expect. @@ -3451,6 +3466,7 @@ def test_delete_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 = file_service.DeleteFileRequest() metadata = [ @@ -3493,6 +3509,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) @@ -3523,6 +3540,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) @@ -3551,6 +3569,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) @@ -3581,6 +3600,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-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta/test_generative_service.py b/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta/test_generative_service.py index 5582acedaacf..6264482575e5 100644 --- a/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta/test_generative_service.py +++ b/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta/test_generative_service.py @@ -3285,6 +3285,7 @@ def test_generate_content_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.generate_content(request) @@ -3339,6 +3340,7 @@ def test_generate_content_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.generate_content(**mock_args) @@ -3471,6 +3473,7 @@ def test_generate_answer_rest_required_fields( response_value._content = json_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_answer(request) @@ -3532,6 +3535,7 @@ def test_generate_answer_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_answer(**mock_args) @@ -3676,6 +3680,7 @@ def test_stream_generate_content_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} with mock.patch.object(response_value, "iter_content") as iter_content: iter_content.return_value = iter(json_return_value) @@ -3733,6 +3738,7 @@ def test_stream_generate_content_rest_flattened(): json_return_value = "[{}]".format(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"} with mock.patch.object(response_value, "iter_content") as iter_content: iter_content.return_value = iter(json_return_value) @@ -3867,6 +3873,7 @@ def test_embed_content_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.embed_content(request) @@ -3921,6 +3928,7 @@ def test_embed_content_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.embed_content(**mock_args) @@ -4058,6 +4066,7 @@ def test_batch_embed_contents_rest_required_fields( response_value._content = json_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_embed_contents(request) @@ -4112,6 +4121,7 @@ def test_batch_embed_contents_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_embed_contents(**mock_args) @@ -4244,6 +4254,7 @@ def test_count_tokens_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.count_tokens(request) @@ -4290,6 +4301,7 @@ def test_count_tokens_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.count_tokens(**mock_args) @@ -4758,6 +4770,7 @@ def test_generate_content_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.generate_content(request) @@ -4793,6 +4806,7 @@ def test_generate_content_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.generate_content(request) # Establish that the response is the type that we expect. @@ -4833,6 +4847,7 @@ def test_generate_content_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = generative_service.GenerateContentResponse.to_json( generative_service.GenerateContentResponse() ) @@ -4879,6 +4894,7 @@ def test_generate_answer_rest_bad_request( response_value.status_code = 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_answer(request) @@ -4914,6 +4930,7 @@ def test_generate_answer_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_answer(request) # Establish that the response is the type that we expect. @@ -4954,6 +4971,7 @@ def test_generate_answer_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = generative_service.GenerateAnswerResponse.to_json( generative_service.GenerateAnswerResponse() ) @@ -5000,6 +5018,7 @@ def test_stream_generate_content_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.stream_generate_content(request) @@ -5036,6 +5055,7 @@ def test_stream_generate_content_rest_call_success(request_type): json_return_value = "[{}]".format(json_return_value) response_value.iter_content = mock.Mock(return_value=iter(json_return_value)) req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.stream_generate_content(request) assert isinstance(response, Iterable) @@ -5079,6 +5099,7 @@ def test_stream_generate_content_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = generative_service.GenerateContentResponse.to_json( generative_service.GenerateContentResponse() ) @@ -5125,6 +5146,7 @@ def test_embed_content_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.embed_content(request) @@ -5158,6 +5180,7 @@ def test_embed_content_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.embed_content(request) # Establish that the response is the type that we expect. @@ -5197,6 +5220,7 @@ def test_embed_content_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = generative_service.EmbedContentResponse.to_json( generative_service.EmbedContentResponse() ) @@ -5243,6 +5267,7 @@ def test_batch_embed_contents_rest_bad_request( response_value.status_code = 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_embed_contents(request) @@ -5276,6 +5301,7 @@ def test_batch_embed_contents_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_embed_contents(request) # Establish that the response is the type that we expect. @@ -5315,6 +5341,7 @@ def test_batch_embed_contents_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = generative_service.BatchEmbedContentsResponse.to_json( generative_service.BatchEmbedContentsResponse() ) @@ -5361,6 +5388,7 @@ def test_count_tokens_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.count_tokens(request) @@ -5397,6 +5425,7 @@ def test_count_tokens_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.count_tokens(request) # Establish that the response is the type that we expect. @@ -5438,6 +5467,7 @@ def test_count_tokens_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = generative_service.CountTokensResponse.to_json( generative_service.CountTokensResponse() ) @@ -5486,6 +5516,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) @@ -5516,6 +5547,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) @@ -5544,6 +5576,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) @@ -5574,6 +5607,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-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta/test_model_service.py b/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta/test_model_service.py index 2ec7f51e316c..0a325329ebe4 100644 --- a/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta/test_model_service.py +++ b/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta/test_model_service.py @@ -3859,6 +3859,7 @@ def test_get_model_rest_required_fields(request_type=model_service.GetModelReque response_value._content = json_return_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) @@ -3904,6 +3905,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) @@ -3996,6 +3998,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) @@ -4187,6 +4190,7 @@ def test_get_tuned_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_tuned_model(request) @@ -4232,6 +4236,7 @@ def test_get_tuned_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_tuned_model(**mock_args) @@ -4326,6 +4331,7 @@ def test_list_tuned_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_tuned_models(**mock_args) @@ -4522,6 +4528,7 @@ def test_create_tuned_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_tuned_model(request) @@ -4570,6 +4577,7 @@ def test_create_tuned_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_tuned_model(**mock_args) @@ -4706,6 +4714,7 @@ def test_update_tuned_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.update_tuned_model(request) @@ -4756,6 +4765,7 @@ def test_update_tuned_model_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_tuned_model(**mock_args) @@ -4892,6 +4902,7 @@ def test_delete_tuned_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_tuned_model(request) @@ -4935,6 +4946,7 @@ def test_delete_tuned_model_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_tuned_model(**mock_args) @@ -5479,6 +5491,7 @@ def test_get_model_rest_bad_request(request_type=model_service.GetModelRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_model(request) @@ -5525,6 +5538,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. @@ -5576,6 +5590,7 @@ def test_get_model_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = model.Model.to_json(model.Model()) req.return_value.content = return_value @@ -5618,6 +5633,7 @@ def test_list_models_rest_bad_request(request_type=model_service.ListModelsReque response_value.status_code = 400 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) @@ -5653,6 +5669,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. @@ -5693,6 +5710,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 = model_service.ListModelsResponse.to_json( model_service.ListModelsResponse() ) @@ -5739,6 +5757,7 @@ def test_get_tuned_model_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_tuned_model(request) @@ -5782,6 +5801,7 @@ def test_get_tuned_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_tuned_model(request) # Establish that the response is the type that we expect. @@ -5829,6 +5849,7 @@ def test_get_tuned_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 = tuned_model.TunedModel.to_json(tuned_model.TunedModel()) req.return_value.content = return_value @@ -5873,6 +5894,7 @@ def test_list_tuned_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_tuned_models(request) @@ -5908,6 +5930,7 @@ def test_list_tuned_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_tuned_models(request) # Establish that the response is the type that we expect. @@ -5948,6 +5971,7 @@ def test_list_tuned_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 = model_service.ListTunedModelsResponse.to_json( model_service.ListTunedModelsResponse() ) @@ -5994,6 +6018,7 @@ def test_create_tuned_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_tuned_model(request) @@ -6128,6 +6153,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_tuned_model(request) # Establish that the response is the type that we expect. @@ -6169,6 +6195,7 @@ def test_create_tuned_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 @@ -6213,6 +6240,7 @@ def test_update_tuned_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.update_tuned_model(request) @@ -6360,6 +6388,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_tuned_model(request) # Establish that the response is the type that we expect. @@ -6407,6 +6436,7 @@ def test_update_tuned_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 = gag_tuned_model.TunedModel.to_json(gag_tuned_model.TunedModel()) req.return_value.content = return_value @@ -6451,6 +6481,7 @@ def test_delete_tuned_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_tuned_model(request) @@ -6481,6 +6512,7 @@ def test_delete_tuned_model_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_tuned_model(request) # Establish that the response is the type that we expect. @@ -6517,6 +6549,7 @@ def test_delete_tuned_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"} request = model_service.DeleteTunedModelRequest() metadata = [ @@ -6559,6 +6592,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) @@ -6589,6 +6623,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) @@ -6617,6 +6652,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) @@ -6647,6 +6683,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-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta/test_permission_service.py b/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta/test_permission_service.py index 344d4d6b2196..5d1db613de20 100644 --- a/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta/test_permission_service.py +++ b/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta/test_permission_service.py @@ -3365,6 +3365,7 @@ def test_create_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.create_permission(request) @@ -3419,6 +3420,7 @@ def test_create_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.create_permission(**mock_args) @@ -3550,6 +3552,7 @@ def test_get_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_permission(request) @@ -3595,6 +3598,7 @@ def test_get_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_permission(**mock_args) @@ -3734,6 +3738,7 @@ def test_list_permissions_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_permissions(request) @@ -3787,6 +3792,7 @@ def test_list_permissions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_permissions(**mock_args) @@ -3980,6 +3986,7 @@ def test_update_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.update_permission(request) @@ -4036,6 +4043,7 @@ def test_update_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.update_permission(**mock_args) @@ -4167,6 +4175,7 @@ def test_delete_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.delete_permission(request) @@ -4210,6 +4219,7 @@ def test_delete_permission_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_permission(**mock_args) @@ -4349,6 +4359,7 @@ def test_transfer_ownership_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.transfer_ownership(request) @@ -4829,6 +4840,7 @@ def test_create_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.create_permission(request) @@ -4940,6 +4952,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_permission(request) # Establish that the response is the type that we expect. @@ -4983,6 +4996,7 @@ def test_create_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 = gag_permission.Permission.to_json(gag_permission.Permission()) req.return_value.content = return_value @@ -5027,6 +5041,7 @@ def test_get_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_permission(request) @@ -5065,6 +5080,7 @@ def test_get_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_permission(request) # Establish that the response is the type that we expect. @@ -5108,6 +5124,7 @@ def test_get_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 = permission.Permission.to_json(permission.Permission()) req.return_value.content = return_value @@ -5152,6 +5169,7 @@ def test_list_permissions_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_permissions(request) @@ -5187,6 +5205,7 @@ def test_list_permissions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_permissions(request) # Establish that the response is the type that we expect. @@ -5227,6 +5246,7 @@ def test_list_permissions_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = permission_service.ListPermissionsResponse.to_json( permission_service.ListPermissionsResponse() ) @@ -5273,6 +5293,7 @@ def test_update_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.update_permission(request) @@ -5384,6 +5405,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_permission(request) # Establish that the response is the type that we expect. @@ -5427,6 +5449,7 @@ def test_update_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 = gag_permission.Permission.to_json(gag_permission.Permission()) req.return_value.content = return_value @@ -5471,6 +5494,7 @@ def test_delete_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.delete_permission(request) @@ -5501,6 +5525,7 @@ def test_delete_permission_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_permission(request) # Establish that the response is the type that we expect. @@ -5537,6 +5562,7 @@ def test_delete_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"} request = permission_service.DeletePermissionRequest() metadata = [ @@ -5577,6 +5603,7 @@ def test_transfer_ownership_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.transfer_ownership(request) @@ -5610,6 +5637,7 @@ def test_transfer_ownership_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.transfer_ownership(request) # Establish that the response is the type that we expect. @@ -5649,6 +5677,7 @@ def test_transfer_ownership_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = permission_service.TransferOwnershipResponse.to_json( permission_service.TransferOwnershipResponse() ) @@ -5697,6 +5726,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) @@ -5727,6 +5757,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) @@ -5755,6 +5786,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) @@ -5785,6 +5817,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-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta/test_prediction_service.py b/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta/test_prediction_service.py index b9cc5c6e844a..2da4cddf7b82 100644 --- a/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta/test_prediction_service.py +++ b/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta/test_prediction_service.py @@ -1525,6 +1525,7 @@ def test_predict_rest_required_fields(request_type=prediction_service.PredictReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.predict(request) @@ -1579,6 +1580,7 @@ def test_predict_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.predict(**mock_args) @@ -1799,6 +1801,7 @@ def test_predict_rest_bad_request(request_type=prediction_service.PredictRequest response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.predict(request) @@ -1832,6 +1835,7 @@ def test_predict_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.predict(request) # Establish that the response is the type that we expect. @@ -1871,6 +1875,7 @@ def test_predict_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = prediction_service.PredictResponse.to_json( prediction_service.PredictResponse() ) @@ -1919,6 +1924,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) @@ -1949,6 +1955,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) @@ -1977,6 +1984,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) @@ -2007,6 +2015,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-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta/test_retriever_service.py b/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta/test_retriever_service.py index 20ced997ab09..4ecb0a8c1b04 100644 --- a/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta/test_retriever_service.py +++ b/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta/test_retriever_service.py @@ -7634,6 +7634,7 @@ def test_create_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.create_corpus(request) @@ -7679,6 +7680,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) @@ -7808,6 +7810,7 @@ def test_get_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.get_corpus(request) @@ -7853,6 +7856,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) @@ -7980,6 +7984,7 @@ def test_update_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.update_corpus(request) @@ -8034,6 +8039,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) @@ -8163,6 +8169,7 @@ def test_delete_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.delete_corpus(request) @@ -8206,6 +8213,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) @@ -8439,6 +8447,7 @@ def test_query_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.query_corpus(request) @@ -8567,6 +8576,7 @@ def test_create_document_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_document(request) @@ -8621,6 +8631,7 @@ def test_create_document_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_document(**mock_args) @@ -8751,6 +8762,7 @@ def test_get_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.get_document(request) @@ -8796,6 +8808,7 @@ def test_get_document_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_document(**mock_args) @@ -8923,6 +8936,7 @@ def test_update_document_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_document(request) @@ -8977,6 +8991,7 @@ def test_update_document_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_document(**mock_args) @@ -9107,6 +9122,7 @@ def test_delete_document_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_document(request) @@ -9150,6 +9166,7 @@ def test_delete_document_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_document(**mock_args) @@ -9286,6 +9303,7 @@ def test_list_documents_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_documents(request) @@ -9339,6 +9357,7 @@ def test_list_documents_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_documents(**mock_args) @@ -9536,6 +9555,7 @@ def test_query_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.query_document(request) @@ -9664,6 +9684,7 @@ def test_create_chunk_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_chunk(request) @@ -9718,6 +9739,7 @@ def test_create_chunk_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_chunk(**mock_args) @@ -9849,6 +9871,7 @@ def test_batch_create_chunks_rest_required_fields( response_value._content = json_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_chunks(request) @@ -9966,6 +9989,7 @@ def test_get_chunk_rest_required_fields(request_type=retriever_service.GetChunkR response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_chunk(request) @@ -10011,6 +10035,7 @@ def test_get_chunk_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_chunk(**mock_args) @@ -10139,6 +10164,7 @@ def test_update_chunk_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_chunk(request) @@ -10195,6 +10221,7 @@ def test_update_chunk_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_chunk(**mock_args) @@ -10327,6 +10354,7 @@ def test_batch_update_chunks_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.batch_update_chunks(request) @@ -10443,6 +10471,7 @@ def test_delete_chunk_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_chunk(request) @@ -10486,6 +10515,7 @@ def test_delete_chunk_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_chunk(**mock_args) @@ -10613,6 +10643,7 @@ def test_batch_delete_chunks_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.batch_delete_chunks(request) @@ -10739,6 +10770,7 @@ def test_list_chunks_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_chunks(request) @@ -10792,6 +10824,7 @@ def test_list_chunks_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_chunks(**mock_args) @@ -11988,6 +12021,7 @@ def test_create_corpus_rest_bad_request( response_value.status_code = 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) @@ -12097,6 +12131,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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. @@ -12138,6 +12173,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 = retriever.Corpus.to_json(retriever.Corpus()) req.return_value.content = return_value @@ -12180,6 +12216,7 @@ def test_get_corpus_rest_bad_request(request_type=retriever_service.GetCorpusReq response_value.status_code = 400 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) @@ -12216,6 +12253,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. @@ -12257,6 +12295,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 = retriever.Corpus.to_json(retriever.Corpus()) req.return_value.content = return_value @@ -12301,6 +12340,7 @@ def test_update_corpus_rest_bad_request( response_value.status_code = 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) @@ -12410,6 +12450,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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. @@ -12451,6 +12492,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 = retriever.Corpus.to_json(retriever.Corpus()) req.return_value.content = return_value @@ -12495,6 +12537,7 @@ def test_delete_corpus_rest_bad_request( response_value.status_code = 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) @@ -12525,6 +12568,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. @@ -12561,6 +12605,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 = retriever_service.DeleteCorpusRequest() metadata = [ @@ -12601,6 +12646,7 @@ def test_list_corpora_rest_bad_request( response_value.status_code = 400 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) @@ -12636,6 +12682,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. @@ -12676,6 +12723,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 = retriever_service.ListCorporaResponse.to_json( retriever_service.ListCorporaResponse() ) @@ -12722,6 +12770,7 @@ def test_query_corpus_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.query_corpus(request) @@ -12755,6 +12804,7 @@ def test_query_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.query_corpus(request) # Establish that the response is the type that we expect. @@ -12794,6 +12844,7 @@ def test_query_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 = retriever_service.QueryCorpusResponse.to_json( retriever_service.QueryCorpusResponse() ) @@ -12840,6 +12891,7 @@ def test_create_document_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_document(request) @@ -12957,6 +13009,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_document(request) # Establish that the response is the type that we expect. @@ -12998,6 +13051,7 @@ def test_create_document_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = retriever.Document.to_json(retriever.Document()) req.return_value.content = return_value @@ -13042,6 +13096,7 @@ def test_get_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.get_document(request) @@ -13078,6 +13133,7 @@ def test_get_document_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_document(request) # Establish that the response is the type that we expect. @@ -13119,6 +13175,7 @@ def test_get_document_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = retriever.Document.to_json(retriever.Document()) req.return_value.content = return_value @@ -13163,6 +13220,7 @@ def test_update_document_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_document(request) @@ -13280,6 +13338,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_document(request) # Establish that the response is the type that we expect. @@ -13321,6 +13380,7 @@ def test_update_document_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = retriever.Document.to_json(retriever.Document()) req.return_value.content = return_value @@ -13365,6 +13425,7 @@ def test_delete_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.delete_document(request) @@ -13395,6 +13456,7 @@ def test_delete_document_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_document(request) # Establish that the response is the type that we expect. @@ -13431,6 +13493,7 @@ def test_delete_document_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = retriever_service.DeleteDocumentRequest() metadata = [ @@ -13471,6 +13534,7 @@ def test_list_documents_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_documents(request) @@ -13506,6 +13570,7 @@ def test_list_documents_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_documents(request) # Establish that the response is the type that we expect. @@ -13546,6 +13611,7 @@ def test_list_documents_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = retriever_service.ListDocumentsResponse.to_json( retriever_service.ListDocumentsResponse() ) @@ -13592,6 +13658,7 @@ def test_query_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.query_document(request) @@ -13625,6 +13692,7 @@ def test_query_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.query_document(request) # Establish that the response is the type that we expect. @@ -13664,6 +13732,7 @@ def test_query_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 = retriever_service.QueryDocumentResponse.to_json( retriever_service.QueryDocumentResponse() ) @@ -13710,6 +13779,7 @@ def test_create_chunk_rest_bad_request( response_value.status_code = 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_chunk(request) @@ -13828,6 +13898,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_chunk(request) # Establish that the response is the type that we expect. @@ -13869,6 +13940,7 @@ def test_create_chunk_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = retriever.Chunk.to_json(retriever.Chunk()) req.return_value.content = return_value @@ -13913,6 +13985,7 @@ def test_batch_create_chunks_rest_bad_request( response_value.status_code = 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_chunks(request) @@ -13946,6 +14019,7 @@ def test_batch_create_chunks_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_chunks(request) # Establish that the response is the type that we expect. @@ -13985,6 +14059,7 @@ def test_batch_create_chunks_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = retriever_service.BatchCreateChunksResponse.to_json( retriever_service.BatchCreateChunksResponse() ) @@ -14029,6 +14104,7 @@ def test_get_chunk_rest_bad_request(request_type=retriever_service.GetChunkReque response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_chunk(request) @@ -14065,6 +14141,7 @@ def test_get_chunk_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_chunk(request) # Establish that the response is the type that we expect. @@ -14106,6 +14183,7 @@ def test_get_chunk_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = retriever.Chunk.to_json(retriever.Chunk()) req.return_value.content = return_value @@ -14152,6 +14230,7 @@ def test_update_chunk_rest_bad_request( response_value.status_code = 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_chunk(request) @@ -14272,6 +14351,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_chunk(request) # Establish that the response is the type that we expect. @@ -14313,6 +14393,7 @@ def test_update_chunk_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = retriever.Chunk.to_json(retriever.Chunk()) req.return_value.content = return_value @@ -14357,6 +14438,7 @@ def test_batch_update_chunks_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.batch_update_chunks(request) @@ -14390,6 +14472,7 @@ def test_batch_update_chunks_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.batch_update_chunks(request) # Establish that the response is the type that we expect. @@ -14429,6 +14512,7 @@ def test_batch_update_chunks_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = retriever_service.BatchUpdateChunksResponse.to_json( retriever_service.BatchUpdateChunksResponse() ) @@ -14475,6 +14559,7 @@ def test_delete_chunk_rest_bad_request( response_value.status_code = 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_chunk(request) @@ -14505,6 +14590,7 @@ def test_delete_chunk_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_chunk(request) # Establish that the response is the type that we expect. @@ -14541,6 +14627,7 @@ def test_delete_chunk_rest_interceptors(null_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 = retriever_service.DeleteChunkRequest() metadata = [ @@ -14581,6 +14668,7 @@ def test_batch_delete_chunks_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.batch_delete_chunks(request) @@ -14611,6 +14699,7 @@ def test_batch_delete_chunks_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_delete_chunks(request) # Establish that the response is the type that we expect. @@ -14647,6 +14736,7 @@ def test_batch_delete_chunks_rest_interceptors(null_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 = retriever_service.BatchDeleteChunksRequest() metadata = [ @@ -14685,6 +14775,7 @@ def test_list_chunks_rest_bad_request(request_type=retriever_service.ListChunksR response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_chunks(request) @@ -14720,6 +14811,7 @@ def test_list_chunks_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_chunks(request) # Establish that the response is the type that we expect. @@ -14760,6 +14852,7 @@ def test_list_chunks_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = retriever_service.ListChunksResponse.to_json( retriever_service.ListChunksResponse() ) @@ -14808,6 +14901,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) @@ -14838,6 +14932,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) @@ -14866,6 +14961,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) @@ -14896,6 +14992,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-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta/test_text_service.py b/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta/test_text_service.py index 55ceac4342a4..f4c3411358f8 100644 --- a/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta/test_text_service.py +++ b/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta/test_text_service.py @@ -2500,6 +2500,7 @@ def test_generate_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.generate_text(request) @@ -2559,6 +2560,7 @@ def test_generate_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.generate_text(**mock_args) @@ -2693,6 +2695,7 @@ def test_embed_text_rest_required_fields(request_type=text_service.EmbedTextRequ response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.embed_text(request) @@ -2739,6 +2742,7 @@ def test_embed_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.embed_text(**mock_args) @@ -2872,6 +2876,7 @@ def test_batch_embed_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_embed_text(request) @@ -2918,6 +2923,7 @@ def test_batch_embed_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.batch_embed_text(**mock_args) @@ -3052,6 +3058,7 @@ def test_count_text_tokens_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.count_text_tokens(request) @@ -3106,6 +3113,7 @@ def test_count_text_tokens_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.count_text_tokens(**mock_args) @@ -3471,6 +3479,7 @@ def test_generate_text_rest_bad_request(request_type=text_service.GenerateTextRe response_value.status_code = 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_text(request) @@ -3504,6 +3513,7 @@ def test_generate_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.generate_text(request) # Establish that the response is the type that we expect. @@ -3543,6 +3553,7 @@ def test_generate_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 = text_service.GenerateTextResponse.to_json( text_service.GenerateTextResponse() ) @@ -3587,6 +3598,7 @@ def test_embed_text_rest_bad_request(request_type=text_service.EmbedTextRequest) response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.embed_text(request) @@ -3620,6 +3632,7 @@ def test_embed_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.embed_text(request) # Establish that the response is the type that we expect. @@ -3657,6 +3670,7 @@ def test_embed_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 = text_service.EmbedTextResponse.to_json( text_service.EmbedTextResponse() ) @@ -3703,6 +3717,7 @@ def test_batch_embed_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_embed_text(request) @@ -3736,6 +3751,7 @@ def test_batch_embed_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_embed_text(request) # Establish that the response is the type that we expect. @@ -3775,6 +3791,7 @@ def test_batch_embed_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 = text_service.BatchEmbedTextResponse.to_json( text_service.BatchEmbedTextResponse() ) @@ -3821,6 +3838,7 @@ def test_count_text_tokens_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.count_text_tokens(request) @@ -3856,6 +3874,7 @@ def test_count_text_tokens_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.count_text_tokens(request) # Establish that the response is the type that we expect. @@ -3896,6 +3915,7 @@ def test_count_text_tokens_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = text_service.CountTextTokensResponse.to_json( text_service.CountTextTokensResponse() ) @@ -3944,6 +3964,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) @@ -3974,6 +3995,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) @@ -4002,6 +4024,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) @@ -4032,6 +4055,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-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta2/test_discuss_service.py b/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta2/test_discuss_service.py index 6745f00aecb3..ae755c101e55 100644 --- a/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta2/test_discuss_service.py +++ b/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta2/test_discuss_service.py @@ -1877,6 +1877,7 @@ def test_generate_message_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.generate_message(request) @@ -1935,6 +1936,7 @@ def test_generate_message_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.generate_message(**mock_args) @@ -2075,6 +2077,7 @@ def test_count_message_tokens_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.count_message_tokens(request) @@ -2129,6 +2132,7 @@ def test_count_message_tokens_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.count_message_tokens(**mock_args) @@ -2404,6 +2408,7 @@ def test_generate_message_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.generate_message(request) @@ -2437,6 +2442,7 @@ def test_generate_message_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.generate_message(request) # Establish that the response is the type that we expect. @@ -2476,6 +2482,7 @@ def test_generate_message_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = discuss_service.GenerateMessageResponse.to_json( discuss_service.GenerateMessageResponse() ) @@ -2522,6 +2529,7 @@ def test_count_message_tokens_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.count_message_tokens(request) @@ -2557,6 +2565,7 @@ def test_count_message_tokens_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.count_message_tokens(request) # Establish that the response is the type that we expect. @@ -2597,6 +2606,7 @@ def test_count_message_tokens_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = discuss_service.CountMessageTokensResponse.to_json( discuss_service.CountMessageTokensResponse() ) diff --git a/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta2/test_model_service.py b/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta2/test_model_service.py index eac582efe3d0..344c9b785904 100644 --- a/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta2/test_model_service.py +++ b/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta2/test_model_service.py @@ -1961,6 +1961,7 @@ def test_get_model_rest_required_fields(request_type=model_service.GetModelReque response_value._content = json_return_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) @@ -2006,6 +2007,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) @@ -2098,6 +2100,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) @@ -2439,6 +2442,7 @@ def test_get_model_rest_bad_request(request_type=model_service.GetModelRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_model(request) @@ -2484,6 +2488,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. @@ -2534,6 +2539,7 @@ def test_get_model_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = model.Model.to_json(model.Model()) req.return_value.content = return_value @@ -2576,6 +2582,7 @@ def test_list_models_rest_bad_request(request_type=model_service.ListModelsReque response_value.status_code = 400 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) @@ -2611,6 +2618,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. @@ -2651,6 +2659,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 = model_service.ListModelsResponse.to_json( model_service.ListModelsResponse() ) diff --git a/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta2/test_text_service.py b/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta2/test_text_service.py index 5dce1f43b446..d0e3e74b6eb9 100644 --- a/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta2/test_text_service.py +++ b/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta2/test_text_service.py @@ -1821,6 +1821,7 @@ def test_generate_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.generate_text(request) @@ -1880,6 +1881,7 @@ def test_generate_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.generate_text(**mock_args) @@ -2018,6 +2020,7 @@ def test_embed_text_rest_required_fields(request_type=text_service.EmbedTextRequ response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.embed_text(request) @@ -2072,6 +2075,7 @@ def test_embed_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.embed_text(**mock_args) @@ -2338,6 +2342,7 @@ def test_generate_text_rest_bad_request(request_type=text_service.GenerateTextRe response_value.status_code = 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_text(request) @@ -2371,6 +2376,7 @@ def test_generate_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.generate_text(request) # Establish that the response is the type that we expect. @@ -2410,6 +2416,7 @@ def test_generate_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 = text_service.GenerateTextResponse.to_json( text_service.GenerateTextResponse() ) @@ -2454,6 +2461,7 @@ def test_embed_text_rest_bad_request(request_type=text_service.EmbedTextRequest) response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.embed_text(request) @@ -2487,6 +2495,7 @@ def test_embed_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.embed_text(request) # Establish that the response is the type that we expect. @@ -2524,6 +2533,7 @@ def test_embed_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 = text_service.EmbedTextResponse.to_json( text_service.EmbedTextResponse() ) diff --git a/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta3/test_discuss_service.py b/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta3/test_discuss_service.py index 0440cb22380c..b0e1f7beddc8 100644 --- a/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta3/test_discuss_service.py +++ b/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta3/test_discuss_service.py @@ -1878,6 +1878,7 @@ def test_generate_message_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.generate_message(request) @@ -1936,6 +1937,7 @@ def test_generate_message_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.generate_message(**mock_args) @@ -2076,6 +2078,7 @@ def test_count_message_tokens_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.count_message_tokens(request) @@ -2130,6 +2133,7 @@ def test_count_message_tokens_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.count_message_tokens(**mock_args) @@ -2405,6 +2409,7 @@ def test_generate_message_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.generate_message(request) @@ -2438,6 +2443,7 @@ def test_generate_message_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.generate_message(request) # Establish that the response is the type that we expect. @@ -2477,6 +2483,7 @@ def test_generate_message_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = discuss_service.GenerateMessageResponse.to_json( discuss_service.GenerateMessageResponse() ) @@ -2523,6 +2530,7 @@ def test_count_message_tokens_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.count_message_tokens(request) @@ -2558,6 +2566,7 @@ def test_count_message_tokens_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.count_message_tokens(request) # Establish that the response is the type that we expect. @@ -2598,6 +2607,7 @@ def test_count_message_tokens_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = discuss_service.CountMessageTokensResponse.to_json( discuss_service.CountMessageTokensResponse() ) diff --git a/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta3/test_model_service.py b/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta3/test_model_service.py index 8247ca3c9236..18414da7feef 100644 --- a/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta3/test_model_service.py +++ b/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta3/test_model_service.py @@ -3845,6 +3845,7 @@ def test_get_model_rest_required_fields(request_type=model_service.GetModelReque response_value._content = json_return_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) @@ -3890,6 +3891,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) @@ -3982,6 +3984,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) @@ -4173,6 +4176,7 @@ def test_get_tuned_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_tuned_model(request) @@ -4218,6 +4222,7 @@ def test_get_tuned_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_tuned_model(**mock_args) @@ -4312,6 +4317,7 @@ def test_list_tuned_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_tuned_models(**mock_args) @@ -4508,6 +4514,7 @@ def test_create_tuned_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_tuned_model(request) @@ -4556,6 +4563,7 @@ def test_create_tuned_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_tuned_model(**mock_args) @@ -4692,6 +4700,7 @@ def test_update_tuned_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.update_tuned_model(request) @@ -4750,6 +4759,7 @@ def test_update_tuned_model_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_tuned_model(**mock_args) @@ -4886,6 +4896,7 @@ def test_delete_tuned_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_tuned_model(request) @@ -4929,6 +4940,7 @@ def test_delete_tuned_model_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_tuned_model(**mock_args) @@ -5470,6 +5482,7 @@ def test_get_model_rest_bad_request(request_type=model_service.GetModelRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_model(request) @@ -5515,6 +5528,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. @@ -5565,6 +5579,7 @@ def test_get_model_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = model.Model.to_json(model.Model()) req.return_value.content = return_value @@ -5607,6 +5622,7 @@ def test_list_models_rest_bad_request(request_type=model_service.ListModelsReque response_value.status_code = 400 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) @@ -5642,6 +5658,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. @@ -5682,6 +5699,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 = model_service.ListModelsResponse.to_json( model_service.ListModelsResponse() ) @@ -5728,6 +5746,7 @@ def test_get_tuned_model_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_tuned_model(request) @@ -5770,6 +5789,7 @@ def test_get_tuned_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_tuned_model(request) # Establish that the response is the type that we expect. @@ -5816,6 +5836,7 @@ def test_get_tuned_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 = tuned_model.TunedModel.to_json(tuned_model.TunedModel()) req.return_value.content = return_value @@ -5860,6 +5881,7 @@ def test_list_tuned_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_tuned_models(request) @@ -5895,6 +5917,7 @@ def test_list_tuned_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_tuned_models(request) # Establish that the response is the type that we expect. @@ -5935,6 +5958,7 @@ def test_list_tuned_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 = model_service.ListTunedModelsResponse.to_json( model_service.ListTunedModelsResponse() ) @@ -5981,6 +6005,7 @@ def test_create_tuned_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_tuned_model(request) @@ -6113,6 +6138,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_tuned_model(request) # Establish that the response is the type that we expect. @@ -6154,6 +6180,7 @@ def test_create_tuned_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 @@ -6198,6 +6225,7 @@ def test_update_tuned_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.update_tuned_model(request) @@ -6342,6 +6370,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_tuned_model(request) # Establish that the response is the type that we expect. @@ -6388,6 +6417,7 @@ def test_update_tuned_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 = gag_tuned_model.TunedModel.to_json(gag_tuned_model.TunedModel()) req.return_value.content = return_value @@ -6432,6 +6462,7 @@ def test_delete_tuned_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_tuned_model(request) @@ -6462,6 +6493,7 @@ def test_delete_tuned_model_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_tuned_model(request) # Establish that the response is the type that we expect. @@ -6498,6 +6530,7 @@ def test_delete_tuned_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"} request = model_service.DeleteTunedModelRequest() metadata = [ diff --git a/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta3/test_permission_service.py b/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta3/test_permission_service.py index 749dd92ab0b7..b10783b57a84 100644 --- a/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta3/test_permission_service.py +++ b/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta3/test_permission_service.py @@ -3365,6 +3365,7 @@ def test_create_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.create_permission(request) @@ -3419,6 +3420,7 @@ def test_create_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.create_permission(**mock_args) @@ -3550,6 +3552,7 @@ def test_get_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_permission(request) @@ -3595,6 +3598,7 @@ def test_get_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_permission(**mock_args) @@ -3734,6 +3738,7 @@ def test_list_permissions_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_permissions(request) @@ -3787,6 +3792,7 @@ def test_list_permissions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_permissions(**mock_args) @@ -3980,6 +3986,7 @@ def test_update_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.update_permission(request) @@ -4036,6 +4043,7 @@ def test_update_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.update_permission(**mock_args) @@ -4167,6 +4175,7 @@ def test_delete_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.delete_permission(request) @@ -4210,6 +4219,7 @@ def test_delete_permission_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_permission(**mock_args) @@ -4349,6 +4359,7 @@ def test_transfer_ownership_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.transfer_ownership(request) @@ -4829,6 +4840,7 @@ def test_create_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.create_permission(request) @@ -4940,6 +4952,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_permission(request) # Establish that the response is the type that we expect. @@ -4983,6 +4996,7 @@ def test_create_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 = gag_permission.Permission.to_json(gag_permission.Permission()) req.return_value.content = return_value @@ -5027,6 +5041,7 @@ def test_get_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_permission(request) @@ -5065,6 +5080,7 @@ def test_get_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_permission(request) # Establish that the response is the type that we expect. @@ -5108,6 +5124,7 @@ def test_get_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 = permission.Permission.to_json(permission.Permission()) req.return_value.content = return_value @@ -5152,6 +5169,7 @@ def test_list_permissions_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_permissions(request) @@ -5187,6 +5205,7 @@ def test_list_permissions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_permissions(request) # Establish that the response is the type that we expect. @@ -5227,6 +5246,7 @@ def test_list_permissions_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = permission_service.ListPermissionsResponse.to_json( permission_service.ListPermissionsResponse() ) @@ -5273,6 +5293,7 @@ def test_update_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.update_permission(request) @@ -5384,6 +5405,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_permission(request) # Establish that the response is the type that we expect. @@ -5427,6 +5449,7 @@ def test_update_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 = gag_permission.Permission.to_json(gag_permission.Permission()) req.return_value.content = return_value @@ -5471,6 +5494,7 @@ def test_delete_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.delete_permission(request) @@ -5501,6 +5525,7 @@ def test_delete_permission_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_permission(request) # Establish that the response is the type that we expect. @@ -5537,6 +5562,7 @@ def test_delete_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"} request = permission_service.DeletePermissionRequest() metadata = [ @@ -5577,6 +5603,7 @@ def test_transfer_ownership_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.transfer_ownership(request) @@ -5610,6 +5637,7 @@ def test_transfer_ownership_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.transfer_ownership(request) # Establish that the response is the type that we expect. @@ -5649,6 +5677,7 @@ def test_transfer_ownership_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = permission_service.TransferOwnershipResponse.to_json( permission_service.TransferOwnershipResponse() ) diff --git a/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta3/test_text_service.py b/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta3/test_text_service.py index f5fda3b37e0b..17dce0231d24 100644 --- a/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta3/test_text_service.py +++ b/packages/google-ai-generativelanguage/tests/unit/gapic/generativelanguage_v1beta3/test_text_service.py @@ -2500,6 +2500,7 @@ def test_generate_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.generate_text(request) @@ -2559,6 +2560,7 @@ def test_generate_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.generate_text(**mock_args) @@ -2697,6 +2699,7 @@ def test_embed_text_rest_required_fields(request_type=text_service.EmbedTextRequ response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.embed_text(request) @@ -2751,6 +2754,7 @@ def test_embed_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.embed_text(**mock_args) @@ -2888,6 +2892,7 @@ def test_batch_embed_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_embed_text(request) @@ -2942,6 +2947,7 @@ def test_batch_embed_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.batch_embed_text(**mock_args) @@ -3076,6 +3082,7 @@ def test_count_text_tokens_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.count_text_tokens(request) @@ -3130,6 +3137,7 @@ def test_count_text_tokens_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.count_text_tokens(**mock_args) @@ -3495,6 +3503,7 @@ def test_generate_text_rest_bad_request(request_type=text_service.GenerateTextRe response_value.status_code = 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_text(request) @@ -3528,6 +3537,7 @@ def test_generate_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.generate_text(request) # Establish that the response is the type that we expect. @@ -3567,6 +3577,7 @@ def test_generate_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 = text_service.GenerateTextResponse.to_json( text_service.GenerateTextResponse() ) @@ -3611,6 +3622,7 @@ def test_embed_text_rest_bad_request(request_type=text_service.EmbedTextRequest) response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.embed_text(request) @@ -3644,6 +3656,7 @@ def test_embed_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.embed_text(request) # Establish that the response is the type that we expect. @@ -3681,6 +3694,7 @@ def test_embed_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 = text_service.EmbedTextResponse.to_json( text_service.EmbedTextResponse() ) @@ -3727,6 +3741,7 @@ def test_batch_embed_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_embed_text(request) @@ -3760,6 +3775,7 @@ def test_batch_embed_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_embed_text(request) # Establish that the response is the type that we expect. @@ -3799,6 +3815,7 @@ def test_batch_embed_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 = text_service.BatchEmbedTextResponse.to_json( text_service.BatchEmbedTextResponse() ) @@ -3845,6 +3862,7 @@ def test_count_text_tokens_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.count_text_tokens(request) @@ -3880,6 +3898,7 @@ def test_count_text_tokens_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.count_text_tokens(request) # Establish that the response is the type that we expect. @@ -3920,6 +3939,7 @@ def test_count_text_tokens_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = text_service.CountTextTokensResponse.to_json( text_service.CountTextTokensResponse() ) diff --git a/packages/google-analytics-admin/google/analytics/admin/gapic_version.py b/packages/google-analytics-admin/google/analytics/admin/gapic_version.py index ea568fc1a5a7..558c8aab67c5 100644 --- a/packages/google-analytics-admin/google/analytics/admin/gapic_version.py +++ b/packages/google-analytics-admin/google/analytics/admin/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.23.2" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-analytics-admin/google/analytics/admin_v1alpha/gapic_version.py b/packages/google-analytics-admin/google/analytics/admin_v1alpha/gapic_version.py index ea568fc1a5a7..558c8aab67c5 100644 --- a/packages/google-analytics-admin/google/analytics/admin_v1alpha/gapic_version.py +++ b/packages/google-analytics-admin/google/analytics/admin_v1alpha/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.23.2" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/async_client.py b/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/async_client.py index 077a441ebdb6..b3e3c29acd1f 100644 --- a/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/async_client.py +++ b/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_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, @@ -68,6 +69,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, AnalyticsAdminServiceTransport from .transports.grpc_asyncio import AnalyticsAdminServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class AnalyticsAdminServiceAsyncClient: """Service Interface for the Analytics Admin API (GA4).""" @@ -451,6 +461,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.analytics.admin_v1alpha.AnalyticsAdminServiceAsyncClient`.", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "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.analytics.admin.v1alpha.AnalyticsAdminService", + "credentialsType": None, + }, + ) + async def get_account( self, request: Optional[Union[analytics_admin.GetAccountRequest, dict]] = None, @@ -458,7 +490,7 @@ async def get_account( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Account: r"""Lookup for a single Account. @@ -476,8 +508,10 @@ async def get_account( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.Account: @@ -537,7 +571,7 @@ async def list_accounts( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAccountsAsyncPager: r"""Returns all accounts accessible by the caller. @@ -552,8 +586,10 @@ async def list_accounts( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListAccountsAsyncPager: @@ -608,7 +644,7 @@ async def delete_account( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Marks target Account as soft-deleted (ie: "trashed") and returns it. @@ -639,8 +675,10 @@ async def delete_account( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -693,7 +731,7 @@ async def update_account( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Account: r"""Updates an account. @@ -721,8 +759,10 @@ async def update_account( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.Account: @@ -788,7 +828,7 @@ async def provision_account_ticket( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ProvisionAccountTicketResponse: r"""Requests a ticket for creating an account. @@ -799,8 +839,10 @@ async def provision_account_ticket( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.ProvisionAccountTicketResponse: @@ -842,7 +884,7 @@ async def list_account_summaries( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAccountSummariesAsyncPager: r"""Returns summaries of all accounts accessible by the caller. @@ -854,8 +896,10 @@ async def list_account_summaries( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListAccountSummariesAsyncPager: @@ -910,7 +954,7 @@ async def get_property( name: Optional[str] = None, retry: OptionalRetry = 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.Property: r"""Lookup for a single "GA4" Property. @@ -927,8 +971,10 @@ async def get_property( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.Property: @@ -988,7 +1034,7 @@ async def list_properties( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPropertiesAsyncPager: r"""Returns child Properties under the specified parent Account. @@ -1005,8 +1051,10 @@ async def list_properties( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListPropertiesAsyncPager: @@ -1061,7 +1109,7 @@ async def create_property( property: Optional[resources.Property] = None, retry: OptionalRetry = 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.Property: r"""Creates an "GA4" property with the specified location and attributes. @@ -1081,8 +1129,10 @@ async def create_property( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.Property: @@ -1137,7 +1187,7 @@ async def delete_property( name: Optional[str] = None, retry: OptionalRetry = 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.Property: r"""Marks target Property as soft-deleted (ie: "trashed") and returns it. @@ -1169,8 +1219,10 @@ async def delete_property( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.Property: @@ -1232,7 +1284,7 @@ async def update_property( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Property: r"""Updates a property. @@ -1261,8 +1313,10 @@ async def update_property( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.Property: @@ -1330,7 +1384,7 @@ async def create_firebase_link( firebase_link: Optional[resources.FirebaseLink] = None, retry: OptionalRetry = 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.FirebaseLink: r"""Creates a FirebaseLink. @@ -1358,8 +1412,10 @@ async def create_firebase_link( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.FirebaseLink: @@ -1424,7 +1480,7 @@ async def delete_firebase_link( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 FirebaseLink on a property @@ -1444,8 +1500,10 @@ async def delete_firebase_link( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -1497,7 +1555,7 @@ async def list_firebase_links( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListFirebaseLinksAsyncPager: r"""Lists FirebaseLinks on a property. Properties can have at most one FirebaseLink. @@ -1517,8 +1575,10 @@ async def list_firebase_links( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListFirebaseLinksAsyncPager: @@ -1593,7 +1653,7 @@ async def get_global_site_tag( name: Optional[str] = None, retry: OptionalRetry = 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.GlobalSiteTag: r"""Returns the Site Tag for the specified web stream. Site Tags are immutable singletons. @@ -1617,8 +1677,10 @@ async def get_global_site_tag( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.GlobalSiteTag: @@ -1684,7 +1746,7 @@ async def create_google_ads_link( google_ads_link: Optional[resources.GoogleAdsLink] = None, retry: OptionalRetry = 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.GoogleAdsLink: r"""Creates a GoogleAdsLink. @@ -1709,8 +1771,10 @@ async def create_google_ads_link( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.GoogleAdsLink: @@ -1776,7 +1840,7 @@ async def update_google_ads_link( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.GoogleAdsLink: r"""Updates a GoogleAdsLink on a property @@ -1802,8 +1866,10 @@ async def update_google_ads_link( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.GoogleAdsLink: @@ -1870,7 +1936,7 @@ async def delete_google_ads_link( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 GoogleAdsLink on a property @@ -1888,8 +1954,10 @@ async def delete_google_ads_link( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -1943,7 +2011,7 @@ async def list_google_ads_links( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListGoogleAdsLinksAsyncPager: r"""Lists GoogleAdsLinks on a property. @@ -1961,8 +2029,10 @@ async def list_google_ads_links( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListGoogleAdsLinksAsyncPager: @@ -2039,7 +2109,7 @@ async def get_data_sharing_settings( name: Optional[str] = None, retry: OptionalRetry = 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.DataSharingSettings: r"""Get data sharing settings on an account. Data sharing settings are singletons. @@ -2060,8 +2130,10 @@ async def get_data_sharing_settings( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.DataSharingSettings: @@ -2125,7 +2197,7 @@ async def get_measurement_protocol_secret( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.MeasurementProtocolSecret: r"""Lookup for a single "GA4" MeasurementProtocolSecret. @@ -2145,8 +2217,10 @@ async def get_measurement_protocol_secret( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.MeasurementProtocolSecret: @@ -2209,7 +2283,7 @@ async def list_measurement_protocol_secrets( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListMeasurementProtocolSecretsAsyncPager: r"""Returns child MeasurementProtocolSecrets under the specified parent Property. @@ -2230,8 +2304,10 @@ async def list_measurement_protocol_secrets( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListMeasurementProtocolSecretsAsyncPager: @@ -2313,7 +2389,7 @@ async def create_measurement_protocol_secret( ] = None, retry: OptionalRetry = 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.MeasurementProtocolSecret: r"""Creates a measurement protocol secret. @@ -2339,8 +2415,10 @@ async def create_measurement_protocol_secret( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.MeasurementProtocolSecret: @@ -2407,7 +2485,7 @@ async def delete_measurement_protocol_secret( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes target MeasurementProtocolSecret. @@ -2428,8 +2506,10 @@ async def delete_measurement_protocol_secret( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2488,7 +2568,7 @@ async def update_measurement_protocol_secret( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.MeasurementProtocolSecret: r"""Updates a measurement protocol secret. @@ -2514,8 +2594,10 @@ async def update_measurement_protocol_secret( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.MeasurementProtocolSecret: @@ -2588,7 +2670,7 @@ async def acknowledge_user_data_collection( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.AcknowledgeUserDataCollectionResponse: r"""Acknowledges the terms of user data collection for the specified property. @@ -2603,8 +2685,10 @@ async def acknowledge_user_data_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.analytics.admin_v1alpha.types.AcknowledgeUserDataCollectionResponse: @@ -2655,7 +2739,7 @@ async def get_sk_ad_network_conversion_value_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]]] = (), ) -> resources.SKAdNetworkConversionValueSchema: r"""Looks up a single SKAdNetworkConversionValueSchema. @@ -2674,8 +2758,10 @@ async def get_sk_ad_network_conversion_value_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.analytics.admin_v1alpha.types.SKAdNetworkConversionValueSchema: @@ -2745,7 +2831,7 @@ async def create_sk_ad_network_conversion_value_schema( ] = None, retry: OptionalRetry = 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.SKAdNetworkConversionValueSchema: r"""Creates a SKAdNetworkConversionValueSchema. @@ -2772,8 +2858,10 @@ async def create_sk_ad_network_conversion_value_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.analytics.admin_v1alpha.types.SKAdNetworkConversionValueSchema: @@ -2844,7 +2932,7 @@ async def delete_sk_ad_network_conversion_value_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 target SKAdNetworkConversionValueSchema. @@ -2864,8 +2952,10 @@ async def delete_sk_ad_network_conversion_value_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 @@ -2926,7 +3016,7 @@ async def update_sk_ad_network_conversion_value_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]]] = (), ) -> resources.SKAdNetworkConversionValueSchema: r"""Updates a SKAdNetworkConversionValueSchema. @@ -2953,8 +3043,10 @@ async def update_sk_ad_network_conversion_value_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.analytics.admin_v1alpha.types.SKAdNetworkConversionValueSchema: @@ -3032,7 +3124,7 @@ async def list_sk_ad_network_conversion_value_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.ListSKAdNetworkConversionValueSchemasAsyncPager: r"""Lists SKAdNetworkConversionValueSchema on a stream. Properties can have at most one @@ -3055,8 +3147,10 @@ async def list_sk_ad_network_conversion_value_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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListSKAdNetworkConversionValueSchemasAsyncPager: @@ -3136,7 +3230,7 @@ async def search_change_history_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]]] = (), ) -> pagers.SearchChangeHistoryEventsAsyncPager: r"""Searches through all changes to an account or its children given the specified set of filters. @@ -3148,8 +3242,10 @@ async def search_change_history_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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.SearchChangeHistoryEventsAsyncPager: @@ -3212,7 +3308,7 @@ async def get_google_signals_settings( name: Optional[str] = None, retry: OptionalRetry = 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.GoogleSignalsSettings: r"""Lookup for Google Signals settings for a property. @@ -3231,8 +3327,10 @@ async def get_google_signals_settings( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.GoogleSignalsSettings: @@ -3296,7 +3394,7 @@ async def update_google_signals_settings( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.GoogleSignalsSettings: r"""Updates Google Signals settings for a property. @@ -3324,8 +3422,10 @@ async def update_google_signals_settings( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.GoogleSignalsSettings: @@ -3398,7 +3498,7 @@ async def create_conversion_event( conversion_event: Optional[resources.ConversionEvent] = None, retry: OptionalRetry = 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.ConversionEvent: r"""Deprecated: Use ``CreateKeyEvent`` instead. Creates a conversion event with the specified attributes. @@ -3426,8 +3526,10 @@ async def create_conversion_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.analytics.admin_v1alpha.types.ConversionEvent: @@ -3498,7 +3600,7 @@ async def update_conversion_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]]] = (), ) -> resources.ConversionEvent: r"""Deprecated: Use ``UpdateKeyEvent`` instead. Updates a conversion event with the specified attributes. @@ -3527,8 +3629,10 @@ async def update_conversion_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.analytics.admin_v1alpha.types.ConversionEvent: @@ -3600,7 +3704,7 @@ async def get_conversion_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.ConversionEvent: r"""Deprecated: Use ``GetKeyEvent`` instead. Retrieve a single conversion event. @@ -3621,8 +3725,10 @@ async def get_conversion_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.analytics.admin_v1alpha.types.ConversionEvent: @@ -3690,7 +3796,7 @@ async def delete_conversion_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"""Deprecated: Use ``DeleteKeyEvent`` instead. Deletes a conversion event in a property. @@ -3711,8 +3817,10 @@ async def delete_conversion_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`. """ warnings.warn( "AnalyticsAdminServiceAsyncClient.delete_conversion_event is deprecated", @@ -3771,7 +3879,7 @@ async def list_conversion_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.ListConversionEventsAsyncPager: r"""Deprecated: Use ``ListKeyEvents`` instead. Returns a list of conversion events in the specified parent property. @@ -3793,8 +3901,10 @@ async def list_conversion_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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListConversionEventsAsyncPager: @@ -3875,7 +3985,7 @@ async def create_key_event( key_event: Optional[resources.KeyEvent] = None, retry: OptionalRetry = 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.KeyEvent: r"""Creates a Key Event. @@ -3899,8 +4009,10 @@ async def create_key_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.analytics.admin_v1alpha.types.KeyEvent: @@ -3964,7 +4076,7 @@ async def update_key_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]]] = (), ) -> resources.KeyEvent: r"""Updates a Key Event. @@ -3992,8 +4104,10 @@ async def update_key_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.analytics.admin_v1alpha.types.KeyEvent: @@ -4058,7 +4172,7 @@ async def get_key_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.KeyEvent: r"""Retrieve a single Key Event. @@ -4077,8 +4191,10 @@ async def get_key_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.analytics.admin_v1alpha.types.KeyEvent: @@ -4139,7 +4255,7 @@ async def delete_key_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 a Key Event. @@ -4158,8 +4274,10 @@ async def delete_key_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 @@ -4211,7 +4329,7 @@ async def list_key_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.ListKeyEventsAsyncPager: r"""Returns a list of Key Events in the specified parent property. Returns an empty list if no Key Events are @@ -4231,8 +4349,10 @@ async def list_key_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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListKeyEventsAsyncPager: @@ -4309,7 +4429,7 @@ async def get_display_video360_advertiser_link( name: Optional[str] = None, retry: OptionalRetry = 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.DisplayVideo360AdvertiserLink: r"""Look up a single DisplayVideo360AdvertiserLink @@ -4329,8 +4449,10 @@ async def get_display_video360_advertiser_link( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLink: @@ -4395,7 +4517,7 @@ async def list_display_video360_advertiser_links( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDisplayVideo360AdvertiserLinksAsyncPager: r"""Lists all DisplayVideo360AdvertiserLinks on a property. @@ -4414,8 +4536,10 @@ async def list_display_video360_advertiser_links( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListDisplayVideo360AdvertiserLinksAsyncPager: @@ -4497,7 +4621,7 @@ async def create_display_video360_advertiser_link( ] = None, retry: OptionalRetry = 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.DisplayVideo360AdvertiserLink: r"""Creates a DisplayVideo360AdvertiserLink. This can only be utilized by users who have proper @@ -4527,8 +4651,10 @@ async def create_display_video360_advertiser_link( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLink: @@ -4599,7 +4725,7 @@ async def delete_display_video360_advertiser_link( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 DisplayVideo360AdvertiserLink on a property. @@ -4620,8 +4746,10 @@ async def delete_display_video360_advertiser_link( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -4682,7 +4810,7 @@ async def update_display_video360_advertiser_link( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.DisplayVideo360AdvertiserLink: r"""Updates a DisplayVideo360AdvertiserLink on a property. @@ -4710,8 +4838,10 @@ async def update_display_video360_advertiser_link( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLink: @@ -4789,7 +4919,7 @@ async def get_display_video360_advertiser_link_proposal( name: Optional[str] = None, retry: OptionalRetry = 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.DisplayVideo360AdvertiserLinkProposal: r"""Lookup for a single DisplayVideo360AdvertiserLinkProposal. @@ -4811,8 +4941,10 @@ async def get_display_video360_advertiser_link_proposal( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLinkProposal: @@ -4889,7 +5021,7 @@ async def list_display_video360_advertiser_link_proposals( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDisplayVideo360AdvertiserLinkProposalsAsyncPager: r"""Lists DisplayVideo360AdvertiserLinkProposals on a property. @@ -4909,8 +5041,10 @@ async def list_display_video360_advertiser_link_proposals( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListDisplayVideo360AdvertiserLinkProposalsAsyncPager: @@ -4996,7 +5130,7 @@ async def create_display_video360_advertiser_link_proposal( ] = None, retry: OptionalRetry = 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.DisplayVideo360AdvertiserLinkProposal: r"""Creates a DisplayVideo360AdvertiserLinkProposal. @@ -5023,8 +5157,10 @@ async def create_display_video360_advertiser_link_proposal( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLinkProposal: @@ -5107,7 +5243,7 @@ async def delete_display_video360_advertiser_link_proposal( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 DisplayVideo360AdvertiserLinkProposal on a property. This can only be used on cancelled proposals. @@ -5129,8 +5265,10 @@ async def delete_display_video360_advertiser_link_proposal( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -5192,7 +5330,7 @@ async def approve_display_video360_advertiser_link_proposal( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalResponse: r"""Approves a DisplayVideo360AdvertiserLinkProposal. The DisplayVideo360AdvertiserLinkProposal will be @@ -5207,8 +5345,10 @@ async def approve_display_video360_advertiser_link_proposal( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.ApproveDisplayVideo360AdvertiserLinkProposalResponse: @@ -5265,7 +5405,7 @@ async def cancel_display_video360_advertiser_link_proposal( *, retry: OptionalRetry = 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.DisplayVideo360AdvertiserLinkProposal: r"""Cancels a DisplayVideo360AdvertiserLinkProposal. Cancelling can mean either: @@ -5284,8 +5424,10 @@ async def cancel_display_video360_advertiser_link_proposal( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLinkProposal: @@ -5349,7 +5491,7 @@ async def create_custom_dimension( custom_dimension: Optional[resources.CustomDimension] = None, retry: OptionalRetry = 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.CustomDimension: r"""Creates a CustomDimension. @@ -5374,8 +5516,10 @@ async def create_custom_dimension( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.CustomDimension: @@ -5439,7 +5583,7 @@ async def update_custom_dimension( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.CustomDimension: r"""Updates a CustomDimension on a property. @@ -5464,8 +5608,10 @@ async def update_custom_dimension( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.CustomDimension: @@ -5530,7 +5676,7 @@ async def list_custom_dimensions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCustomDimensionsAsyncPager: r"""Lists CustomDimensions on a property. @@ -5548,8 +5694,10 @@ async def list_custom_dimensions( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListCustomDimensionsAsyncPager: @@ -5626,7 +5774,7 @@ async def archive_custom_dimension( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Archives a CustomDimension on a property. @@ -5646,8 +5794,10 @@ async def archive_custom_dimension( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -5701,7 +5851,7 @@ async def get_custom_dimension( name: Optional[str] = None, retry: OptionalRetry = 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.CustomDimension: r"""Lookup for a single CustomDimension. @@ -5720,8 +5870,10 @@ async def get_custom_dimension( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.CustomDimension: @@ -5783,7 +5935,7 @@ async def create_custom_metric( custom_metric: Optional[resources.CustomMetric] = None, retry: OptionalRetry = 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.CustomMetric: r"""Creates a CustomMetric. @@ -5806,8 +5958,10 @@ async def create_custom_metric( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.CustomMetric: @@ -5871,7 +6025,7 @@ async def update_custom_metric( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.CustomMetric: r"""Updates a CustomMetric on a property. @@ -5896,8 +6050,10 @@ async def update_custom_metric( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.CustomMetric: @@ -5960,7 +6116,7 @@ async def list_custom_metrics( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCustomMetricsAsyncPager: r"""Lists CustomMetrics on a property. @@ -5978,8 +6134,10 @@ async def list_custom_metrics( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListCustomMetricsAsyncPager: @@ -6056,7 +6214,7 @@ async def archive_custom_metric( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Archives a CustomMetric on a property. @@ -6075,8 +6233,10 @@ async def archive_custom_metric( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -6128,7 +6288,7 @@ async def get_custom_metric( name: Optional[str] = None, retry: OptionalRetry = 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.CustomMetric: r"""Lookup for a single CustomMetric. @@ -6147,8 +6307,10 @@ async def get_custom_metric( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.CustomMetric: @@ -6209,7 +6371,7 @@ async def get_data_retention_settings( name: Optional[str] = None, retry: OptionalRetry = 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.DataRetentionSettings: r"""Returns the singleton data retention settings for this property. @@ -6232,8 +6394,10 @@ async def get_data_retention_settings( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.DataRetentionSettings: @@ -6297,7 +6461,7 @@ async def update_data_retention_settings( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.DataRetentionSettings: r"""Updates the singleton data retention settings for this property. @@ -6326,8 +6490,10 @@ async def update_data_retention_settings( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.DataRetentionSettings: @@ -6398,7 +6564,7 @@ async def create_data_stream( data_stream: Optional[resources.DataStream] = None, retry: OptionalRetry = 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.DataStream: r"""Creates a DataStream. @@ -6421,8 +6587,10 @@ async def create_data_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.analytics.admin_v1alpha.types.DataStream: @@ -6485,7 +6653,7 @@ async def delete_data_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]]] = (), ) -> None: r"""Deletes a DataStream on a property. @@ -6504,8 +6672,10 @@ async def delete_data_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -6558,7 +6728,7 @@ async def update_data_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]]] = (), ) -> resources.DataStream: r"""Updates a DataStream on a property. @@ -6583,8 +6753,10 @@ async def update_data_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.analytics.admin_v1alpha.types.DataStream: @@ -6649,7 +6821,7 @@ async def list_data_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.ListDataStreamsAsyncPager: r"""Lists DataStreams on a property. @@ -6667,8 +6839,10 @@ async def list_data_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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListDataStreamsAsyncPager: @@ -6743,7 +6917,7 @@ async def get_data_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]]] = (), ) -> resources.DataStream: r"""Lookup for a single DataStream. @@ -6762,8 +6936,10 @@ async def get_data_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.analytics.admin_v1alpha.types.DataStream: @@ -6824,7 +7000,7 @@ async def get_audience( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> audience.Audience: r"""Lookup for a single Audience. Audiences created before 2020 may not be supported. @@ -6844,8 +7020,10 @@ async def get_audience( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.Audience: @@ -6906,7 +7084,7 @@ async def list_audiences( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAudiencesAsyncPager: r"""Lists Audiences on a property. Audiences created before 2020 may not be supported. @@ -6926,8 +7104,10 @@ async def list_audiences( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListAudiencesAsyncPager: @@ -7003,7 +7183,7 @@ async def create_audience( audience: Optional[gaa_audience.Audience] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gaa_audience.Audience: r"""Creates an Audience. @@ -7026,8 +7206,10 @@ async def create_audience( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.Audience: @@ -7091,7 +7273,7 @@ async def update_audience( 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]]] = (), ) -> gaa_audience.Audience: r"""Updates an Audience on a property. @@ -7120,8 +7302,10 @@ async def update_audience( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.Audience: @@ -7185,7 +7369,7 @@ async def archive_audience( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Archives an Audience on a property. @@ -7196,8 +7380,10 @@ async def archive_audience( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -7237,7 +7423,7 @@ async def get_search_ads360_link( name: Optional[str] = None, retry: OptionalRetry = 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.SearchAds360Link: r"""Look up a single SearchAds360Link @@ -7256,8 +7442,10 @@ async def get_search_ads360_link( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.SearchAds360Link: @@ -7320,7 +7508,7 @@ async def list_search_ads360_links( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSearchAds360LinksAsyncPager: r"""Lists all SearchAds360Links on a property. @@ -7338,8 +7526,10 @@ async def list_search_ads360_links( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListSearchAds360LinksAsyncPager: @@ -7417,7 +7607,7 @@ async def create_search_ads360_link( search_ads_360_link: Optional[resources.SearchAds360Link] = None, retry: OptionalRetry = 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.SearchAds360Link: r"""Creates a SearchAds360Link. @@ -7442,8 +7632,10 @@ async def create_search_ads360_link( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.SearchAds360Link: @@ -7508,7 +7700,7 @@ async def delete_search_ads360_link( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 SearchAds360Link on a property. @@ -7528,8 +7720,10 @@ async def delete_search_ads360_link( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -7584,7 +7778,7 @@ async def update_search_ads360_link( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SearchAds360Link: r"""Updates a SearchAds360Link on a property. @@ -7609,8 +7803,10 @@ async def update_search_ads360_link( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.SearchAds360Link: @@ -7677,7 +7873,7 @@ async def get_attribution_settings( name: Optional[str] = None, retry: OptionalRetry = 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.AttributionSettings: r"""Lookup for a AttributionSettings singleton. @@ -7696,8 +7892,10 @@ async def get_attribution_settings( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.AttributionSettings: @@ -7762,7 +7960,7 @@ async def update_attribution_settings( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.AttributionSettings: r"""Updates attribution settings on a property. @@ -7791,8 +7989,10 @@ async def update_attribution_settings( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.AttributionSettings: @@ -7857,7 +8057,7 @@ async def run_access_report( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.RunAccessReportResponse: r"""Returns a customized report of data access records. The report provides records of each time a user reads Google Analytics @@ -7883,8 +8083,10 @@ async def run_access_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.analytics.admin_v1alpha.types.RunAccessReportResponse: @@ -7934,7 +8136,7 @@ async def create_access_binding( access_binding: Optional[resources.AccessBinding] = None, retry: OptionalRetry = 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.AccessBinding: r"""Creates an access binding on an account or property. @@ -7961,8 +8163,10 @@ async def create_access_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.analytics.admin_v1alpha.types.AccessBinding: @@ -8025,7 +8229,7 @@ async def get_access_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]]] = (), ) -> resources.AccessBinding: r"""Gets information about an access binding. @@ -8048,8 +8252,10 @@ async def get_access_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.analytics.admin_v1alpha.types.AccessBinding: @@ -8112,7 +8318,7 @@ async def update_access_binding( access_binding: Optional[resources.AccessBinding] = None, retry: OptionalRetry = 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.AccessBinding: r"""Updates an access binding on an account or property. @@ -8130,8 +8336,10 @@ async def update_access_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.analytics.admin_v1alpha.types.AccessBinding: @@ -8196,7 +8404,7 @@ async def delete_access_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]]] = (), ) -> None: r"""Deletes an access binding on an account or property. @@ -8218,8 +8426,10 @@ async def delete_access_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -8273,7 +8483,7 @@ async def list_access_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.ListAccessBindingsAsyncPager: r"""Lists all access bindings on an account or property. @@ -8293,8 +8503,10 @@ async def list_access_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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListAccessBindingsAsyncPager: @@ -8370,7 +8582,7 @@ async def batch_create_access_bindings( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.BatchCreateAccessBindingsResponse: r"""Creates information about multiple access bindings to an account or property. @@ -8386,8 +8598,10 @@ async def batch_create_access_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.analytics.admin_v1alpha.types.BatchCreateAccessBindingsResponse: @@ -8435,7 +8649,7 @@ async def batch_get_access_bindings( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.BatchGetAccessBindingsResponse: r"""Gets information about multiple access bindings to an account or property. @@ -8447,8 +8661,10 @@ async def batch_get_access_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.analytics.admin_v1alpha.types.BatchGetAccessBindingsResponse: @@ -8496,7 +8712,7 @@ async def batch_update_access_bindings( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.BatchUpdateAccessBindingsResponse: r"""Updates information about multiple access bindings to an account or property. @@ -8508,8 +8724,10 @@ async def batch_update_access_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.analytics.admin_v1alpha.types.BatchUpdateAccessBindingsResponse: @@ -8557,7 +8775,7 @@ async def batch_delete_access_bindings( *, retry: OptionalRetry = gapic_v1.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 information about multiple users' links to an account or property. @@ -8569,8 +8787,10 @@ async def batch_delete_access_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`. """ # Create or coerce a protobuf request object. # - Use the request object if provided (there's no risk of modifying the input as @@ -8610,7 +8830,7 @@ async def get_expanded_data_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]]] = (), ) -> expanded_data_set.ExpandedDataSet: r"""Lookup for a single ExpandedDataSet. @@ -8629,8 +8849,10 @@ async def get_expanded_data_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.analytics.admin_v1alpha.types.ExpandedDataSet: @@ -8693,7 +8915,7 @@ async def list_expanded_data_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.ListExpandedDataSetsAsyncPager: r"""Lists ExpandedDataSets on a property. @@ -8711,8 +8933,10 @@ async def list_expanded_data_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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListExpandedDataSetsAsyncPager: @@ -8790,7 +9014,7 @@ async def create_expanded_data_set( expanded_data_set: Optional[gaa_expanded_data_set.ExpandedDataSet] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gaa_expanded_data_set.ExpandedDataSet: r"""Creates a ExpandedDataSet. @@ -8815,8 +9039,10 @@ async def create_expanded_data_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.analytics.admin_v1alpha.types.ExpandedDataSet: @@ -8882,7 +9108,7 @@ async def update_expanded_data_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]]] = (), ) -> gaa_expanded_data_set.ExpandedDataSet: r"""Updates a ExpandedDataSet on a property. @@ -8911,8 +9137,10 @@ async def update_expanded_data_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.analytics.admin_v1alpha.types.ExpandedDataSet: @@ -8979,7 +9207,7 @@ async def delete_expanded_data_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"""Deletes a ExpandedDataSet on a property. @@ -8997,8 +9225,10 @@ async def delete_expanded_data_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 @@ -9050,7 +9280,7 @@ async def get_channel_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]]] = (), ) -> channel_group.ChannelGroup: r"""Lookup for a single ChannelGroup. @@ -9069,8 +9299,10 @@ async def get_channel_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.analytics.admin_v1alpha.types.ChannelGroup: @@ -9131,7 +9363,7 @@ async def list_channel_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.ListChannelGroupsAsyncPager: r"""Lists ChannelGroups on a property. @@ -9150,8 +9382,10 @@ async def list_channel_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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListChannelGroupsAsyncPager: @@ -9229,7 +9463,7 @@ async def create_channel_group( channel_group: Optional[gaa_channel_group.ChannelGroup] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gaa_channel_group.ChannelGroup: r"""Creates a ChannelGroup. @@ -9253,8 +9487,10 @@ async def create_channel_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.analytics.admin_v1alpha.types.ChannelGroup: @@ -9320,7 +9556,7 @@ async def update_channel_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]]] = (), ) -> gaa_channel_group.ChannelGroup: r"""Updates a ChannelGroup. @@ -9349,8 +9585,10 @@ async def update_channel_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.analytics.admin_v1alpha.types.ChannelGroup: @@ -9417,7 +9655,7 @@ async def delete_channel_group( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a ChannelGroup on a property. @@ -9436,8 +9674,10 @@ async def delete_channel_group( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -9490,7 +9730,7 @@ async def set_automated_ga4_configuration_opt_out( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse: r"""Sets the opt out status for the automated GA4 setup process for a UA property. @@ -9504,8 +9744,10 @@ async def set_automated_ga4_configuration_opt_out( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.SetAutomatedGa4ConfigurationOptOutResponse: @@ -9550,7 +9792,7 @@ async def fetch_automated_ga4_configuration_opt_out( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.FetchAutomatedGa4ConfigurationOptOutResponse: r"""Fetches the opt out status for the automated GA4 setup process for a UA property. @@ -9564,8 +9806,10 @@ async def fetch_automated_ga4_configuration_opt_out( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.FetchAutomatedGa4ConfigurationOptOutResponse: @@ -9614,7 +9858,7 @@ async def create_big_query_link( bigquery_link: Optional[resources.BigQueryLink] = None, retry: OptionalRetry = 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.BigQueryLink: r"""Creates a BigQueryLink. @@ -9637,8 +9881,10 @@ async def create_big_query_link( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.BigQueryLink: @@ -9701,7 +9947,7 @@ async def get_big_query_link( name: Optional[str] = None, retry: OptionalRetry = 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.BigQueryLink: r"""Lookup for a single BigQuery Link. @@ -9721,8 +9967,10 @@ async def get_big_query_link( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.BigQueryLink: @@ -9783,7 +10031,7 @@ async def list_big_query_links( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListBigQueryLinksAsyncPager: r"""Lists BigQuery Links on a property. @@ -9802,8 +10050,10 @@ async def list_big_query_links( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListBigQueryLinksAsyncPager: @@ -9880,7 +10130,7 @@ async def delete_big_query_link( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 BigQueryLink on a property. @@ -9899,8 +10149,10 @@ async def delete_big_query_link( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -9955,7 +10207,7 @@ async def update_big_query_link( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.BigQueryLink: r"""Updates a BigQueryLink. @@ -9983,8 +10235,10 @@ async def update_big_query_link( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.BigQueryLink: @@ -10051,7 +10305,7 @@ async def get_enhanced_measurement_settings( name: Optional[str] = None, retry: OptionalRetry = 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.EnhancedMeasurementSettings: r"""Returns the enhanced measurement settings for this data stream. Note that the stream must enable enhanced @@ -10073,8 +10327,10 @@ async def get_enhanced_measurement_settings( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.EnhancedMeasurementSettings: @@ -10144,7 +10400,7 @@ async def update_enhanced_measurement_settings( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.EnhancedMeasurementSettings: r"""Updates the enhanced measurement settings for this data stream. Note that the stream must enable enhanced @@ -10174,8 +10430,10 @@ async def update_enhanced_measurement_settings( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.EnhancedMeasurementSettings: @@ -10250,7 +10508,7 @@ async def create_connected_site_tag( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.CreateConnectedSiteTagResponse: r"""Creates a connected site tag for a Universal Analytics property. You can create a maximum of 20 @@ -10264,8 +10522,10 @@ async def create_connected_site_tag( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.CreateConnectedSiteTagResponse: @@ -10307,7 +10567,7 @@ async def delete_connected_site_tag( *, retry: OptionalRetry = gapic_v1.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 connected site tag for a Universal Analytics property. Note: this has no effect on GA4 @@ -10320,8 +10580,10 @@ async def delete_connected_site_tag( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -10354,7 +10616,7 @@ async def list_connected_site_tags( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListConnectedSiteTagsResponse: r"""Lists the connected site tags for a Universal Analytics property. A maximum of 20 connected site tags @@ -10368,8 +10630,10 @@ async def list_connected_site_tags( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.ListConnectedSiteTagsResponse: @@ -10411,7 +10675,7 @@ async def fetch_connected_ga4_property( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.FetchConnectedGa4PropertyResponse: r"""Given a specified UA property, looks up the GA4 property connected to it. Note: this cannot be used with @@ -10424,8 +10688,10 @@ async def fetch_connected_ga4_property( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.FetchConnectedGa4PropertyResponse: @@ -10466,7 +10732,7 @@ async def get_ad_sense_link( name: Optional[str] = None, retry: OptionalRetry = 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.AdSenseLink: r"""Looks up a single AdSenseLink. @@ -10487,8 +10753,10 @@ async def get_ad_sense_link( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.AdSenseLink: @@ -10550,7 +10818,7 @@ async def create_ad_sense_link( adsense_link: Optional[resources.AdSenseLink] = None, retry: OptionalRetry = 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.AdSenseLink: r"""Creates an AdSenseLink. @@ -10575,8 +10843,10 @@ async def create_ad_sense_link( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.AdSenseLink: @@ -10639,7 +10909,7 @@ async def delete_ad_sense_link( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 AdSenseLink. @@ -10660,8 +10930,10 @@ async def delete_ad_sense_link( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -10713,7 +10985,7 @@ async def list_ad_sense_links( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAdSenseLinksAsyncPager: r"""Lists AdSenseLinks on a property. @@ -10733,8 +11005,10 @@ async def list_ad_sense_links( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListAdSenseLinksAsyncPager: @@ -10811,7 +11085,7 @@ async def get_event_create_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]]] = (), ) -> event_create_and_edit.EventCreateRule: r"""Lookup for a single EventCreateRule. @@ -10830,8 +11104,10 @@ async def get_event_create_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.analytics.admin_v1alpha.types.EventCreateRule: @@ -10906,7 +11182,7 @@ async def list_event_create_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.ListEventCreateRulesAsyncPager: r"""Lists EventCreateRules on a web data stream. @@ -10924,8 +11200,10 @@ async def list_event_create_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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListEventCreateRulesAsyncPager: @@ -11003,7 +11281,7 @@ async def create_event_create_rule( event_create_rule: Optional[event_create_and_edit.EventCreateRule] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> event_create_and_edit.EventCreateRule: r"""Creates an EventCreateRule. @@ -11028,8 +11306,10 @@ async def create_event_create_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.analytics.admin_v1alpha.types.EventCreateRule: @@ -11107,7 +11387,7 @@ async def update_event_create_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]]] = (), ) -> event_create_and_edit.EventCreateRule: r"""Updates an EventCreateRule. @@ -11136,8 +11416,10 @@ async def update_event_create_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.analytics.admin_v1alpha.types.EventCreateRule: @@ -11216,7 +11498,7 @@ async def delete_event_create_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]]] = (), ) -> None: r"""Deletes an EventCreateRule. @@ -11235,8 +11517,10 @@ async def delete_event_create_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -11288,7 +11572,7 @@ async def get_event_edit_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]]] = (), ) -> event_create_and_edit.EventEditRule: r"""Lookup for a single EventEditRule. @@ -11307,8 +11591,10 @@ async def get_event_edit_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.analytics.admin_v1alpha.types.EventEditRule: @@ -11383,7 +11669,7 @@ async def list_event_edit_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.ListEventEditRulesAsyncPager: r"""Lists EventEditRules on a web data stream. @@ -11401,8 +11687,10 @@ async def list_event_edit_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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListEventEditRulesAsyncPager: @@ -11480,7 +11768,7 @@ async def create_event_edit_rule( event_edit_rule: Optional[event_create_and_edit.EventEditRule] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> event_create_and_edit.EventEditRule: r"""Creates an EventEditRule. @@ -11505,8 +11793,10 @@ async def create_event_edit_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.analytics.admin_v1alpha.types.EventEditRule: @@ -11584,7 +11874,7 @@ async def update_event_edit_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]]] = (), ) -> event_create_and_edit.EventEditRule: r"""Updates an EventEditRule. @@ -11613,8 +11903,10 @@ async def update_event_edit_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.analytics.admin_v1alpha.types.EventEditRule: @@ -11693,7 +11985,7 @@ async def delete_event_edit_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]]] = (), ) -> None: r"""Deletes an EventEditRule. @@ -11711,8 +12003,10 @@ async def delete_event_edit_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -11765,7 +12059,7 @@ async def reorder_event_edit_rules( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Changes the processing order of event edit rules on the specified stream. @@ -11777,8 +12071,10 @@ async def reorder_event_edit_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`. """ # Create or coerce a protobuf request object. # - Use the request object if provided (there's no risk of modifying the input as @@ -11819,7 +12115,7 @@ async def update_data_redaction_settings( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.DataRedactionSettings: r"""Updates a DataRedactionSettings on a property. @@ -11847,8 +12143,10 @@ async def update_data_redaction_settings( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.DataRedactionSettings: @@ -11921,7 +12219,7 @@ async def get_data_redaction_settings( name: Optional[str] = None, retry: OptionalRetry = 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.DataRedactionSettings: r"""Lookup for a single DataRedactionSettings. @@ -11941,8 +12239,10 @@ async def get_data_redaction_settings( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.DataRedactionSettings: @@ -12006,7 +12306,7 @@ async def get_calculated_metric( name: Optional[str] = None, retry: OptionalRetry = 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.CalculatedMetric: r"""Lookup for a single CalculatedMetric. @@ -12026,8 +12326,10 @@ async def get_calculated_metric( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.CalculatedMetric: @@ -12090,7 +12392,7 @@ async def create_calculated_metric( calculated_metric_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.CalculatedMetric: r"""Creates a CalculatedMetric. @@ -12131,8 +12433,10 @@ async def create_calculated_metric( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.CalculatedMetric: @@ -12197,7 +12501,7 @@ async def list_calculated_metrics( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCalculatedMetricsAsyncPager: r"""Lists CalculatedMetrics on a property. @@ -12215,8 +12519,10 @@ async def list_calculated_metrics( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListCalculatedMetricsAsyncPager: @@ -12294,7 +12600,7 @@ async def update_calculated_metric( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.CalculatedMetric: r"""Updates a CalculatedMetric on a property. @@ -12321,8 +12627,10 @@ async def update_calculated_metric( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.CalculatedMetric: @@ -12387,7 +12695,7 @@ async def delete_calculated_metric( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 CalculatedMetric on a property. @@ -12407,8 +12715,10 @@ async def delete_calculated_metric( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -12461,7 +12771,7 @@ async def create_rollup_property( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.CreateRollupPropertyResponse: r"""Create a roll-up property and all roll-up property source links. @@ -12473,8 +12783,10 @@ async def create_rollup_property( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.CreateRollupPropertyResponse: @@ -12517,7 +12829,7 @@ async def get_rollup_property_source_link( name: Optional[str] = None, retry: OptionalRetry = 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.RollupPropertySourceLink: r"""Lookup for a single roll-up property source Link. Only roll-up properties can have source links, so this @@ -12540,8 +12852,10 @@ async def get_rollup_property_source_link( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.RollupPropertySourceLink: @@ -12605,7 +12919,7 @@ async def list_rollup_property_source_links( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListRollupPropertySourceLinksAsyncPager: r"""Lists roll-up property source Links on a property. Only roll-up properties can have source links, so this @@ -12627,8 +12941,10 @@ async def list_rollup_property_source_links( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListRollupPropertySourceLinksAsyncPager: @@ -12710,7 +13026,7 @@ async def create_rollup_property_source_link( ] = None, retry: OptionalRetry = 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.RollupPropertySourceLink: r"""Creates a roll-up property source link. Only roll-up properties can have source links, so this @@ -12738,8 +13054,10 @@ async def create_rollup_property_source_link( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.RollupPropertySourceLink: @@ -12807,7 +13125,7 @@ async def delete_rollup_property_source_link( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 roll-up property source link. Only roll-up properties can have source links, so this @@ -12829,8 +13147,10 @@ async def delete_rollup_property_source_link( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -12885,7 +13205,7 @@ async def provision_subproperty( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ProvisionSubpropertyResponse: r"""Create a subproperty and a subproperty event filter that applies to the created subproperty. @@ -12897,8 +13217,10 @@ async def provision_subproperty( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.ProvisionSubpropertyResponse: @@ -12944,7 +13266,7 @@ async def create_subproperty_event_filter( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gaa_subproperty_event_filter.SubpropertyEventFilter: r"""Creates a subproperty Event Filter. @@ -12970,8 +13292,10 @@ async def create_subproperty_event_filter( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.SubpropertyEventFilter: @@ -13036,7 +13360,7 @@ async def get_subproperty_event_filter( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> subproperty_event_filter.SubpropertyEventFilter: r"""Lookup for a single subproperty Event Filter. @@ -13056,8 +13380,10 @@ async def get_subproperty_event_filter( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.SubpropertyEventFilter: @@ -13120,7 +13446,7 @@ async def list_subproperty_event_filters( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSubpropertyEventFiltersAsyncPager: r"""List all subproperty Event Filters on a property. @@ -13138,8 +13464,10 @@ async def list_subproperty_event_filters( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListSubpropertyEventFiltersAsyncPager: @@ -13219,7 +13547,7 @@ async def update_subproperty_event_filter( 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]]] = (), ) -> gaa_subproperty_event_filter.SubpropertyEventFilter: r"""Updates a subproperty Event Filter. @@ -13247,8 +13575,10 @@ async def update_subproperty_event_filter( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.SubpropertyEventFilter: @@ -13320,7 +13650,7 @@ async def delete_subproperty_event_filter( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 subproperty event filter. @@ -13340,8 +13670,10 @@ async def delete_subproperty_event_filter( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/client.py b/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/client.py index bfc42cfdb936..ccf6bb0fe82c 100644 --- a/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/client.py +++ b/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore from google.protobuf import wrappers_pb2 # type: ignore @@ -1221,6 +1231,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( @@ -1287,6 +1301,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.analytics.admin_v1alpha.AnalyticsAdminServiceClient`.", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "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.analytics.admin.v1alpha.AnalyticsAdminService", + "credentialsType": None, + }, + ) + def get_account( self, request: Optional[Union[analytics_admin.GetAccountRequest, dict]] = None, @@ -1294,7 +1331,7 @@ def get_account( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Account: r"""Lookup for a single Account. @@ -1312,8 +1349,10 @@ def get_account( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.Account: @@ -1370,7 +1409,7 @@ def list_accounts( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAccountsPager: r"""Returns all accounts accessible by the caller. @@ -1385,8 +1424,10 @@ def list_accounts( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListAccountsPager: @@ -1439,7 +1480,7 @@ def delete_account( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Marks target Account as soft-deleted (ie: "trashed") and returns it. @@ -1470,8 +1511,10 @@ def delete_account( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1521,7 +1564,7 @@ def update_account( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Account: r"""Updates an account. @@ -1549,8 +1592,10 @@ def update_account( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.Account: @@ -1613,7 +1658,7 @@ def provision_account_ticket( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ProvisionAccountTicketResponse: r"""Requests a ticket for creating an account. @@ -1624,8 +1669,10 @@ def provision_account_ticket( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.ProvisionAccountTicketResponse: @@ -1665,7 +1712,7 @@ def list_account_summaries( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAccountSummariesPager: r"""Returns summaries of all accounts accessible by the caller. @@ -1677,8 +1724,10 @@ def list_account_summaries( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListAccountSummariesPager: @@ -1731,7 +1780,7 @@ def get_property( name: Optional[str] = None, retry: OptionalRetry = 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.Property: r"""Lookup for a single "GA4" Property. @@ -1748,8 +1797,10 @@ def get_property( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.Property: @@ -1806,7 +1857,7 @@ def list_properties( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPropertiesPager: r"""Returns child Properties under the specified parent Account. @@ -1823,8 +1874,10 @@ def list_properties( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListPropertiesPager: @@ -1877,7 +1930,7 @@ def create_property( property: Optional[resources.Property] = None, retry: OptionalRetry = 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.Property: r"""Creates an "GA4" property with the specified location and attributes. @@ -1897,8 +1950,10 @@ def create_property( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.Property: @@ -1950,7 +2005,7 @@ def delete_property( name: Optional[str] = None, retry: OptionalRetry = 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.Property: r"""Marks target Property as soft-deleted (ie: "trashed") and returns it. @@ -1982,8 +2037,10 @@ def delete_property( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.Property: @@ -2042,7 +2099,7 @@ def update_property( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Property: r"""Updates a property. @@ -2071,8 +2128,10 @@ def update_property( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.Property: @@ -2137,7 +2196,7 @@ def create_firebase_link( firebase_link: Optional[resources.FirebaseLink] = None, retry: OptionalRetry = 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.FirebaseLink: r"""Creates a FirebaseLink. @@ -2165,8 +2224,10 @@ def create_firebase_link( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.FirebaseLink: @@ -2228,7 +2289,7 @@ def delete_firebase_link( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 FirebaseLink on a property @@ -2248,8 +2309,10 @@ def delete_firebase_link( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -2298,7 +2361,7 @@ def list_firebase_links( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListFirebaseLinksPager: r"""Lists FirebaseLinks on a property. Properties can have at most one FirebaseLink. @@ -2318,8 +2381,10 @@ def list_firebase_links( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListFirebaseLinksPager: @@ -2391,7 +2456,7 @@ def get_global_site_tag( name: Optional[str] = None, retry: OptionalRetry = 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.GlobalSiteTag: r"""Returns the Site Tag for the specified web stream. Site Tags are immutable singletons. @@ -2415,8 +2480,10 @@ def get_global_site_tag( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.GlobalSiteTag: @@ -2479,7 +2546,7 @@ def create_google_ads_link( google_ads_link: Optional[resources.GoogleAdsLink] = None, retry: OptionalRetry = 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.GoogleAdsLink: r"""Creates a GoogleAdsLink. @@ -2504,8 +2571,10 @@ def create_google_ads_link( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.GoogleAdsLink: @@ -2568,7 +2637,7 @@ def update_google_ads_link( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.GoogleAdsLink: r"""Updates a GoogleAdsLink on a property @@ -2594,8 +2663,10 @@ def update_google_ads_link( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.GoogleAdsLink: @@ -2659,7 +2730,7 @@ def delete_google_ads_link( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 GoogleAdsLink on a property @@ -2677,8 +2748,10 @@ def delete_google_ads_link( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -2729,7 +2802,7 @@ def list_google_ads_links( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListGoogleAdsLinksPager: r"""Lists GoogleAdsLinks on a property. @@ -2747,8 +2820,10 @@ def list_google_ads_links( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListGoogleAdsLinksPager: @@ -2822,7 +2897,7 @@ def get_data_sharing_settings( name: Optional[str] = None, retry: OptionalRetry = 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.DataSharingSettings: r"""Get data sharing settings on an account. Data sharing settings are singletons. @@ -2843,8 +2918,10 @@ def get_data_sharing_settings( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.DataSharingSettings: @@ -2907,7 +2984,7 @@ def get_measurement_protocol_secret( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.MeasurementProtocolSecret: r"""Lookup for a single "GA4" MeasurementProtocolSecret. @@ -2927,8 +3004,10 @@ def get_measurement_protocol_secret( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.MeasurementProtocolSecret: @@ -2990,7 +3069,7 @@ def list_measurement_protocol_secrets( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListMeasurementProtocolSecretsPager: r"""Returns child MeasurementProtocolSecrets under the specified parent Property. @@ -3011,8 +3090,10 @@ def list_measurement_protocol_secrets( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListMeasurementProtocolSecretsPager: @@ -3093,7 +3174,7 @@ def create_measurement_protocol_secret( ] = None, retry: OptionalRetry = 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.MeasurementProtocolSecret: r"""Creates a measurement protocol secret. @@ -3119,8 +3200,10 @@ def create_measurement_protocol_secret( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.MeasurementProtocolSecret: @@ -3186,7 +3269,7 @@ def delete_measurement_protocol_secret( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes target MeasurementProtocolSecret. @@ -3207,8 +3290,10 @@ def delete_measurement_protocol_secret( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -3266,7 +3351,7 @@ def update_measurement_protocol_secret( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.MeasurementProtocolSecret: r"""Updates a measurement protocol secret. @@ -3292,8 +3377,10 @@ def update_measurement_protocol_secret( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.MeasurementProtocolSecret: @@ -3365,7 +3452,7 @@ def acknowledge_user_data_collection( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.AcknowledgeUserDataCollectionResponse: r"""Acknowledges the terms of user data collection for the specified property. @@ -3380,8 +3467,10 @@ def acknowledge_user_data_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.analytics.admin_v1alpha.types.AcknowledgeUserDataCollectionResponse: @@ -3432,7 +3521,7 @@ def get_sk_ad_network_conversion_value_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]]] = (), ) -> resources.SKAdNetworkConversionValueSchema: r"""Looks up a single SKAdNetworkConversionValueSchema. @@ -3451,8 +3540,10 @@ def get_sk_ad_network_conversion_value_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.analytics.admin_v1alpha.types.SKAdNetworkConversionValueSchema: @@ -3521,7 +3612,7 @@ def create_sk_ad_network_conversion_value_schema( ] = None, retry: OptionalRetry = 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.SKAdNetworkConversionValueSchema: r"""Creates a SKAdNetworkConversionValueSchema. @@ -3548,8 +3639,10 @@ def create_sk_ad_network_conversion_value_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.analytics.admin_v1alpha.types.SKAdNetworkConversionValueSchema: @@ -3619,7 +3712,7 @@ def delete_sk_ad_network_conversion_value_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 target SKAdNetworkConversionValueSchema. @@ -3639,8 +3732,10 @@ def delete_sk_ad_network_conversion_value_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 @@ -3700,7 +3795,7 @@ def update_sk_ad_network_conversion_value_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]]] = (), ) -> resources.SKAdNetworkConversionValueSchema: r"""Updates a SKAdNetworkConversionValueSchema. @@ -3727,8 +3822,10 @@ def update_sk_ad_network_conversion_value_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.analytics.admin_v1alpha.types.SKAdNetworkConversionValueSchema: @@ -3805,7 +3902,7 @@ def list_sk_ad_network_conversion_value_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.ListSKAdNetworkConversionValueSchemasPager: r"""Lists SKAdNetworkConversionValueSchema on a stream. Properties can have at most one @@ -3828,8 +3925,10 @@ def list_sk_ad_network_conversion_value_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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListSKAdNetworkConversionValueSchemasPager: @@ -3908,7 +4007,7 @@ def search_change_history_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]]] = (), ) -> pagers.SearchChangeHistoryEventsPager: r"""Searches through all changes to an account or its children given the specified set of filters. @@ -3920,8 +4019,10 @@ def search_change_history_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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.SearchChangeHistoryEventsPager: @@ -3984,7 +4085,7 @@ def get_google_signals_settings( name: Optional[str] = None, retry: OptionalRetry = 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.GoogleSignalsSettings: r"""Lookup for Google Signals settings for a property. @@ -4003,8 +4104,10 @@ def get_google_signals_settings( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.GoogleSignalsSettings: @@ -4067,7 +4170,7 @@ def update_google_signals_settings( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.GoogleSignalsSettings: r"""Updates Google Signals settings for a property. @@ -4095,8 +4198,10 @@ def update_google_signals_settings( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.GoogleSignalsSettings: @@ -4168,7 +4273,7 @@ def create_conversion_event( conversion_event: Optional[resources.ConversionEvent] = None, retry: OptionalRetry = 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.ConversionEvent: r"""Deprecated: Use ``CreateKeyEvent`` instead. Creates a conversion event with the specified attributes. @@ -4196,8 +4301,10 @@ def create_conversion_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.analytics.admin_v1alpha.types.ConversionEvent: @@ -4265,7 +4372,7 @@ def update_conversion_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]]] = (), ) -> resources.ConversionEvent: r"""Deprecated: Use ``UpdateKeyEvent`` instead. Updates a conversion event with the specified attributes. @@ -4294,8 +4401,10 @@ def update_conversion_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.analytics.admin_v1alpha.types.ConversionEvent: @@ -4364,7 +4473,7 @@ def get_conversion_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.ConversionEvent: r"""Deprecated: Use ``GetKeyEvent`` instead. Retrieve a single conversion event. @@ -4385,8 +4494,10 @@ def get_conversion_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.analytics.admin_v1alpha.types.ConversionEvent: @@ -4451,7 +4562,7 @@ def delete_conversion_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"""Deprecated: Use ``DeleteKeyEvent`` instead. Deletes a conversion event in a property. @@ -4472,8 +4583,10 @@ def delete_conversion_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`. """ warnings.warn( "AnalyticsAdminServiceClient.delete_conversion_event is deprecated", @@ -4529,7 +4642,7 @@ def list_conversion_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.ListConversionEventsPager: r"""Deprecated: Use ``ListKeyEvents`` instead. Returns a list of conversion events in the specified parent property. @@ -4551,8 +4664,10 @@ def list_conversion_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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListConversionEventsPager: @@ -4630,7 +4745,7 @@ def create_key_event( key_event: Optional[resources.KeyEvent] = None, retry: OptionalRetry = 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.KeyEvent: r"""Creates a Key Event. @@ -4654,8 +4769,10 @@ def create_key_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.analytics.admin_v1alpha.types.KeyEvent: @@ -4716,7 +4833,7 @@ def update_key_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]]] = (), ) -> resources.KeyEvent: r"""Updates a Key Event. @@ -4744,8 +4861,10 @@ def update_key_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.analytics.admin_v1alpha.types.KeyEvent: @@ -4807,7 +4926,7 @@ def get_key_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.KeyEvent: r"""Retrieve a single Key Event. @@ -4826,8 +4945,10 @@ def get_key_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.analytics.admin_v1alpha.types.KeyEvent: @@ -4885,7 +5006,7 @@ def delete_key_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 a Key Event. @@ -4904,8 +5025,10 @@ def delete_key_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 @@ -4954,7 +5077,7 @@ def list_key_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.ListKeyEventsPager: r"""Returns a list of Key Events in the specified parent property. Returns an empty list if no Key Events are @@ -4974,8 +5097,10 @@ def list_key_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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListKeyEventsPager: @@ -5049,7 +5174,7 @@ def get_display_video360_advertiser_link( name: Optional[str] = None, retry: OptionalRetry = 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.DisplayVideo360AdvertiserLink: r"""Look up a single DisplayVideo360AdvertiserLink @@ -5069,8 +5194,10 @@ def get_display_video360_advertiser_link( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLink: @@ -5134,7 +5261,7 @@ def list_display_video360_advertiser_links( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDisplayVideo360AdvertiserLinksPager: r"""Lists all DisplayVideo360AdvertiserLinks on a property. @@ -5153,8 +5280,10 @@ def list_display_video360_advertiser_links( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListDisplayVideo360AdvertiserLinksPager: @@ -5235,7 +5364,7 @@ def create_display_video360_advertiser_link( ] = None, retry: OptionalRetry = 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.DisplayVideo360AdvertiserLink: r"""Creates a DisplayVideo360AdvertiserLink. This can only be utilized by users who have proper @@ -5265,8 +5394,10 @@ def create_display_video360_advertiser_link( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLink: @@ -5336,7 +5467,7 @@ def delete_display_video360_advertiser_link( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 DisplayVideo360AdvertiserLink on a property. @@ -5357,8 +5488,10 @@ def delete_display_video360_advertiser_link( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -5418,7 +5551,7 @@ def update_display_video360_advertiser_link( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.DisplayVideo360AdvertiserLink: r"""Updates a DisplayVideo360AdvertiserLink on a property. @@ -5446,8 +5579,10 @@ def update_display_video360_advertiser_link( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLink: @@ -5524,7 +5659,7 @@ def get_display_video360_advertiser_link_proposal( name: Optional[str] = None, retry: OptionalRetry = 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.DisplayVideo360AdvertiserLinkProposal: r"""Lookup for a single DisplayVideo360AdvertiserLinkProposal. @@ -5546,8 +5681,10 @@ def get_display_video360_advertiser_link_proposal( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLinkProposal: @@ -5623,7 +5760,7 @@ def list_display_video360_advertiser_link_proposals( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDisplayVideo360AdvertiserLinkProposalsPager: r"""Lists DisplayVideo360AdvertiserLinkProposals on a property. @@ -5643,8 +5780,10 @@ def list_display_video360_advertiser_link_proposals( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListDisplayVideo360AdvertiserLinkProposalsPager: @@ -5729,7 +5868,7 @@ def create_display_video360_advertiser_link_proposal( ] = None, retry: OptionalRetry = 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.DisplayVideo360AdvertiserLinkProposal: r"""Creates a DisplayVideo360AdvertiserLinkProposal. @@ -5756,8 +5895,10 @@ def create_display_video360_advertiser_link_proposal( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLinkProposal: @@ -5839,7 +5980,7 @@ def delete_display_video360_advertiser_link_proposal( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 DisplayVideo360AdvertiserLinkProposal on a property. This can only be used on cancelled proposals. @@ -5861,8 +6002,10 @@ def delete_display_video360_advertiser_link_proposal( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -5923,7 +6066,7 @@ def approve_display_video360_advertiser_link_proposal( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalResponse: r"""Approves a DisplayVideo360AdvertiserLinkProposal. The DisplayVideo360AdvertiserLinkProposal will be @@ -5938,8 +6081,10 @@ def approve_display_video360_advertiser_link_proposal( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.ApproveDisplayVideo360AdvertiserLinkProposalResponse: @@ -5996,7 +6141,7 @@ def cancel_display_video360_advertiser_link_proposal( *, retry: OptionalRetry = 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.DisplayVideo360AdvertiserLinkProposal: r"""Cancels a DisplayVideo360AdvertiserLinkProposal. Cancelling can mean either: @@ -6015,8 +6160,10 @@ def cancel_display_video360_advertiser_link_proposal( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.DisplayVideo360AdvertiserLinkProposal: @@ -6080,7 +6227,7 @@ def create_custom_dimension( custom_dimension: Optional[resources.CustomDimension] = None, retry: OptionalRetry = 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.CustomDimension: r"""Creates a CustomDimension. @@ -6105,8 +6252,10 @@ def create_custom_dimension( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.CustomDimension: @@ -6167,7 +6316,7 @@ def update_custom_dimension( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.CustomDimension: r"""Updates a CustomDimension on a property. @@ -6192,8 +6341,10 @@ def update_custom_dimension( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.CustomDimension: @@ -6255,7 +6406,7 @@ def list_custom_dimensions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCustomDimensionsPager: r"""Lists CustomDimensions on a property. @@ -6273,8 +6424,10 @@ def list_custom_dimensions( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListCustomDimensionsPager: @@ -6348,7 +6501,7 @@ def archive_custom_dimension( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Archives a CustomDimension on a property. @@ -6368,8 +6521,10 @@ def archive_custom_dimension( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -6420,7 +6575,7 @@ def get_custom_dimension( name: Optional[str] = None, retry: OptionalRetry = 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.CustomDimension: r"""Lookup for a single CustomDimension. @@ -6439,8 +6594,10 @@ def get_custom_dimension( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.CustomDimension: @@ -6499,7 +6656,7 @@ def create_custom_metric( custom_metric: Optional[resources.CustomMetric] = None, retry: OptionalRetry = 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.CustomMetric: r"""Creates a CustomMetric. @@ -6522,8 +6679,10 @@ def create_custom_metric( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.CustomMetric: @@ -6584,7 +6743,7 @@ def update_custom_metric( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.CustomMetric: r"""Updates a CustomMetric on a property. @@ -6609,8 +6768,10 @@ def update_custom_metric( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.CustomMetric: @@ -6670,7 +6831,7 @@ def list_custom_metrics( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCustomMetricsPager: r"""Lists CustomMetrics on a property. @@ -6688,8 +6849,10 @@ def list_custom_metrics( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListCustomMetricsPager: @@ -6763,7 +6926,7 @@ def archive_custom_metric( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Archives a CustomMetric on a property. @@ -6782,8 +6945,10 @@ def archive_custom_metric( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -6832,7 +6997,7 @@ def get_custom_metric( name: Optional[str] = None, retry: OptionalRetry = 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.CustomMetric: r"""Lookup for a single CustomMetric. @@ -6851,8 +7016,10 @@ def get_custom_metric( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.CustomMetric: @@ -6910,7 +7077,7 @@ def get_data_retention_settings( name: Optional[str] = None, retry: OptionalRetry = 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.DataRetentionSettings: r"""Returns the singleton data retention settings for this property. @@ -6933,8 +7100,10 @@ def get_data_retention_settings( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.DataRetentionSettings: @@ -6997,7 +7166,7 @@ def update_data_retention_settings( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.DataRetentionSettings: r"""Updates the singleton data retention settings for this property. @@ -7026,8 +7195,10 @@ def update_data_retention_settings( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.DataRetentionSettings: @@ -7097,7 +7268,7 @@ def create_data_stream( data_stream: Optional[resources.DataStream] = None, retry: OptionalRetry = 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.DataStream: r"""Creates a DataStream. @@ -7120,8 +7291,10 @@ def create_data_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.analytics.admin_v1alpha.types.DataStream: @@ -7181,7 +7354,7 @@ def delete_data_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]]] = (), ) -> None: r"""Deletes a DataStream on a property. @@ -7200,8 +7373,10 @@ def delete_data_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -7251,7 +7426,7 @@ def update_data_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]]] = (), ) -> resources.DataStream: r"""Updates a DataStream on a property. @@ -7276,8 +7451,10 @@ def update_data_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.analytics.admin_v1alpha.types.DataStream: @@ -7339,7 +7516,7 @@ def list_data_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.ListDataStreamsPager: r"""Lists DataStreams on a property. @@ -7357,8 +7534,10 @@ def list_data_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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListDataStreamsPager: @@ -7430,7 +7609,7 @@ def get_data_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]]] = (), ) -> resources.DataStream: r"""Lookup for a single DataStream. @@ -7449,8 +7628,10 @@ def get_data_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.analytics.admin_v1alpha.types.DataStream: @@ -7508,7 +7689,7 @@ def get_audience( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> audience.Audience: r"""Lookup for a single Audience. Audiences created before 2020 may not be supported. @@ -7528,8 +7709,10 @@ def get_audience( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.Audience: @@ -7587,7 +7770,7 @@ def list_audiences( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAudiencesPager: r"""Lists Audiences on a property. Audiences created before 2020 may not be supported. @@ -7607,8 +7790,10 @@ def list_audiences( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListAudiencesPager: @@ -7681,7 +7866,7 @@ def create_audience( audience: Optional[gaa_audience.Audience] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gaa_audience.Audience: r"""Creates an Audience. @@ -7704,8 +7889,10 @@ def create_audience( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.Audience: @@ -7766,7 +7953,7 @@ def update_audience( 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]]] = (), ) -> gaa_audience.Audience: r"""Updates an Audience on a property. @@ -7795,8 +7982,10 @@ def update_audience( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.Audience: @@ -7857,7 +8046,7 @@ def archive_audience( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Archives an Audience on a property. @@ -7868,8 +8057,10 @@ def archive_audience( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -7907,7 +8098,7 @@ def get_search_ads360_link( name: Optional[str] = None, retry: OptionalRetry = 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.SearchAds360Link: r"""Look up a single SearchAds360Link @@ -7926,8 +8117,10 @@ def get_search_ads360_link( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.SearchAds360Link: @@ -7987,7 +8180,7 @@ def list_search_ads360_links( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSearchAds360LinksPager: r"""Lists all SearchAds360Links on a property. @@ -8005,8 +8198,10 @@ def list_search_ads360_links( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListSearchAds360LinksPager: @@ -8081,7 +8276,7 @@ def create_search_ads360_link( search_ads_360_link: Optional[resources.SearchAds360Link] = None, retry: OptionalRetry = 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.SearchAds360Link: r"""Creates a SearchAds360Link. @@ -8106,8 +8301,10 @@ def create_search_ads360_link( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.SearchAds360Link: @@ -8171,7 +8368,7 @@ def delete_search_ads360_link( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 SearchAds360Link on a property. @@ -8191,8 +8388,10 @@ def delete_search_ads360_link( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -8246,7 +8445,7 @@ def update_search_ads360_link( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.SearchAds360Link: r"""Updates a SearchAds360Link on a property. @@ -8271,8 +8470,10 @@ def update_search_ads360_link( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.SearchAds360Link: @@ -8338,7 +8539,7 @@ def get_attribution_settings( name: Optional[str] = None, retry: OptionalRetry = 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.AttributionSettings: r"""Lookup for a AttributionSettings singleton. @@ -8357,8 +8558,10 @@ def get_attribution_settings( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.AttributionSettings: @@ -8420,7 +8623,7 @@ def update_attribution_settings( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.AttributionSettings: r"""Updates attribution settings on a property. @@ -8449,8 +8652,10 @@ def update_attribution_settings( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.AttributionSettings: @@ -8514,7 +8719,7 @@ def run_access_report( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.RunAccessReportResponse: r"""Returns a customized report of data access records. The report provides records of each time a user reads Google Analytics @@ -8540,8 +8745,10 @@ def run_access_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.analytics.admin_v1alpha.types.RunAccessReportResponse: @@ -8589,7 +8796,7 @@ def create_access_binding( access_binding: Optional[resources.AccessBinding] = None, retry: OptionalRetry = 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.AccessBinding: r"""Creates an access binding on an account or property. @@ -8616,8 +8823,10 @@ def create_access_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.analytics.admin_v1alpha.types.AccessBinding: @@ -8677,7 +8886,7 @@ def get_access_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]]] = (), ) -> resources.AccessBinding: r"""Gets information about an access binding. @@ -8700,8 +8909,10 @@ def get_access_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.analytics.admin_v1alpha.types.AccessBinding: @@ -8761,7 +8972,7 @@ def update_access_binding( access_binding: Optional[resources.AccessBinding] = None, retry: OptionalRetry = 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.AccessBinding: r"""Updates an access binding on an account or property. @@ -8779,8 +8990,10 @@ def update_access_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.analytics.admin_v1alpha.types.AccessBinding: @@ -8842,7 +9055,7 @@ def delete_access_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]]] = (), ) -> None: r"""Deletes an access binding on an account or property. @@ -8864,8 +9077,10 @@ def delete_access_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -8916,7 +9131,7 @@ def list_access_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.ListAccessBindingsPager: r"""Lists all access bindings on an account or property. @@ -8936,8 +9151,10 @@ def list_access_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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListAccessBindingsPager: @@ -9010,7 +9227,7 @@ def batch_create_access_bindings( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.BatchCreateAccessBindingsResponse: r"""Creates information about multiple access bindings to an account or property. @@ -9026,8 +9243,10 @@ def batch_create_access_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.analytics.admin_v1alpha.types.BatchCreateAccessBindingsResponse: @@ -9075,7 +9294,7 @@ def batch_get_access_bindings( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.BatchGetAccessBindingsResponse: r"""Gets information about multiple access bindings to an account or property. @@ -9087,8 +9306,10 @@ def batch_get_access_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.analytics.admin_v1alpha.types.BatchGetAccessBindingsResponse: @@ -9136,7 +9357,7 @@ def batch_update_access_bindings( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.BatchUpdateAccessBindingsResponse: r"""Updates information about multiple access bindings to an account or property. @@ -9148,8 +9369,10 @@ def batch_update_access_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.analytics.admin_v1alpha.types.BatchUpdateAccessBindingsResponse: @@ -9197,7 +9420,7 @@ def batch_delete_access_bindings( *, retry: OptionalRetry = gapic_v1.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 information about multiple users' links to an account or property. @@ -9209,8 +9432,10 @@ def batch_delete_access_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`. """ # Create or coerce a protobuf request object. # - Use the request object if provided (there's no risk of modifying the input as @@ -9250,7 +9475,7 @@ def get_expanded_data_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]]] = (), ) -> expanded_data_set.ExpandedDataSet: r"""Lookup for a single ExpandedDataSet. @@ -9269,8 +9494,10 @@ def get_expanded_data_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.analytics.admin_v1alpha.types.ExpandedDataSet: @@ -9330,7 +9557,7 @@ def list_expanded_data_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.ListExpandedDataSetsPager: r"""Lists ExpandedDataSets on a property. @@ -9348,8 +9575,10 @@ def list_expanded_data_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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListExpandedDataSetsPager: @@ -9424,7 +9653,7 @@ def create_expanded_data_set( expanded_data_set: Optional[gaa_expanded_data_set.ExpandedDataSet] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gaa_expanded_data_set.ExpandedDataSet: r"""Creates a ExpandedDataSet. @@ -9449,8 +9678,10 @@ def create_expanded_data_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.analytics.admin_v1alpha.types.ExpandedDataSet: @@ -9513,7 +9744,7 @@ def update_expanded_data_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]]] = (), ) -> gaa_expanded_data_set.ExpandedDataSet: r"""Updates a ExpandedDataSet on a property. @@ -9542,8 +9773,10 @@ def update_expanded_data_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.analytics.admin_v1alpha.types.ExpandedDataSet: @@ -9607,7 +9840,7 @@ def delete_expanded_data_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"""Deletes a ExpandedDataSet on a property. @@ -9625,8 +9858,10 @@ def delete_expanded_data_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 @@ -9675,7 +9910,7 @@ def get_channel_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]]] = (), ) -> channel_group.ChannelGroup: r"""Lookup for a single ChannelGroup. @@ -9694,8 +9929,10 @@ def get_channel_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.analytics.admin_v1alpha.types.ChannelGroup: @@ -9753,7 +9990,7 @@ def list_channel_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.ListChannelGroupsPager: r"""Lists ChannelGroups on a property. @@ -9772,8 +10009,10 @@ def list_channel_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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListChannelGroupsPager: @@ -9848,7 +10087,7 @@ def create_channel_group( channel_group: Optional[gaa_channel_group.ChannelGroup] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gaa_channel_group.ChannelGroup: r"""Creates a ChannelGroup. @@ -9872,8 +10111,10 @@ def create_channel_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.analytics.admin_v1alpha.types.ChannelGroup: @@ -9936,7 +10177,7 @@ def update_channel_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]]] = (), ) -> gaa_channel_group.ChannelGroup: r"""Updates a ChannelGroup. @@ -9965,8 +10206,10 @@ def update_channel_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.analytics.admin_v1alpha.types.ChannelGroup: @@ -10030,7 +10273,7 @@ def delete_channel_group( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a ChannelGroup on a property. @@ -10049,8 +10292,10 @@ def delete_channel_group( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -10100,7 +10345,7 @@ def set_automated_ga4_configuration_opt_out( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse: r"""Sets the opt out status for the automated GA4 setup process for a UA property. @@ -10114,8 +10359,10 @@ def set_automated_ga4_configuration_opt_out( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.SetAutomatedGa4ConfigurationOptOutResponse: @@ -10160,7 +10407,7 @@ def fetch_automated_ga4_configuration_opt_out( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.FetchAutomatedGa4ConfigurationOptOutResponse: r"""Fetches the opt out status for the automated GA4 setup process for a UA property. @@ -10174,8 +10421,10 @@ def fetch_automated_ga4_configuration_opt_out( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.FetchAutomatedGa4ConfigurationOptOutResponse: @@ -10224,7 +10473,7 @@ def create_big_query_link( bigquery_link: Optional[resources.BigQueryLink] = None, retry: OptionalRetry = 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.BigQueryLink: r"""Creates a BigQueryLink. @@ -10247,8 +10496,10 @@ def create_big_query_link( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.BigQueryLink: @@ -10308,7 +10559,7 @@ def get_big_query_link( name: Optional[str] = None, retry: OptionalRetry = 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.BigQueryLink: r"""Lookup for a single BigQuery Link. @@ -10328,8 +10579,10 @@ def get_big_query_link( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.BigQueryLink: @@ -10387,7 +10640,7 @@ def list_big_query_links( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListBigQueryLinksPager: r"""Lists BigQuery Links on a property. @@ -10406,8 +10659,10 @@ def list_big_query_links( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListBigQueryLinksPager: @@ -10481,7 +10736,7 @@ def delete_big_query_link( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 BigQueryLink on a property. @@ -10500,8 +10755,10 @@ def delete_big_query_link( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -10553,7 +10810,7 @@ def update_big_query_link( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.BigQueryLink: r"""Updates a BigQueryLink. @@ -10581,8 +10838,10 @@ def update_big_query_link( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.BigQueryLink: @@ -10646,7 +10905,7 @@ def get_enhanced_measurement_settings( name: Optional[str] = None, retry: OptionalRetry = 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.EnhancedMeasurementSettings: r"""Returns the enhanced measurement settings for this data stream. Note that the stream must enable enhanced @@ -10668,8 +10927,10 @@ def get_enhanced_measurement_settings( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.EnhancedMeasurementSettings: @@ -10738,7 +10999,7 @@ def update_enhanced_measurement_settings( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.EnhancedMeasurementSettings: r"""Updates the enhanced measurement settings for this data stream. Note that the stream must enable enhanced @@ -10768,8 +11029,10 @@ def update_enhanced_measurement_settings( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.EnhancedMeasurementSettings: @@ -10843,7 +11106,7 @@ def create_connected_site_tag( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.CreateConnectedSiteTagResponse: r"""Creates a connected site tag for a Universal Analytics property. You can create a maximum of 20 @@ -10857,8 +11120,10 @@ def create_connected_site_tag( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.CreateConnectedSiteTagResponse: @@ -10900,7 +11165,7 @@ def delete_connected_site_tag( *, retry: OptionalRetry = gapic_v1.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 connected site tag for a Universal Analytics property. Note: this has no effect on GA4 @@ -10913,8 +11178,10 @@ def delete_connected_site_tag( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -10947,7 +11214,7 @@ def list_connected_site_tags( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListConnectedSiteTagsResponse: r"""Lists the connected site tags for a Universal Analytics property. A maximum of 20 connected site tags @@ -10961,8 +11228,10 @@ def list_connected_site_tags( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.ListConnectedSiteTagsResponse: @@ -11002,7 +11271,7 @@ def fetch_connected_ga4_property( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.FetchConnectedGa4PropertyResponse: r"""Given a specified UA property, looks up the GA4 property connected to it. Note: this cannot be used with @@ -11015,8 +11284,10 @@ def fetch_connected_ga4_property( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.FetchConnectedGa4PropertyResponse: @@ -11057,7 +11328,7 @@ def get_ad_sense_link( name: Optional[str] = None, retry: OptionalRetry = 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.AdSenseLink: r"""Looks up a single AdSenseLink. @@ -11078,8 +11349,10 @@ def get_ad_sense_link( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.AdSenseLink: @@ -11138,7 +11411,7 @@ def create_ad_sense_link( adsense_link: Optional[resources.AdSenseLink] = None, retry: OptionalRetry = 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.AdSenseLink: r"""Creates an AdSenseLink. @@ -11163,8 +11436,10 @@ def create_ad_sense_link( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.AdSenseLink: @@ -11224,7 +11499,7 @@ def delete_ad_sense_link( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 AdSenseLink. @@ -11245,8 +11520,10 @@ def delete_ad_sense_link( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -11295,7 +11572,7 @@ def list_ad_sense_links( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAdSenseLinksPager: r"""Lists AdSenseLinks on a property. @@ -11315,8 +11592,10 @@ def list_ad_sense_links( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListAdSenseLinksPager: @@ -11390,7 +11669,7 @@ def get_event_create_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]]] = (), ) -> event_create_and_edit.EventCreateRule: r"""Lookup for a single EventCreateRule. @@ -11409,8 +11688,10 @@ def get_event_create_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.analytics.admin_v1alpha.types.EventCreateRule: @@ -11482,7 +11763,7 @@ def list_event_create_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.ListEventCreateRulesPager: r"""Lists EventCreateRules on a web data stream. @@ -11500,8 +11781,10 @@ def list_event_create_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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListEventCreateRulesPager: @@ -11576,7 +11859,7 @@ def create_event_create_rule( event_create_rule: Optional[event_create_and_edit.EventCreateRule] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> event_create_and_edit.EventCreateRule: r"""Creates an EventCreateRule. @@ -11601,8 +11884,10 @@ def create_event_create_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.analytics.admin_v1alpha.types.EventCreateRule: @@ -11677,7 +11962,7 @@ def update_event_create_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]]] = (), ) -> event_create_and_edit.EventCreateRule: r"""Updates an EventCreateRule. @@ -11706,8 +11991,10 @@ def update_event_create_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.analytics.admin_v1alpha.types.EventCreateRule: @@ -11783,7 +12070,7 @@ def delete_event_create_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]]] = (), ) -> None: r"""Deletes an EventCreateRule. @@ -11802,8 +12089,10 @@ def delete_event_create_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -11852,7 +12141,7 @@ def get_event_edit_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]]] = (), ) -> event_create_and_edit.EventEditRule: r"""Lookup for a single EventEditRule. @@ -11871,8 +12160,10 @@ def get_event_edit_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.analytics.admin_v1alpha.types.EventEditRule: @@ -11944,7 +12235,7 @@ def list_event_edit_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.ListEventEditRulesPager: r"""Lists EventEditRules on a web data stream. @@ -11962,8 +12253,10 @@ def list_event_edit_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.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListEventEditRulesPager: @@ -12038,7 +12331,7 @@ def create_event_edit_rule( event_edit_rule: Optional[event_create_and_edit.EventEditRule] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> event_create_and_edit.EventEditRule: r"""Creates an EventEditRule. @@ -12063,8 +12356,10 @@ def create_event_edit_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.analytics.admin_v1alpha.types.EventEditRule: @@ -12139,7 +12434,7 @@ def update_event_edit_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]]] = (), ) -> event_create_and_edit.EventEditRule: r"""Updates an EventEditRule. @@ -12168,8 +12463,10 @@ def update_event_edit_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.analytics.admin_v1alpha.types.EventEditRule: @@ -12245,7 +12542,7 @@ def delete_event_edit_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]]] = (), ) -> None: r"""Deletes an EventEditRule. @@ -12263,8 +12560,10 @@ def delete_event_edit_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -12314,7 +12613,7 @@ def reorder_event_edit_rules( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Changes the processing order of event edit rules on the specified stream. @@ -12326,8 +12625,10 @@ def reorder_event_edit_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`. """ # Create or coerce a protobuf request object. # - Use the request object if provided (there's no risk of modifying the input as @@ -12366,7 +12667,7 @@ def update_data_redaction_settings( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.DataRedactionSettings: r"""Updates a DataRedactionSettings on a property. @@ -12394,8 +12695,10 @@ def update_data_redaction_settings( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.DataRedactionSettings: @@ -12467,7 +12770,7 @@ def get_data_redaction_settings( name: Optional[str] = None, retry: OptionalRetry = 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.DataRedactionSettings: r"""Lookup for a single DataRedactionSettings. @@ -12487,8 +12790,10 @@ def get_data_redaction_settings( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.DataRedactionSettings: @@ -12551,7 +12856,7 @@ def get_calculated_metric( name: Optional[str] = None, retry: OptionalRetry = 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.CalculatedMetric: r"""Lookup for a single CalculatedMetric. @@ -12571,8 +12876,10 @@ def get_calculated_metric( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.CalculatedMetric: @@ -12632,7 +12939,7 @@ def create_calculated_metric( calculated_metric_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.CalculatedMetric: r"""Creates a CalculatedMetric. @@ -12673,8 +12980,10 @@ def create_calculated_metric( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.CalculatedMetric: @@ -12736,7 +13045,7 @@ def list_calculated_metrics( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCalculatedMetricsPager: r"""Lists CalculatedMetrics on a property. @@ -12754,8 +13063,10 @@ def list_calculated_metrics( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListCalculatedMetricsPager: @@ -12830,7 +13141,7 @@ def update_calculated_metric( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.CalculatedMetric: r"""Updates a CalculatedMetric on a property. @@ -12857,8 +13168,10 @@ def update_calculated_metric( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.CalculatedMetric: @@ -12920,7 +13233,7 @@ def delete_calculated_metric( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 CalculatedMetric on a property. @@ -12940,8 +13253,10 @@ def delete_calculated_metric( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -12991,7 +13306,7 @@ def create_rollup_property( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.CreateRollupPropertyResponse: r"""Create a roll-up property and all roll-up property source links. @@ -13003,8 +13318,10 @@ def create_rollup_property( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.CreateRollupPropertyResponse: @@ -13045,7 +13362,7 @@ def get_rollup_property_source_link( name: Optional[str] = None, retry: OptionalRetry = 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.RollupPropertySourceLink: r"""Lookup for a single roll-up property source Link. Only roll-up properties can have source links, so this @@ -13068,8 +13385,10 @@ def get_rollup_property_source_link( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.RollupPropertySourceLink: @@ -13132,7 +13451,7 @@ def list_rollup_property_source_links( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListRollupPropertySourceLinksPager: r"""Lists roll-up property source Links on a property. Only roll-up properties can have source links, so this @@ -13154,8 +13473,10 @@ def list_rollup_property_source_links( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListRollupPropertySourceLinksPager: @@ -13236,7 +13557,7 @@ def create_rollup_property_source_link( ] = None, retry: OptionalRetry = 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.RollupPropertySourceLink: r"""Creates a roll-up property source link. Only roll-up properties can have source links, so this @@ -13264,8 +13585,10 @@ def create_rollup_property_source_link( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.RollupPropertySourceLink: @@ -13332,7 +13655,7 @@ def delete_rollup_property_source_link( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 roll-up property source link. Only roll-up properties can have source links, so this @@ -13354,8 +13677,10 @@ def delete_rollup_property_source_link( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -13409,7 +13734,7 @@ def provision_subproperty( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ProvisionSubpropertyResponse: r"""Create a subproperty and a subproperty event filter that applies to the created subproperty. @@ -13421,8 +13746,10 @@ def provision_subproperty( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.ProvisionSubpropertyResponse: @@ -13466,7 +13793,7 @@ def create_subproperty_event_filter( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gaa_subproperty_event_filter.SubpropertyEventFilter: r"""Creates a subproperty Event Filter. @@ -13492,8 +13819,10 @@ def create_subproperty_event_filter( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.SubpropertyEventFilter: @@ -13557,7 +13886,7 @@ def get_subproperty_event_filter( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> subproperty_event_filter.SubpropertyEventFilter: r"""Lookup for a single subproperty Event Filter. @@ -13577,8 +13906,10 @@ def get_subproperty_event_filter( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.SubpropertyEventFilter: @@ -13640,7 +13971,7 @@ def list_subproperty_event_filters( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSubpropertyEventFiltersPager: r"""List all subproperty Event Filters on a property. @@ -13658,8 +13989,10 @@ def list_subproperty_event_filters( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.services.analytics_admin_service.pagers.ListSubpropertyEventFiltersPager: @@ -13738,7 +14071,7 @@ def update_subproperty_event_filter( 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]]] = (), ) -> gaa_subproperty_event_filter.SubpropertyEventFilter: r"""Updates a subproperty Event Filter. @@ -13766,8 +14099,10 @@ def update_subproperty_event_filter( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1alpha.types.SubpropertyEventFilter: @@ -13838,7 +14173,7 @@ def delete_subproperty_event_filter( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 subproperty event filter. @@ -13858,8 +14193,10 @@ def delete_subproperty_event_filter( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/pagers.py b/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/pagers.py index 1b458359c185..04f56f04970d 100644 --- a/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/pagers.py +++ b/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_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 = analytics_admin.ListAccountsRequest(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 = analytics_admin.ListAccountsRequest(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 = analytics_admin.ListAccountSummariesRequest(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 = analytics_admin.ListAccountSummariesRequest(request) @@ -381,7 +389,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -395,8 +403,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = analytics_admin.ListPropertiesRequest(request) @@ -455,7 +465,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. @@ -469,8 +479,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 = analytics_admin.ListPropertiesRequest(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 = analytics_admin.ListFirebaseLinksRequest(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 = analytics_admin.ListFirebaseLinksRequest(request) @@ -685,7 +701,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -699,8 +715,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = analytics_admin.ListGoogleAdsLinksRequest(request) @@ -759,7 +777,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. @@ -773,8 +791,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 = analytics_admin.ListGoogleAdsLinksRequest(request) @@ -837,7 +857,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -851,8 +871,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = analytics_admin.ListMeasurementProtocolSecretsRequest(request) @@ -913,7 +935,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. @@ -927,8 +949,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 = analytics_admin.ListMeasurementProtocolSecretsRequest(request) @@ -995,7 +1019,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1009,8 +1033,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = analytics_admin.ListSKAdNetworkConversionValueSchemasRequest( @@ -1076,7 +1102,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. @@ -1090,8 +1116,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 = analytics_admin.ListSKAdNetworkConversionValueSchemasRequest( @@ -1158,7 +1186,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1172,8 +1200,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = analytics_admin.SearchChangeHistoryEventsRequest(request) @@ -1234,7 +1264,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. @@ -1248,8 +1278,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 = analytics_admin.SearchChangeHistoryEventsRequest(request) @@ -1314,7 +1346,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1328,8 +1360,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = analytics_admin.ListConversionEventsRequest(request) @@ -1388,7 +1422,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. @@ -1402,8 +1436,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 = analytics_admin.ListConversionEventsRequest(request) @@ -1468,7 +1504,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1482,8 +1518,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = analytics_admin.ListKeyEventsRequest(request) @@ -1542,7 +1580,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. @@ -1556,8 +1594,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 = analytics_admin.ListKeyEventsRequest(request) @@ -1622,7 +1662,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1636,8 +1676,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = analytics_admin.ListDisplayVideo360AdvertiserLinksRequest( @@ -1702,7 +1744,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. @@ -1716,8 +1758,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 = analytics_admin.ListDisplayVideo360AdvertiserLinksRequest( @@ -1786,7 +1830,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1800,8 +1844,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = ( @@ -1869,7 +1915,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. @@ -1883,8 +1929,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 = ( @@ -1955,7 +2003,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1969,8 +2017,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = analytics_admin.ListCustomDimensionsRequest(request) @@ -2029,7 +2079,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. @@ -2043,8 +2093,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 = analytics_admin.ListCustomDimensionsRequest(request) @@ -2109,7 +2161,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -2123,8 +2175,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = analytics_admin.ListCustomMetricsRequest(request) @@ -2183,7 +2237,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. @@ -2197,8 +2251,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 = analytics_admin.ListCustomMetricsRequest(request) @@ -2261,7 +2317,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -2275,8 +2331,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = analytics_admin.ListDataStreamsRequest(request) @@ -2335,7 +2393,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. @@ -2349,8 +2407,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 = analytics_admin.ListDataStreamsRequest(request) @@ -2413,7 +2473,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -2427,8 +2487,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = analytics_admin.ListAudiencesRequest(request) @@ -2487,7 +2549,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. @@ -2501,8 +2563,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 = analytics_admin.ListAudiencesRequest(request) @@ -2565,7 +2629,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -2579,8 +2643,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = analytics_admin.ListSearchAds360LinksRequest(request) @@ -2639,7 +2705,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. @@ -2653,8 +2719,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 = analytics_admin.ListSearchAds360LinksRequest(request) @@ -2719,7 +2787,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -2733,8 +2801,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = analytics_admin.ListAccessBindingsRequest(request) @@ -2793,7 +2863,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. @@ -2807,8 +2877,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 = analytics_admin.ListAccessBindingsRequest(request) @@ -2871,7 +2943,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -2885,8 +2957,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = analytics_admin.ListExpandedDataSetsRequest(request) @@ -2945,7 +3019,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. @@ -2959,8 +3033,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 = analytics_admin.ListExpandedDataSetsRequest(request) @@ -3025,7 +3101,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -3039,8 +3115,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = analytics_admin.ListChannelGroupsRequest(request) @@ -3099,7 +3177,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. @@ -3113,8 +3191,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 = analytics_admin.ListChannelGroupsRequest(request) @@ -3177,7 +3257,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -3191,8 +3271,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = analytics_admin.ListBigQueryLinksRequest(request) @@ -3251,7 +3333,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. @@ -3265,8 +3347,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 = analytics_admin.ListBigQueryLinksRequest(request) @@ -3329,7 +3413,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -3343,8 +3427,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = analytics_admin.ListAdSenseLinksRequest(request) @@ -3403,7 +3489,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. @@ -3417,8 +3503,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 = analytics_admin.ListAdSenseLinksRequest(request) @@ -3481,7 +3569,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -3495,8 +3583,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = analytics_admin.ListEventCreateRulesRequest(request) @@ -3555,7 +3645,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. @@ -3569,8 +3659,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 = analytics_admin.ListEventCreateRulesRequest(request) @@ -3635,7 +3727,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -3649,8 +3741,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = analytics_admin.ListEventEditRulesRequest(request) @@ -3709,7 +3803,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. @@ -3723,8 +3817,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 = analytics_admin.ListEventEditRulesRequest(request) @@ -3787,7 +3883,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -3801,8 +3897,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = analytics_admin.ListCalculatedMetricsRequest(request) @@ -3861,7 +3959,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. @@ -3875,8 +3973,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 = analytics_admin.ListCalculatedMetricsRequest(request) @@ -3941,7 +4041,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -3955,8 +4055,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = analytics_admin.ListRollupPropertySourceLinksRequest(request) @@ -4017,7 +4119,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. @@ -4031,8 +4133,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 = analytics_admin.ListRollupPropertySourceLinksRequest(request) @@ -4097,7 +4201,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -4111,8 +4215,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = analytics_admin.ListSubpropertyEventFiltersRequest(request) @@ -4173,7 +4279,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. @@ -4187,8 +4293,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 = analytics_admin.ListSubpropertyEventFiltersRequest(request) diff --git a/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc.py b/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc.py index e73db13774f3..04146df37ed8 100644 --- a/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc.py +++ b/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,7 +24,10 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.analytics.admin_v1alpha.types import channel_group as gaa_channel_group from google.analytics.admin_v1alpha.types import ( @@ -41,6 +47,81 @@ from .base import DEFAULT_CLIENT_INFO, AnalyticsAdminServiceTransport +try: + from google.api_core import client_logging # 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.analytics.admin.v1alpha.AnalyticsAdminService", + "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.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AnalyticsAdminServiceGrpcTransport(AnalyticsAdminServiceTransport): """gRPC backend transport for AnalyticsAdminService. @@ -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 @@ -268,7 +354,7 @@ def get_account( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_account" not in self._stubs: - self._stubs["get_account"] = self.grpc_channel.unary_unary( + self._stubs["get_account"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetAccount", request_serializer=analytics_admin.GetAccountRequest.serialize, response_deserializer=resources.Account.deserialize, @@ -301,7 +387,7 @@ def list_accounts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_accounts" not in self._stubs: - self._stubs["list_accounts"] = self.grpc_channel.unary_unary( + self._stubs["list_accounts"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListAccounts", request_serializer=analytics_admin.ListAccountsRequest.serialize, response_deserializer=analytics_admin.ListAccountsResponse.deserialize, @@ -339,7 +425,7 @@ def delete_account( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_account" not in self._stubs: - self._stubs["delete_account"] = self.grpc_channel.unary_unary( + self._stubs["delete_account"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteAccount", request_serializer=analytics_admin.DeleteAccountRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -365,7 +451,7 @@ def update_account( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_account" not in self._stubs: - self._stubs["update_account"] = self.grpc_channel.unary_unary( + self._stubs["update_account"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateAccount", request_serializer=analytics_admin.UpdateAccountRequest.serialize, response_deserializer=resources.Account.deserialize, @@ -394,7 +480,7 @@ def provision_account_ticket( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "provision_account_ticket" not in self._stubs: - self._stubs["provision_account_ticket"] = self.grpc_channel.unary_unary( + self._stubs["provision_account_ticket"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ProvisionAccountTicket", request_serializer=analytics_admin.ProvisionAccountTicketRequest.serialize, response_deserializer=analytics_admin.ProvisionAccountTicketResponse.deserialize, @@ -424,7 +510,7 @@ def list_account_summaries( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_account_summaries" not in self._stubs: - self._stubs["list_account_summaries"] = self.grpc_channel.unary_unary( + self._stubs["list_account_summaries"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListAccountSummaries", request_serializer=analytics_admin.ListAccountSummariesRequest.serialize, response_deserializer=analytics_admin.ListAccountSummariesResponse.deserialize, @@ -450,7 +536,7 @@ def get_property( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_property" not in self._stubs: - self._stubs["get_property"] = self.grpc_channel.unary_unary( + self._stubs["get_property"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetProperty", request_serializer=analytics_admin.GetPropertyRequest.serialize, response_deserializer=resources.Property.deserialize, @@ -484,7 +570,7 @@ def list_properties( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_properties" not in self._stubs: - self._stubs["list_properties"] = self.grpc_channel.unary_unary( + self._stubs["list_properties"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListProperties", request_serializer=analytics_admin.ListPropertiesRequest.serialize, response_deserializer=analytics_admin.ListPropertiesResponse.deserialize, @@ -511,7 +597,7 @@ def create_property( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_property" not in self._stubs: - self._stubs["create_property"] = self.grpc_channel.unary_unary( + self._stubs["create_property"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateProperty", request_serializer=analytics_admin.CreatePropertyRequest.serialize, response_deserializer=resources.Property.deserialize, @@ -550,7 +636,7 @@ def delete_property( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_property" not in self._stubs: - self._stubs["delete_property"] = self.grpc_channel.unary_unary( + self._stubs["delete_property"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteProperty", request_serializer=analytics_admin.DeletePropertyRequest.serialize, response_deserializer=resources.Property.deserialize, @@ -576,7 +662,7 @@ def update_property( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_property" not in self._stubs: - self._stubs["update_property"] = self.grpc_channel.unary_unary( + self._stubs["update_property"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateProperty", request_serializer=analytics_admin.UpdatePropertyRequest.serialize, response_deserializer=resources.Property.deserialize, @@ -604,7 +690,7 @@ def create_firebase_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_firebase_link" not in self._stubs: - self._stubs["create_firebase_link"] = self.grpc_channel.unary_unary( + self._stubs["create_firebase_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateFirebaseLink", request_serializer=analytics_admin.CreateFirebaseLinkRequest.serialize, response_deserializer=resources.FirebaseLink.deserialize, @@ -630,7 +716,7 @@ def delete_firebase_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_firebase_link" not in self._stubs: - self._stubs["delete_firebase_link"] = self.grpc_channel.unary_unary( + self._stubs["delete_firebase_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteFirebaseLink", request_serializer=analytics_admin.DeleteFirebaseLinkRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -660,7 +746,7 @@ def list_firebase_links( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_firebase_links" not in self._stubs: - self._stubs["list_firebase_links"] = self.grpc_channel.unary_unary( + self._stubs["list_firebase_links"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListFirebaseLinks", request_serializer=analytics_admin.ListFirebaseLinksRequest.serialize, response_deserializer=analytics_admin.ListFirebaseLinksResponse.deserialize, @@ -687,7 +773,7 @@ def get_global_site_tag( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_global_site_tag" not in self._stubs: - self._stubs["get_global_site_tag"] = self.grpc_channel.unary_unary( + self._stubs["get_global_site_tag"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetGlobalSiteTag", request_serializer=analytics_admin.GetGlobalSiteTagRequest.serialize, response_deserializer=resources.GlobalSiteTag.deserialize, @@ -715,7 +801,7 @@ def create_google_ads_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_google_ads_link" not in self._stubs: - self._stubs["create_google_ads_link"] = self.grpc_channel.unary_unary( + self._stubs["create_google_ads_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateGoogleAdsLink", request_serializer=analytics_admin.CreateGoogleAdsLinkRequest.serialize, response_deserializer=resources.GoogleAdsLink.deserialize, @@ -743,7 +829,7 @@ def update_google_ads_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_google_ads_link" not in self._stubs: - self._stubs["update_google_ads_link"] = self.grpc_channel.unary_unary( + self._stubs["update_google_ads_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateGoogleAdsLink", request_serializer=analytics_admin.UpdateGoogleAdsLinkRequest.serialize, response_deserializer=resources.GoogleAdsLink.deserialize, @@ -769,7 +855,7 @@ def delete_google_ads_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_google_ads_link" not in self._stubs: - self._stubs["delete_google_ads_link"] = self.grpc_channel.unary_unary( + self._stubs["delete_google_ads_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteGoogleAdsLink", request_serializer=analytics_admin.DeleteGoogleAdsLinkRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -798,7 +884,7 @@ def list_google_ads_links( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_google_ads_links" not in self._stubs: - self._stubs["list_google_ads_links"] = self.grpc_channel.unary_unary( + self._stubs["list_google_ads_links"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListGoogleAdsLinks", request_serializer=analytics_admin.ListGoogleAdsLinksRequest.serialize, response_deserializer=analytics_admin.ListGoogleAdsLinksResponse.deserialize, @@ -827,7 +913,7 @@ def get_data_sharing_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_data_sharing_settings" not in self._stubs: - self._stubs["get_data_sharing_settings"] = self.grpc_channel.unary_unary( + self._stubs["get_data_sharing_settings"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetDataSharingSettings", request_serializer=analytics_admin.GetDataSharingSettingsRequest.serialize, response_deserializer=resources.DataSharingSettings.deserialize, @@ -859,7 +945,7 @@ def get_measurement_protocol_secret( if "get_measurement_protocol_secret" not in self._stubs: self._stubs[ "get_measurement_protocol_secret" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetMeasurementProtocolSecret", request_serializer=analytics_admin.GetMeasurementProtocolSecretRequest.serialize, response_deserializer=resources.MeasurementProtocolSecret.deserialize, @@ -892,7 +978,7 @@ def list_measurement_protocol_secrets( if "list_measurement_protocol_secrets" not in self._stubs: self._stubs[ "list_measurement_protocol_secrets" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListMeasurementProtocolSecrets", request_serializer=analytics_admin.ListMeasurementProtocolSecretsRequest.serialize, response_deserializer=analytics_admin.ListMeasurementProtocolSecretsResponse.deserialize, @@ -924,7 +1010,7 @@ def create_measurement_protocol_secret( if "create_measurement_protocol_secret" not in self._stubs: self._stubs[ "create_measurement_protocol_secret" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateMeasurementProtocolSecret", request_serializer=analytics_admin.CreateMeasurementProtocolSecretRequest.serialize, response_deserializer=resources.MeasurementProtocolSecret.deserialize, @@ -955,7 +1041,7 @@ def delete_measurement_protocol_secret( if "delete_measurement_protocol_secret" not in self._stubs: self._stubs[ "delete_measurement_protocol_secret" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteMeasurementProtocolSecret", request_serializer=analytics_admin.DeleteMeasurementProtocolSecretRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -987,7 +1073,7 @@ def update_measurement_protocol_secret( if "update_measurement_protocol_secret" not in self._stubs: self._stubs[ "update_measurement_protocol_secret" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateMeasurementProtocolSecret", request_serializer=analytics_admin.UpdateMeasurementProtocolSecretRequest.serialize, response_deserializer=resources.MeasurementProtocolSecret.deserialize, @@ -1023,7 +1109,7 @@ def acknowledge_user_data_collection( if "acknowledge_user_data_collection" not in self._stubs: self._stubs[ "acknowledge_user_data_collection" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/AcknowledgeUserDataCollection", request_serializer=analytics_admin.AcknowledgeUserDataCollectionRequest.serialize, response_deserializer=analytics_admin.AcknowledgeUserDataCollectionResponse.deserialize, @@ -1055,7 +1141,7 @@ def get_sk_ad_network_conversion_value_schema( if "get_sk_ad_network_conversion_value_schema" not in self._stubs: self._stubs[ "get_sk_ad_network_conversion_value_schema" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetSKAdNetworkConversionValueSchema", request_serializer=analytics_admin.GetSKAdNetworkConversionValueSchemaRequest.serialize, response_deserializer=resources.SKAdNetworkConversionValueSchema.deserialize, @@ -1087,7 +1173,7 @@ def create_sk_ad_network_conversion_value_schema( if "create_sk_ad_network_conversion_value_schema" not in self._stubs: self._stubs[ "create_sk_ad_network_conversion_value_schema" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateSKAdNetworkConversionValueSchema", request_serializer=analytics_admin.CreateSKAdNetworkConversionValueSchemaRequest.serialize, response_deserializer=resources.SKAdNetworkConversionValueSchema.deserialize, @@ -1118,7 +1204,7 @@ def delete_sk_ad_network_conversion_value_schema( if "delete_sk_ad_network_conversion_value_schema" not in self._stubs: self._stubs[ "delete_sk_ad_network_conversion_value_schema" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteSKAdNetworkConversionValueSchema", request_serializer=analytics_admin.DeleteSKAdNetworkConversionValueSchemaRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1150,7 +1236,7 @@ def update_sk_ad_network_conversion_value_schema( if "update_sk_ad_network_conversion_value_schema" not in self._stubs: self._stubs[ "update_sk_ad_network_conversion_value_schema" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateSKAdNetworkConversionValueSchema", request_serializer=analytics_admin.UpdateSKAdNetworkConversionValueSchemaRequest.serialize, response_deserializer=resources.SKAdNetworkConversionValueSchema.deserialize, @@ -1184,7 +1270,7 @@ def list_sk_ad_network_conversion_value_schemas( if "list_sk_ad_network_conversion_value_schemas" not in self._stubs: self._stubs[ "list_sk_ad_network_conversion_value_schemas" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListSKAdNetworkConversionValueSchemas", request_serializer=analytics_admin.ListSKAdNetworkConversionValueSchemasRequest.serialize, response_deserializer=analytics_admin.ListSKAdNetworkConversionValueSchemasResponse.deserialize, @@ -1214,7 +1300,9 @@ def search_change_history_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_change_history_events" not in self._stubs: - self._stubs["search_change_history_events"] = self.grpc_channel.unary_unary( + self._stubs[ + "search_change_history_events" + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/SearchChangeHistoryEvents", request_serializer=analytics_admin.SearchChangeHistoryEventsRequest.serialize, response_deserializer=analytics_admin.SearchChangeHistoryEventsResponse.deserialize, @@ -1243,7 +1331,9 @@ def get_google_signals_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_google_signals_settings" not in self._stubs: - self._stubs["get_google_signals_settings"] = self.grpc_channel.unary_unary( + self._stubs[ + "get_google_signals_settings" + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetGoogleSignalsSettings", request_serializer=analytics_admin.GetGoogleSignalsSettingsRequest.serialize, response_deserializer=resources.GoogleSignalsSettings.deserialize, @@ -1274,7 +1364,7 @@ def update_google_signals_settings( if "update_google_signals_settings" not in self._stubs: self._stubs[ "update_google_signals_settings" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateGoogleSignalsSettings", request_serializer=analytics_admin.UpdateGoogleSignalsSettingsRequest.serialize, response_deserializer=resources.GoogleSignalsSettings.deserialize, @@ -1303,7 +1393,7 @@ def create_conversion_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_conversion_event" not in self._stubs: - self._stubs["create_conversion_event"] = self.grpc_channel.unary_unary( + self._stubs["create_conversion_event"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateConversionEvent", request_serializer=analytics_admin.CreateConversionEventRequest.serialize, response_deserializer=resources.ConversionEvent.deserialize, @@ -1332,7 +1422,7 @@ def update_conversion_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_conversion_event" not in self._stubs: - self._stubs["update_conversion_event"] = self.grpc_channel.unary_unary( + self._stubs["update_conversion_event"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateConversionEvent", request_serializer=analytics_admin.UpdateConversionEventRequest.serialize, response_deserializer=resources.ConversionEvent.deserialize, @@ -1361,7 +1451,7 @@ def get_conversion_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_conversion_event" not in self._stubs: - self._stubs["get_conversion_event"] = self.grpc_channel.unary_unary( + self._stubs["get_conversion_event"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetConversionEvent", request_serializer=analytics_admin.GetConversionEventRequest.serialize, response_deserializer=resources.ConversionEvent.deserialize, @@ -1388,7 +1478,7 @@ def delete_conversion_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_conversion_event" not in self._stubs: - self._stubs["delete_conversion_event"] = self.grpc_channel.unary_unary( + self._stubs["delete_conversion_event"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteConversionEvent", request_serializer=analytics_admin.DeleteConversionEventRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1420,7 +1510,7 @@ def list_conversion_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_conversion_events" not in self._stubs: - self._stubs["list_conversion_events"] = self.grpc_channel.unary_unary( + self._stubs["list_conversion_events"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListConversionEvents", request_serializer=analytics_admin.ListConversionEventsRequest.serialize, response_deserializer=analytics_admin.ListConversionEventsResponse.deserialize, @@ -1446,7 +1536,7 @@ def create_key_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_key_event" not in self._stubs: - self._stubs["create_key_event"] = self.grpc_channel.unary_unary( + self._stubs["create_key_event"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateKeyEvent", request_serializer=analytics_admin.CreateKeyEventRequest.serialize, response_deserializer=resources.KeyEvent.deserialize, @@ -1472,7 +1562,7 @@ def update_key_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_key_event" not in self._stubs: - self._stubs["update_key_event"] = self.grpc_channel.unary_unary( + self._stubs["update_key_event"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateKeyEvent", request_serializer=analytics_admin.UpdateKeyEventRequest.serialize, response_deserializer=resources.KeyEvent.deserialize, @@ -1498,7 +1588,7 @@ def get_key_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_key_event" not in self._stubs: - self._stubs["get_key_event"] = self.grpc_channel.unary_unary( + self._stubs["get_key_event"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetKeyEvent", request_serializer=analytics_admin.GetKeyEventRequest.serialize, response_deserializer=resources.KeyEvent.deserialize, @@ -1524,7 +1614,7 @@ def delete_key_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_key_event" not in self._stubs: - self._stubs["delete_key_event"] = self.grpc_channel.unary_unary( + self._stubs["delete_key_event"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteKeyEvent", request_serializer=analytics_admin.DeleteKeyEventRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1554,7 +1644,7 @@ def list_key_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_key_events" not in self._stubs: - self._stubs["list_key_events"] = self.grpc_channel.unary_unary( + self._stubs["list_key_events"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListKeyEvents", request_serializer=analytics_admin.ListKeyEventsRequest.serialize, response_deserializer=analytics_admin.ListKeyEventsResponse.deserialize, @@ -1586,7 +1676,7 @@ def get_display_video360_advertiser_link( if "get_display_video360_advertiser_link" not in self._stubs: self._stubs[ "get_display_video360_advertiser_link" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetDisplayVideo360AdvertiserLink", request_serializer=analytics_admin.GetDisplayVideo360AdvertiserLinkRequest.serialize, response_deserializer=resources.DisplayVideo360AdvertiserLink.deserialize, @@ -1619,7 +1709,7 @@ def list_display_video360_advertiser_links( if "list_display_video360_advertiser_links" not in self._stubs: self._stubs[ "list_display_video360_advertiser_links" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListDisplayVideo360AdvertiserLinks", request_serializer=analytics_admin.ListDisplayVideo360AdvertiserLinksRequest.serialize, response_deserializer=analytics_admin.ListDisplayVideo360AdvertiserLinksResponse.deserialize, @@ -1656,7 +1746,7 @@ def create_display_video360_advertiser_link( if "create_display_video360_advertiser_link" not in self._stubs: self._stubs[ "create_display_video360_advertiser_link" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateDisplayVideo360AdvertiserLink", request_serializer=analytics_admin.CreateDisplayVideo360AdvertiserLinkRequest.serialize, response_deserializer=resources.DisplayVideo360AdvertiserLink.deserialize, @@ -1688,7 +1778,7 @@ def delete_display_video360_advertiser_link( if "delete_display_video360_advertiser_link" not in self._stubs: self._stubs[ "delete_display_video360_advertiser_link" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteDisplayVideo360AdvertiserLink", request_serializer=analytics_admin.DeleteDisplayVideo360AdvertiserLinkRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1721,7 +1811,7 @@ def update_display_video360_advertiser_link( if "update_display_video360_advertiser_link" not in self._stubs: self._stubs[ "update_display_video360_advertiser_link" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateDisplayVideo360AdvertiserLink", request_serializer=analytics_admin.UpdateDisplayVideo360AdvertiserLinkRequest.serialize, response_deserializer=resources.DisplayVideo360AdvertiserLink.deserialize, @@ -1754,7 +1844,7 @@ def get_display_video360_advertiser_link_proposal( if "get_display_video360_advertiser_link_proposal" not in self._stubs: self._stubs[ "get_display_video360_advertiser_link_proposal" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetDisplayVideo360AdvertiserLinkProposal", request_serializer=analytics_admin.GetDisplayVideo360AdvertiserLinkProposalRequest.serialize, response_deserializer=resources.DisplayVideo360AdvertiserLinkProposal.deserialize, @@ -1787,7 +1877,7 @@ def list_display_video360_advertiser_link_proposals( if "list_display_video360_advertiser_link_proposals" not in self._stubs: self._stubs[ "list_display_video360_advertiser_link_proposals" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListDisplayVideo360AdvertiserLinkProposals", request_serializer=analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsRequest.serialize, response_deserializer=analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse.deserialize, @@ -1819,7 +1909,7 @@ def create_display_video360_advertiser_link_proposal( if "create_display_video360_advertiser_link_proposal" not in self._stubs: self._stubs[ "create_display_video360_advertiser_link_proposal" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateDisplayVideo360AdvertiserLinkProposal", request_serializer=analytics_admin.CreateDisplayVideo360AdvertiserLinkProposalRequest.serialize, response_deserializer=resources.DisplayVideo360AdvertiserLinkProposal.deserialize, @@ -1852,7 +1942,7 @@ def delete_display_video360_advertiser_link_proposal( if "delete_display_video360_advertiser_link_proposal" not in self._stubs: self._stubs[ "delete_display_video360_advertiser_link_proposal" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteDisplayVideo360AdvertiserLinkProposal", request_serializer=analytics_admin.DeleteDisplayVideo360AdvertiserLinkProposalRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1887,7 +1977,7 @@ def approve_display_video360_advertiser_link_proposal( if "approve_display_video360_advertiser_link_proposal" not in self._stubs: self._stubs[ "approve_display_video360_advertiser_link_proposal" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ApproveDisplayVideo360AdvertiserLinkProposal", request_serializer=analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalRequest.serialize, response_deserializer=analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalResponse.deserialize, @@ -1926,7 +2016,7 @@ def cancel_display_video360_advertiser_link_proposal( if "cancel_display_video360_advertiser_link_proposal" not in self._stubs: self._stubs[ "cancel_display_video360_advertiser_link_proposal" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CancelDisplayVideo360AdvertiserLinkProposal", request_serializer=analytics_admin.CancelDisplayVideo360AdvertiserLinkProposalRequest.serialize, response_deserializer=resources.DisplayVideo360AdvertiserLinkProposal.deserialize, @@ -1954,7 +2044,7 @@ def create_custom_dimension( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_custom_dimension" not in self._stubs: - self._stubs["create_custom_dimension"] = self.grpc_channel.unary_unary( + self._stubs["create_custom_dimension"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateCustomDimension", request_serializer=analytics_admin.CreateCustomDimensionRequest.serialize, response_deserializer=resources.CustomDimension.deserialize, @@ -1982,7 +2072,7 @@ def update_custom_dimension( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_custom_dimension" not in self._stubs: - self._stubs["update_custom_dimension"] = self.grpc_channel.unary_unary( + self._stubs["update_custom_dimension"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateCustomDimension", request_serializer=analytics_admin.UpdateCustomDimensionRequest.serialize, response_deserializer=resources.CustomDimension.deserialize, @@ -2011,7 +2101,7 @@ def list_custom_dimensions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_custom_dimensions" not in self._stubs: - self._stubs["list_custom_dimensions"] = self.grpc_channel.unary_unary( + self._stubs["list_custom_dimensions"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListCustomDimensions", request_serializer=analytics_admin.ListCustomDimensionsRequest.serialize, response_deserializer=analytics_admin.ListCustomDimensionsResponse.deserialize, @@ -2037,7 +2127,7 @@ def archive_custom_dimension( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "archive_custom_dimension" not in self._stubs: - self._stubs["archive_custom_dimension"] = self.grpc_channel.unary_unary( + self._stubs["archive_custom_dimension"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ArchiveCustomDimension", request_serializer=analytics_admin.ArchiveCustomDimensionRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -2065,7 +2155,7 @@ def get_custom_dimension( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_custom_dimension" not in self._stubs: - self._stubs["get_custom_dimension"] = self.grpc_channel.unary_unary( + self._stubs["get_custom_dimension"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetCustomDimension", request_serializer=analytics_admin.GetCustomDimensionRequest.serialize, response_deserializer=resources.CustomDimension.deserialize, @@ -2091,7 +2181,7 @@ def create_custom_metric( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_custom_metric" not in self._stubs: - self._stubs["create_custom_metric"] = self.grpc_channel.unary_unary( + self._stubs["create_custom_metric"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateCustomMetric", request_serializer=analytics_admin.CreateCustomMetricRequest.serialize, response_deserializer=resources.CustomMetric.deserialize, @@ -2117,7 +2207,7 @@ def update_custom_metric( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_custom_metric" not in self._stubs: - self._stubs["update_custom_metric"] = self.grpc_channel.unary_unary( + self._stubs["update_custom_metric"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateCustomMetric", request_serializer=analytics_admin.UpdateCustomMetricRequest.serialize, response_deserializer=resources.CustomMetric.deserialize, @@ -2146,7 +2236,7 @@ def list_custom_metrics( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_custom_metrics" not in self._stubs: - self._stubs["list_custom_metrics"] = self.grpc_channel.unary_unary( + self._stubs["list_custom_metrics"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListCustomMetrics", request_serializer=analytics_admin.ListCustomMetricsRequest.serialize, response_deserializer=analytics_admin.ListCustomMetricsResponse.deserialize, @@ -2172,7 +2262,7 @@ def archive_custom_metric( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "archive_custom_metric" not in self._stubs: - self._stubs["archive_custom_metric"] = self.grpc_channel.unary_unary( + self._stubs["archive_custom_metric"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ArchiveCustomMetric", request_serializer=analytics_admin.ArchiveCustomMetricRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -2198,7 +2288,7 @@ def get_custom_metric( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_custom_metric" not in self._stubs: - self._stubs["get_custom_metric"] = self.grpc_channel.unary_unary( + self._stubs["get_custom_metric"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetCustomMetric", request_serializer=analytics_admin.GetCustomMetricRequest.serialize, response_deserializer=resources.CustomMetric.deserialize, @@ -2228,7 +2318,9 @@ def get_data_retention_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_data_retention_settings" not in self._stubs: - self._stubs["get_data_retention_settings"] = self.grpc_channel.unary_unary( + self._stubs[ + "get_data_retention_settings" + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetDataRetentionSettings", request_serializer=analytics_admin.GetDataRetentionSettingsRequest.serialize, response_deserializer=resources.DataRetentionSettings.deserialize, @@ -2260,7 +2352,7 @@ def update_data_retention_settings( if "update_data_retention_settings" not in self._stubs: self._stubs[ "update_data_retention_settings" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateDataRetentionSettings", request_serializer=analytics_admin.UpdateDataRetentionSettingsRequest.serialize, response_deserializer=resources.DataRetentionSettings.deserialize, @@ -2286,7 +2378,7 @@ def create_data_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_data_stream" not in self._stubs: - self._stubs["create_data_stream"] = self.grpc_channel.unary_unary( + self._stubs["create_data_stream"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateDataStream", request_serializer=analytics_admin.CreateDataStreamRequest.serialize, response_deserializer=resources.DataStream.deserialize, @@ -2312,7 +2404,7 @@ def delete_data_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_data_stream" not in self._stubs: - self._stubs["delete_data_stream"] = self.grpc_channel.unary_unary( + self._stubs["delete_data_stream"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteDataStream", request_serializer=analytics_admin.DeleteDataStreamRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -2338,7 +2430,7 @@ def update_data_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_data_stream" not in self._stubs: - self._stubs["update_data_stream"] = self.grpc_channel.unary_unary( + self._stubs["update_data_stream"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateDataStream", request_serializer=analytics_admin.UpdateDataStreamRequest.serialize, response_deserializer=resources.DataStream.deserialize, @@ -2367,7 +2459,7 @@ def list_data_streams( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_data_streams" not in self._stubs: - self._stubs["list_data_streams"] = self.grpc_channel.unary_unary( + self._stubs["list_data_streams"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListDataStreams", request_serializer=analytics_admin.ListDataStreamsRequest.serialize, response_deserializer=analytics_admin.ListDataStreamsResponse.deserialize, @@ -2393,7 +2485,7 @@ def get_data_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_data_stream" not in self._stubs: - self._stubs["get_data_stream"] = self.grpc_channel.unary_unary( + self._stubs["get_data_stream"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetDataStream", request_serializer=analytics_admin.GetDataStreamRequest.serialize, response_deserializer=resources.DataStream.deserialize, @@ -2421,7 +2513,7 @@ def get_audience( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_audience" not in self._stubs: - self._stubs["get_audience"] = self.grpc_channel.unary_unary( + self._stubs["get_audience"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetAudience", request_serializer=analytics_admin.GetAudienceRequest.serialize, response_deserializer=audience.Audience.deserialize, @@ -2451,7 +2543,7 @@ def list_audiences( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_audiences" not in self._stubs: - self._stubs["list_audiences"] = self.grpc_channel.unary_unary( + self._stubs["list_audiences"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListAudiences", request_serializer=analytics_admin.ListAudiencesRequest.serialize, response_deserializer=analytics_admin.ListAudiencesResponse.deserialize, @@ -2477,7 +2569,7 @@ def create_audience( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_audience" not in self._stubs: - self._stubs["create_audience"] = self.grpc_channel.unary_unary( + self._stubs["create_audience"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateAudience", request_serializer=analytics_admin.CreateAudienceRequest.serialize, response_deserializer=gaa_audience.Audience.deserialize, @@ -2503,7 +2595,7 @@ def update_audience( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_audience" not in self._stubs: - self._stubs["update_audience"] = self.grpc_channel.unary_unary( + self._stubs["update_audience"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateAudience", request_serializer=analytics_admin.UpdateAudienceRequest.serialize, response_deserializer=gaa_audience.Audience.deserialize, @@ -2529,7 +2621,7 @@ def archive_audience( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "archive_audience" not in self._stubs: - self._stubs["archive_audience"] = self.grpc_channel.unary_unary( + self._stubs["archive_audience"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ArchiveAudience", request_serializer=analytics_admin.ArchiveAudienceRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -2557,7 +2649,7 @@ def get_search_ads360_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_search_ads360_link" not in self._stubs: - self._stubs["get_search_ads360_link"] = self.grpc_channel.unary_unary( + self._stubs["get_search_ads360_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetSearchAds360Link", request_serializer=analytics_admin.GetSearchAds360LinkRequest.serialize, response_deserializer=resources.SearchAds360Link.deserialize, @@ -2586,7 +2678,7 @@ def list_search_ads360_links( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_search_ads360_links" not in self._stubs: - self._stubs["list_search_ads360_links"] = self.grpc_channel.unary_unary( + self._stubs["list_search_ads360_links"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListSearchAds360Links", request_serializer=analytics_admin.ListSearchAds360LinksRequest.serialize, response_deserializer=analytics_admin.ListSearchAds360LinksResponse.deserialize, @@ -2614,7 +2706,7 @@ def create_search_ads360_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_search_ads360_link" not in self._stubs: - self._stubs["create_search_ads360_link"] = self.grpc_channel.unary_unary( + self._stubs["create_search_ads360_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateSearchAds360Link", request_serializer=analytics_admin.CreateSearchAds360LinkRequest.serialize, response_deserializer=resources.SearchAds360Link.deserialize, @@ -2640,7 +2732,7 @@ def delete_search_ads360_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_search_ads360_link" not in self._stubs: - self._stubs["delete_search_ads360_link"] = self.grpc_channel.unary_unary( + self._stubs["delete_search_ads360_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteSearchAds360Link", request_serializer=analytics_admin.DeleteSearchAds360LinkRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -2668,7 +2760,7 @@ def update_search_ads360_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_search_ads360_link" not in self._stubs: - self._stubs["update_search_ads360_link"] = self.grpc_channel.unary_unary( + self._stubs["update_search_ads360_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateSearchAds360Link", request_serializer=analytics_admin.UpdateSearchAds360LinkRequest.serialize, response_deserializer=resources.SearchAds360Link.deserialize, @@ -2696,7 +2788,7 @@ def get_attribution_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_attribution_settings" not in self._stubs: - self._stubs["get_attribution_settings"] = self.grpc_channel.unary_unary( + self._stubs["get_attribution_settings"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetAttributionSettings", request_serializer=analytics_admin.GetAttributionSettingsRequest.serialize, response_deserializer=resources.AttributionSettings.deserialize, @@ -2725,7 +2817,9 @@ def update_attribution_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_attribution_settings" not in self._stubs: - self._stubs["update_attribution_settings"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_attribution_settings" + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateAttributionSettings", request_serializer=analytics_admin.UpdateAttributionSettingsRequest.serialize, response_deserializer=resources.AttributionSettings.deserialize, @@ -2769,7 +2863,7 @@ def run_access_report( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "run_access_report" not in self._stubs: - self._stubs["run_access_report"] = self.grpc_channel.unary_unary( + self._stubs["run_access_report"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/RunAccessReport", request_serializer=analytics_admin.RunAccessReportRequest.serialize, response_deserializer=analytics_admin.RunAccessReportResponse.deserialize, @@ -2797,7 +2891,7 @@ def create_access_binding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_access_binding" not in self._stubs: - self._stubs["create_access_binding"] = self.grpc_channel.unary_unary( + self._stubs["create_access_binding"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateAccessBinding", request_serializer=analytics_admin.CreateAccessBindingRequest.serialize, response_deserializer=resources.AccessBinding.deserialize, @@ -2823,7 +2917,7 @@ def get_access_binding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_access_binding" not in self._stubs: - self._stubs["get_access_binding"] = self.grpc_channel.unary_unary( + self._stubs["get_access_binding"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetAccessBinding", request_serializer=analytics_admin.GetAccessBindingRequest.serialize, response_deserializer=resources.AccessBinding.deserialize, @@ -2851,7 +2945,7 @@ def update_access_binding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_access_binding" not in self._stubs: - self._stubs["update_access_binding"] = self.grpc_channel.unary_unary( + self._stubs["update_access_binding"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateAccessBinding", request_serializer=analytics_admin.UpdateAccessBindingRequest.serialize, response_deserializer=resources.AccessBinding.deserialize, @@ -2877,7 +2971,7 @@ def delete_access_binding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_access_binding" not in self._stubs: - self._stubs["delete_access_binding"] = self.grpc_channel.unary_unary( + self._stubs["delete_access_binding"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteAccessBinding", request_serializer=analytics_admin.DeleteAccessBindingRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -2906,7 +3000,7 @@ def list_access_bindings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_access_bindings" not in self._stubs: - self._stubs["list_access_bindings"] = self.grpc_channel.unary_unary( + self._stubs["list_access_bindings"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListAccessBindings", request_serializer=analytics_admin.ListAccessBindingsRequest.serialize, response_deserializer=analytics_admin.ListAccessBindingsResponse.deserialize, @@ -2940,7 +3034,9 @@ def batch_create_access_bindings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_create_access_bindings" not in self._stubs: - self._stubs["batch_create_access_bindings"] = self.grpc_channel.unary_unary( + self._stubs[ + "batch_create_access_bindings" + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/BatchCreateAccessBindings", request_serializer=analytics_admin.BatchCreateAccessBindingsRequest.serialize, response_deserializer=analytics_admin.BatchCreateAccessBindingsResponse.deserialize, @@ -2970,7 +3066,7 @@ def batch_get_access_bindings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_get_access_bindings" not in self._stubs: - self._stubs["batch_get_access_bindings"] = self.grpc_channel.unary_unary( + self._stubs["batch_get_access_bindings"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/BatchGetAccessBindings", request_serializer=analytics_admin.BatchGetAccessBindingsRequest.serialize, response_deserializer=analytics_admin.BatchGetAccessBindingsResponse.deserialize, @@ -3000,7 +3096,9 @@ def batch_update_access_bindings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_update_access_bindings" not in self._stubs: - self._stubs["batch_update_access_bindings"] = self.grpc_channel.unary_unary( + self._stubs[ + "batch_update_access_bindings" + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/BatchUpdateAccessBindings", request_serializer=analytics_admin.BatchUpdateAccessBindingsRequest.serialize, response_deserializer=analytics_admin.BatchUpdateAccessBindingsResponse.deserialize, @@ -3027,7 +3125,9 @@ def batch_delete_access_bindings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_delete_access_bindings" not in self._stubs: - self._stubs["batch_delete_access_bindings"] = self.grpc_channel.unary_unary( + self._stubs[ + "batch_delete_access_bindings" + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/BatchDeleteAccessBindings", request_serializer=analytics_admin.BatchDeleteAccessBindingsRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -3055,7 +3155,7 @@ def get_expanded_data_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_expanded_data_set" not in self._stubs: - self._stubs["get_expanded_data_set"] = self.grpc_channel.unary_unary( + self._stubs["get_expanded_data_set"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetExpandedDataSet", request_serializer=analytics_admin.GetExpandedDataSetRequest.serialize, response_deserializer=expanded_data_set.ExpandedDataSet.deserialize, @@ -3084,7 +3184,7 @@ def list_expanded_data_sets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_expanded_data_sets" not in self._stubs: - self._stubs["list_expanded_data_sets"] = self.grpc_channel.unary_unary( + self._stubs["list_expanded_data_sets"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListExpandedDataSets", request_serializer=analytics_admin.ListExpandedDataSetsRequest.serialize, response_deserializer=analytics_admin.ListExpandedDataSetsResponse.deserialize, @@ -3113,7 +3213,7 @@ def create_expanded_data_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_expanded_data_set" not in self._stubs: - self._stubs["create_expanded_data_set"] = self.grpc_channel.unary_unary( + self._stubs["create_expanded_data_set"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateExpandedDataSet", request_serializer=analytics_admin.CreateExpandedDataSetRequest.serialize, response_deserializer=gaa_expanded_data_set.ExpandedDataSet.deserialize, @@ -3142,7 +3242,7 @@ def update_expanded_data_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_expanded_data_set" not in self._stubs: - self._stubs["update_expanded_data_set"] = self.grpc_channel.unary_unary( + self._stubs["update_expanded_data_set"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateExpandedDataSet", request_serializer=analytics_admin.UpdateExpandedDataSetRequest.serialize, response_deserializer=gaa_expanded_data_set.ExpandedDataSet.deserialize, @@ -3168,7 +3268,7 @@ def delete_expanded_data_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_expanded_data_set" not in self._stubs: - self._stubs["delete_expanded_data_set"] = self.grpc_channel.unary_unary( + self._stubs["delete_expanded_data_set"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteExpandedDataSet", request_serializer=analytics_admin.DeleteExpandedDataSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -3194,7 +3294,7 @@ def get_channel_group( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_channel_group" not in self._stubs: - self._stubs["get_channel_group"] = self.grpc_channel.unary_unary( + self._stubs["get_channel_group"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetChannelGroup", request_serializer=analytics_admin.GetChannelGroupRequest.serialize, response_deserializer=channel_group.ChannelGroup.deserialize, @@ -3223,7 +3323,7 @@ def list_channel_groups( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_channel_groups" not in self._stubs: - self._stubs["list_channel_groups"] = self.grpc_channel.unary_unary( + self._stubs["list_channel_groups"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListChannelGroups", request_serializer=analytics_admin.ListChannelGroupsRequest.serialize, response_deserializer=analytics_admin.ListChannelGroupsResponse.deserialize, @@ -3251,7 +3351,7 @@ def create_channel_group( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_channel_group" not in self._stubs: - self._stubs["create_channel_group"] = self.grpc_channel.unary_unary( + self._stubs["create_channel_group"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateChannelGroup", request_serializer=analytics_admin.CreateChannelGroupRequest.serialize, response_deserializer=gaa_channel_group.ChannelGroup.deserialize, @@ -3279,7 +3379,7 @@ def update_channel_group( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_channel_group" not in self._stubs: - self._stubs["update_channel_group"] = self.grpc_channel.unary_unary( + self._stubs["update_channel_group"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateChannelGroup", request_serializer=analytics_admin.UpdateChannelGroupRequest.serialize, response_deserializer=gaa_channel_group.ChannelGroup.deserialize, @@ -3305,7 +3405,7 @@ def delete_channel_group( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_channel_group" not in self._stubs: - self._stubs["delete_channel_group"] = self.grpc_channel.unary_unary( + self._stubs["delete_channel_group"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteChannelGroup", request_serializer=analytics_admin.DeleteChannelGroupRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -3339,7 +3439,7 @@ def set_automated_ga4_configuration_opt_out( if "set_automated_ga4_configuration_opt_out" not in self._stubs: self._stubs[ "set_automated_ga4_configuration_opt_out" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/SetAutomatedGa4ConfigurationOptOut", request_serializer=analytics_admin.SetAutomatedGa4ConfigurationOptOutRequest.serialize, response_deserializer=analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse.deserialize, @@ -3373,7 +3473,7 @@ def fetch_automated_ga4_configuration_opt_out( if "fetch_automated_ga4_configuration_opt_out" not in self._stubs: self._stubs[ "fetch_automated_ga4_configuration_opt_out" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/FetchAutomatedGa4ConfigurationOptOut", request_serializer=analytics_admin.FetchAutomatedGa4ConfigurationOptOutRequest.serialize, response_deserializer=analytics_admin.FetchAutomatedGa4ConfigurationOptOutResponse.deserialize, @@ -3399,7 +3499,7 @@ def create_big_query_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_big_query_link" not in self._stubs: - self._stubs["create_big_query_link"] = self.grpc_channel.unary_unary( + self._stubs["create_big_query_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateBigQueryLink", request_serializer=analytics_admin.CreateBigQueryLinkRequest.serialize, response_deserializer=resources.BigQueryLink.deserialize, @@ -3425,7 +3525,7 @@ def get_big_query_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_big_query_link" not in self._stubs: - self._stubs["get_big_query_link"] = self.grpc_channel.unary_unary( + self._stubs["get_big_query_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetBigQueryLink", request_serializer=analytics_admin.GetBigQueryLinkRequest.serialize, response_deserializer=resources.BigQueryLink.deserialize, @@ -3454,7 +3554,7 @@ def list_big_query_links( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_big_query_links" not in self._stubs: - self._stubs["list_big_query_links"] = self.grpc_channel.unary_unary( + self._stubs["list_big_query_links"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListBigQueryLinks", request_serializer=analytics_admin.ListBigQueryLinksRequest.serialize, response_deserializer=analytics_admin.ListBigQueryLinksResponse.deserialize, @@ -3480,7 +3580,7 @@ def delete_big_query_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_big_query_link" not in self._stubs: - self._stubs["delete_big_query_link"] = self.grpc_channel.unary_unary( + self._stubs["delete_big_query_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteBigQueryLink", request_serializer=analytics_admin.DeleteBigQueryLinkRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -3506,7 +3606,7 @@ def update_big_query_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_big_query_link" not in self._stubs: - self._stubs["update_big_query_link"] = self.grpc_channel.unary_unary( + self._stubs["update_big_query_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateBigQueryLink", request_serializer=analytics_admin.UpdateBigQueryLinkRequest.serialize, response_deserializer=resources.BigQueryLink.deserialize, @@ -3540,7 +3640,7 @@ def get_enhanced_measurement_settings( if "get_enhanced_measurement_settings" not in self._stubs: self._stubs[ "get_enhanced_measurement_settings" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetEnhancedMeasurementSettings", request_serializer=analytics_admin.GetEnhancedMeasurementSettingsRequest.serialize, response_deserializer=resources.EnhancedMeasurementSettings.deserialize, @@ -3574,7 +3674,7 @@ def update_enhanced_measurement_settings( if "update_enhanced_measurement_settings" not in self._stubs: self._stubs[ "update_enhanced_measurement_settings" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateEnhancedMeasurementSettings", request_serializer=analytics_admin.UpdateEnhancedMeasurementSettingsRequest.serialize, response_deserializer=resources.EnhancedMeasurementSettings.deserialize, @@ -3606,7 +3706,7 @@ def create_connected_site_tag( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_connected_site_tag" not in self._stubs: - self._stubs["create_connected_site_tag"] = self.grpc_channel.unary_unary( + self._stubs["create_connected_site_tag"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateConnectedSiteTag", request_serializer=analytics_admin.CreateConnectedSiteTagRequest.serialize, response_deserializer=analytics_admin.CreateConnectedSiteTagResponse.deserialize, @@ -3634,7 +3734,7 @@ def delete_connected_site_tag( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_connected_site_tag" not in self._stubs: - self._stubs["delete_connected_site_tag"] = self.grpc_channel.unary_unary( + self._stubs["delete_connected_site_tag"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteConnectedSiteTag", request_serializer=analytics_admin.DeleteConnectedSiteTagRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -3666,7 +3766,7 @@ def list_connected_site_tags( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_connected_site_tags" not in self._stubs: - self._stubs["list_connected_site_tags"] = self.grpc_channel.unary_unary( + self._stubs["list_connected_site_tags"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListConnectedSiteTags", request_serializer=analytics_admin.ListConnectedSiteTagsRequest.serialize, response_deserializer=analytics_admin.ListConnectedSiteTagsResponse.deserialize, @@ -3697,7 +3797,9 @@ def fetch_connected_ga4_property( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "fetch_connected_ga4_property" not in self._stubs: - self._stubs["fetch_connected_ga4_property"] = self.grpc_channel.unary_unary( + self._stubs[ + "fetch_connected_ga4_property" + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/FetchConnectedGa4Property", request_serializer=analytics_admin.FetchConnectedGa4PropertyRequest.serialize, response_deserializer=analytics_admin.FetchConnectedGa4PropertyResponse.deserialize, @@ -3723,7 +3825,7 @@ def get_ad_sense_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_ad_sense_link" not in self._stubs: - self._stubs["get_ad_sense_link"] = self.grpc_channel.unary_unary( + self._stubs["get_ad_sense_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetAdSenseLink", request_serializer=analytics_admin.GetAdSenseLinkRequest.serialize, response_deserializer=resources.AdSenseLink.deserialize, @@ -3749,7 +3851,7 @@ def create_ad_sense_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_ad_sense_link" not in self._stubs: - self._stubs["create_ad_sense_link"] = self.grpc_channel.unary_unary( + self._stubs["create_ad_sense_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateAdSenseLink", request_serializer=analytics_admin.CreateAdSenseLinkRequest.serialize, response_deserializer=resources.AdSenseLink.deserialize, @@ -3775,7 +3877,7 @@ def delete_ad_sense_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_ad_sense_link" not in self._stubs: - self._stubs["delete_ad_sense_link"] = self.grpc_channel.unary_unary( + self._stubs["delete_ad_sense_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteAdSenseLink", request_serializer=analytics_admin.DeleteAdSenseLinkRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -3804,7 +3906,7 @@ def list_ad_sense_links( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_ad_sense_links" not in self._stubs: - self._stubs["list_ad_sense_links"] = self.grpc_channel.unary_unary( + self._stubs["list_ad_sense_links"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListAdSenseLinks", request_serializer=analytics_admin.ListAdSenseLinksRequest.serialize, response_deserializer=analytics_admin.ListAdSenseLinksResponse.deserialize, @@ -3833,7 +3935,7 @@ def get_event_create_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_event_create_rule" not in self._stubs: - self._stubs["get_event_create_rule"] = self.grpc_channel.unary_unary( + self._stubs["get_event_create_rule"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetEventCreateRule", request_serializer=analytics_admin.GetEventCreateRuleRequest.serialize, response_deserializer=event_create_and_edit.EventCreateRule.deserialize, @@ -3862,7 +3964,7 @@ def list_event_create_rules( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_event_create_rules" not in self._stubs: - self._stubs["list_event_create_rules"] = self.grpc_channel.unary_unary( + self._stubs["list_event_create_rules"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListEventCreateRules", request_serializer=analytics_admin.ListEventCreateRulesRequest.serialize, response_deserializer=analytics_admin.ListEventCreateRulesResponse.deserialize, @@ -3891,7 +3993,7 @@ def create_event_create_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_event_create_rule" not in self._stubs: - self._stubs["create_event_create_rule"] = self.grpc_channel.unary_unary( + self._stubs["create_event_create_rule"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateEventCreateRule", request_serializer=analytics_admin.CreateEventCreateRuleRequest.serialize, response_deserializer=event_create_and_edit.EventCreateRule.deserialize, @@ -3920,7 +4022,7 @@ def update_event_create_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_event_create_rule" not in self._stubs: - self._stubs["update_event_create_rule"] = self.grpc_channel.unary_unary( + self._stubs["update_event_create_rule"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateEventCreateRule", request_serializer=analytics_admin.UpdateEventCreateRuleRequest.serialize, response_deserializer=event_create_and_edit.EventCreateRule.deserialize, @@ -3946,7 +4048,7 @@ def delete_event_create_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_event_create_rule" not in self._stubs: - self._stubs["delete_event_create_rule"] = self.grpc_channel.unary_unary( + self._stubs["delete_event_create_rule"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteEventCreateRule", request_serializer=analytics_admin.DeleteEventCreateRuleRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -3974,7 +4076,7 @@ def get_event_edit_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_event_edit_rule" not in self._stubs: - self._stubs["get_event_edit_rule"] = self.grpc_channel.unary_unary( + self._stubs["get_event_edit_rule"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetEventEditRule", request_serializer=analytics_admin.GetEventEditRuleRequest.serialize, response_deserializer=event_create_and_edit.EventEditRule.deserialize, @@ -4003,7 +4105,7 @@ def list_event_edit_rules( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_event_edit_rules" not in self._stubs: - self._stubs["list_event_edit_rules"] = self.grpc_channel.unary_unary( + self._stubs["list_event_edit_rules"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListEventEditRules", request_serializer=analytics_admin.ListEventEditRulesRequest.serialize, response_deserializer=analytics_admin.ListEventEditRulesResponse.deserialize, @@ -4032,7 +4134,7 @@ def create_event_edit_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_event_edit_rule" not in self._stubs: - self._stubs["create_event_edit_rule"] = self.grpc_channel.unary_unary( + self._stubs["create_event_edit_rule"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateEventEditRule", request_serializer=analytics_admin.CreateEventEditRuleRequest.serialize, response_deserializer=event_create_and_edit.EventEditRule.deserialize, @@ -4061,7 +4163,7 @@ def update_event_edit_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_event_edit_rule" not in self._stubs: - self._stubs["update_event_edit_rule"] = self.grpc_channel.unary_unary( + self._stubs["update_event_edit_rule"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateEventEditRule", request_serializer=analytics_admin.UpdateEventEditRuleRequest.serialize, response_deserializer=event_create_and_edit.EventEditRule.deserialize, @@ -4087,7 +4189,7 @@ def delete_event_edit_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_event_edit_rule" not in self._stubs: - self._stubs["delete_event_edit_rule"] = self.grpc_channel.unary_unary( + self._stubs["delete_event_edit_rule"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteEventEditRule", request_serializer=analytics_admin.DeleteEventEditRuleRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -4114,7 +4216,7 @@ def reorder_event_edit_rules( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reorder_event_edit_rules" not in self._stubs: - self._stubs["reorder_event_edit_rules"] = self.grpc_channel.unary_unary( + self._stubs["reorder_event_edit_rules"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ReorderEventEditRules", request_serializer=analytics_admin.ReorderEventEditRulesRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -4145,7 +4247,7 @@ def update_data_redaction_settings( if "update_data_redaction_settings" not in self._stubs: self._stubs[ "update_data_redaction_settings" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateDataRedactionSettings", request_serializer=analytics_admin.UpdateDataRedactionSettingsRequest.serialize, response_deserializer=resources.DataRedactionSettings.deserialize, @@ -4174,7 +4276,9 @@ def get_data_redaction_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_data_redaction_settings" not in self._stubs: - self._stubs["get_data_redaction_settings"] = self.grpc_channel.unary_unary( + self._stubs[ + "get_data_redaction_settings" + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetDataRedactionSettings", request_serializer=analytics_admin.GetDataRedactionSettingsRequest.serialize, response_deserializer=resources.DataRedactionSettings.deserialize, @@ -4202,7 +4306,7 @@ def get_calculated_metric( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_calculated_metric" not in self._stubs: - self._stubs["get_calculated_metric"] = self.grpc_channel.unary_unary( + self._stubs["get_calculated_metric"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetCalculatedMetric", request_serializer=analytics_admin.GetCalculatedMetricRequest.serialize, response_deserializer=resources.CalculatedMetric.deserialize, @@ -4230,7 +4334,7 @@ def create_calculated_metric( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_calculated_metric" not in self._stubs: - self._stubs["create_calculated_metric"] = self.grpc_channel.unary_unary( + self._stubs["create_calculated_metric"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateCalculatedMetric", request_serializer=analytics_admin.CreateCalculatedMetricRequest.serialize, response_deserializer=resources.CalculatedMetric.deserialize, @@ -4259,7 +4363,7 @@ def list_calculated_metrics( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_calculated_metrics" not in self._stubs: - self._stubs["list_calculated_metrics"] = self.grpc_channel.unary_unary( + self._stubs["list_calculated_metrics"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListCalculatedMetrics", request_serializer=analytics_admin.ListCalculatedMetricsRequest.serialize, response_deserializer=analytics_admin.ListCalculatedMetricsResponse.deserialize, @@ -4287,7 +4391,7 @@ def update_calculated_metric( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_calculated_metric" not in self._stubs: - self._stubs["update_calculated_metric"] = self.grpc_channel.unary_unary( + self._stubs["update_calculated_metric"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateCalculatedMetric", request_serializer=analytics_admin.UpdateCalculatedMetricRequest.serialize, response_deserializer=resources.CalculatedMetric.deserialize, @@ -4313,7 +4417,7 @@ def delete_calculated_metric( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_calculated_metric" not in self._stubs: - self._stubs["delete_calculated_metric"] = self.grpc_channel.unary_unary( + self._stubs["delete_calculated_metric"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteCalculatedMetric", request_serializer=analytics_admin.DeleteCalculatedMetricRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -4343,7 +4447,7 @@ def create_rollup_property( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_rollup_property" not in self._stubs: - self._stubs["create_rollup_property"] = self.grpc_channel.unary_unary( + self._stubs["create_rollup_property"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateRollupProperty", request_serializer=analytics_admin.CreateRollupPropertyRequest.serialize, response_deserializer=analytics_admin.CreateRollupPropertyResponse.deserialize, @@ -4378,7 +4482,7 @@ def get_rollup_property_source_link( if "get_rollup_property_source_link" not in self._stubs: self._stubs[ "get_rollup_property_source_link" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetRollupPropertySourceLink", request_serializer=analytics_admin.GetRollupPropertySourceLinkRequest.serialize, response_deserializer=resources.RollupPropertySourceLink.deserialize, @@ -4413,7 +4517,7 @@ def list_rollup_property_source_links( if "list_rollup_property_source_links" not in self._stubs: self._stubs[ "list_rollup_property_source_links" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListRollupPropertySourceLinks", request_serializer=analytics_admin.ListRollupPropertySourceLinksRequest.serialize, response_deserializer=analytics_admin.ListRollupPropertySourceLinksResponse.deserialize, @@ -4448,7 +4552,7 @@ def create_rollup_property_source_link( if "create_rollup_property_source_link" not in self._stubs: self._stubs[ "create_rollup_property_source_link" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateRollupPropertySourceLink", request_serializer=analytics_admin.CreateRollupPropertySourceLinkRequest.serialize, response_deserializer=resources.RollupPropertySourceLink.deserialize, @@ -4482,7 +4586,7 @@ def delete_rollup_property_source_link( if "delete_rollup_property_source_link" not in self._stubs: self._stubs[ "delete_rollup_property_source_link" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteRollupPropertySourceLink", request_serializer=analytics_admin.DeleteRollupPropertySourceLinkRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -4512,7 +4616,7 @@ def provision_subproperty( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "provision_subproperty" not in self._stubs: - self._stubs["provision_subproperty"] = self.grpc_channel.unary_unary( + self._stubs["provision_subproperty"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ProvisionSubproperty", request_serializer=analytics_admin.ProvisionSubpropertyRequest.serialize, response_deserializer=analytics_admin.ProvisionSubpropertyResponse.deserialize, @@ -4544,7 +4648,7 @@ def create_subproperty_event_filter( if "create_subproperty_event_filter" not in self._stubs: self._stubs[ "create_subproperty_event_filter" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateSubpropertyEventFilter", request_serializer=analytics_admin.CreateSubpropertyEventFilterRequest.serialize, response_deserializer=gaa_subproperty_event_filter.SubpropertyEventFilter.deserialize, @@ -4573,7 +4677,9 @@ def get_subproperty_event_filter( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_subproperty_event_filter" not in self._stubs: - self._stubs["get_subproperty_event_filter"] = self.grpc_channel.unary_unary( + self._stubs[ + "get_subproperty_event_filter" + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetSubpropertyEventFilter", request_serializer=analytics_admin.GetSubpropertyEventFilterRequest.serialize, response_deserializer=subproperty_event_filter.SubpropertyEventFilter.deserialize, @@ -4604,7 +4710,7 @@ def list_subproperty_event_filters( if "list_subproperty_event_filters" not in self._stubs: self._stubs[ "list_subproperty_event_filters" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListSubpropertyEventFilters", request_serializer=analytics_admin.ListSubpropertyEventFiltersRequest.serialize, response_deserializer=analytics_admin.ListSubpropertyEventFiltersResponse.deserialize, @@ -4636,7 +4742,7 @@ def update_subproperty_event_filter( if "update_subproperty_event_filter" not in self._stubs: self._stubs[ "update_subproperty_event_filter" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateSubpropertyEventFilter", request_serializer=analytics_admin.UpdateSubpropertyEventFilterRequest.serialize, response_deserializer=gaa_subproperty_event_filter.SubpropertyEventFilter.deserialize, @@ -4667,7 +4773,7 @@ def delete_subproperty_event_filter( if "delete_subproperty_event_filter" not in self._stubs: self._stubs[ "delete_subproperty_event_filter" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteSubpropertyEventFilter", request_serializer=analytics_admin.DeleteSubpropertyEventFilterRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -4675,7 +4781,7 @@ def delete_subproperty_event_filter( return self._stubs["delete_subproperty_event_filter"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc_asyncio.py b/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc_asyncio.py index ed482f4e86c3..62fa6cfd1056 100644 --- a/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc_asyncio.py +++ b/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,8 +26,11 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.analytics.admin_v1alpha.types import channel_group as gaa_channel_group from google.analytics.admin_v1alpha.types import ( @@ -45,6 +51,82 @@ from .base import DEFAULT_CLIENT_INFO, AnalyticsAdminServiceTransport from .grpc import AnalyticsAdminServiceGrpcTransport +try: + from google.api_core import client_logging # 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.analytics.admin.v1alpha.AnalyticsAdminService", + "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.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AnalyticsAdminServiceGrpcAsyncIOTransport(AnalyticsAdminServiceTransport): """gRPC AsyncIO backend transport for AnalyticsAdminService. @@ -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 @@ -276,7 +361,7 @@ def get_account( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_account" not in self._stubs: - self._stubs["get_account"] = self.grpc_channel.unary_unary( + self._stubs["get_account"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetAccount", request_serializer=analytics_admin.GetAccountRequest.serialize, response_deserializer=resources.Account.deserialize, @@ -310,7 +395,7 @@ def list_accounts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_accounts" not in self._stubs: - self._stubs["list_accounts"] = self.grpc_channel.unary_unary( + self._stubs["list_accounts"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListAccounts", request_serializer=analytics_admin.ListAccountsRequest.serialize, response_deserializer=analytics_admin.ListAccountsResponse.deserialize, @@ -348,7 +433,7 @@ def delete_account( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_account" not in self._stubs: - self._stubs["delete_account"] = self.grpc_channel.unary_unary( + self._stubs["delete_account"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteAccount", request_serializer=analytics_admin.DeleteAccountRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -374,7 +459,7 @@ def update_account( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_account" not in self._stubs: - self._stubs["update_account"] = self.grpc_channel.unary_unary( + self._stubs["update_account"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateAccount", request_serializer=analytics_admin.UpdateAccountRequest.serialize, response_deserializer=resources.Account.deserialize, @@ -403,7 +488,7 @@ def provision_account_ticket( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "provision_account_ticket" not in self._stubs: - self._stubs["provision_account_ticket"] = self.grpc_channel.unary_unary( + self._stubs["provision_account_ticket"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ProvisionAccountTicket", request_serializer=analytics_admin.ProvisionAccountTicketRequest.serialize, response_deserializer=analytics_admin.ProvisionAccountTicketResponse.deserialize, @@ -433,7 +518,7 @@ def list_account_summaries( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_account_summaries" not in self._stubs: - self._stubs["list_account_summaries"] = self.grpc_channel.unary_unary( + self._stubs["list_account_summaries"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListAccountSummaries", request_serializer=analytics_admin.ListAccountSummariesRequest.serialize, response_deserializer=analytics_admin.ListAccountSummariesResponse.deserialize, @@ -459,7 +544,7 @@ def get_property( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_property" not in self._stubs: - self._stubs["get_property"] = self.grpc_channel.unary_unary( + self._stubs["get_property"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetProperty", request_serializer=analytics_admin.GetPropertyRequest.serialize, response_deserializer=resources.Property.deserialize, @@ -494,7 +579,7 @@ def list_properties( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_properties" not in self._stubs: - self._stubs["list_properties"] = self.grpc_channel.unary_unary( + self._stubs["list_properties"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListProperties", request_serializer=analytics_admin.ListPropertiesRequest.serialize, response_deserializer=analytics_admin.ListPropertiesResponse.deserialize, @@ -523,7 +608,7 @@ def create_property( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_property" not in self._stubs: - self._stubs["create_property"] = self.grpc_channel.unary_unary( + self._stubs["create_property"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateProperty", request_serializer=analytics_admin.CreatePropertyRequest.serialize, response_deserializer=resources.Property.deserialize, @@ -564,7 +649,7 @@ def delete_property( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_property" not in self._stubs: - self._stubs["delete_property"] = self.grpc_channel.unary_unary( + self._stubs["delete_property"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteProperty", request_serializer=analytics_admin.DeletePropertyRequest.serialize, response_deserializer=resources.Property.deserialize, @@ -592,7 +677,7 @@ def update_property( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_property" not in self._stubs: - self._stubs["update_property"] = self.grpc_channel.unary_unary( + self._stubs["update_property"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateProperty", request_serializer=analytics_admin.UpdatePropertyRequest.serialize, response_deserializer=resources.Property.deserialize, @@ -622,7 +707,7 @@ def create_firebase_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_firebase_link" not in self._stubs: - self._stubs["create_firebase_link"] = self.grpc_channel.unary_unary( + self._stubs["create_firebase_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateFirebaseLink", request_serializer=analytics_admin.CreateFirebaseLinkRequest.serialize, response_deserializer=resources.FirebaseLink.deserialize, @@ -650,7 +735,7 @@ def delete_firebase_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_firebase_link" not in self._stubs: - self._stubs["delete_firebase_link"] = self.grpc_channel.unary_unary( + self._stubs["delete_firebase_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteFirebaseLink", request_serializer=analytics_admin.DeleteFirebaseLinkRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -680,7 +765,7 @@ def list_firebase_links( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_firebase_links" not in self._stubs: - self._stubs["list_firebase_links"] = self.grpc_channel.unary_unary( + self._stubs["list_firebase_links"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListFirebaseLinks", request_serializer=analytics_admin.ListFirebaseLinksRequest.serialize, response_deserializer=analytics_admin.ListFirebaseLinksResponse.deserialize, @@ -709,7 +794,7 @@ def get_global_site_tag( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_global_site_tag" not in self._stubs: - self._stubs["get_global_site_tag"] = self.grpc_channel.unary_unary( + self._stubs["get_global_site_tag"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetGlobalSiteTag", request_serializer=analytics_admin.GetGlobalSiteTagRequest.serialize, response_deserializer=resources.GlobalSiteTag.deserialize, @@ -737,7 +822,7 @@ def create_google_ads_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_google_ads_link" not in self._stubs: - self._stubs["create_google_ads_link"] = self.grpc_channel.unary_unary( + self._stubs["create_google_ads_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateGoogleAdsLink", request_serializer=analytics_admin.CreateGoogleAdsLinkRequest.serialize, response_deserializer=resources.GoogleAdsLink.deserialize, @@ -765,7 +850,7 @@ def update_google_ads_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_google_ads_link" not in self._stubs: - self._stubs["update_google_ads_link"] = self.grpc_channel.unary_unary( + self._stubs["update_google_ads_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateGoogleAdsLink", request_serializer=analytics_admin.UpdateGoogleAdsLinkRequest.serialize, response_deserializer=resources.GoogleAdsLink.deserialize, @@ -793,7 +878,7 @@ def delete_google_ads_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_google_ads_link" not in self._stubs: - self._stubs["delete_google_ads_link"] = self.grpc_channel.unary_unary( + self._stubs["delete_google_ads_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteGoogleAdsLink", request_serializer=analytics_admin.DeleteGoogleAdsLinkRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -822,7 +907,7 @@ def list_google_ads_links( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_google_ads_links" not in self._stubs: - self._stubs["list_google_ads_links"] = self.grpc_channel.unary_unary( + self._stubs["list_google_ads_links"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListGoogleAdsLinks", request_serializer=analytics_admin.ListGoogleAdsLinksRequest.serialize, response_deserializer=analytics_admin.ListGoogleAdsLinksResponse.deserialize, @@ -852,7 +937,7 @@ def get_data_sharing_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_data_sharing_settings" not in self._stubs: - self._stubs["get_data_sharing_settings"] = self.grpc_channel.unary_unary( + self._stubs["get_data_sharing_settings"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetDataSharingSettings", request_serializer=analytics_admin.GetDataSharingSettingsRequest.serialize, response_deserializer=resources.DataSharingSettings.deserialize, @@ -884,7 +969,7 @@ def get_measurement_protocol_secret( if "get_measurement_protocol_secret" not in self._stubs: self._stubs[ "get_measurement_protocol_secret" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetMeasurementProtocolSecret", request_serializer=analytics_admin.GetMeasurementProtocolSecretRequest.serialize, response_deserializer=resources.MeasurementProtocolSecret.deserialize, @@ -917,7 +1002,7 @@ def list_measurement_protocol_secrets( if "list_measurement_protocol_secrets" not in self._stubs: self._stubs[ "list_measurement_protocol_secrets" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListMeasurementProtocolSecrets", request_serializer=analytics_admin.ListMeasurementProtocolSecretsRequest.serialize, response_deserializer=analytics_admin.ListMeasurementProtocolSecretsResponse.deserialize, @@ -949,7 +1034,7 @@ def create_measurement_protocol_secret( if "create_measurement_protocol_secret" not in self._stubs: self._stubs[ "create_measurement_protocol_secret" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateMeasurementProtocolSecret", request_serializer=analytics_admin.CreateMeasurementProtocolSecretRequest.serialize, response_deserializer=resources.MeasurementProtocolSecret.deserialize, @@ -981,7 +1066,7 @@ def delete_measurement_protocol_secret( if "delete_measurement_protocol_secret" not in self._stubs: self._stubs[ "delete_measurement_protocol_secret" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteMeasurementProtocolSecret", request_serializer=analytics_admin.DeleteMeasurementProtocolSecretRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1013,7 +1098,7 @@ def update_measurement_protocol_secret( if "update_measurement_protocol_secret" not in self._stubs: self._stubs[ "update_measurement_protocol_secret" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateMeasurementProtocolSecret", request_serializer=analytics_admin.UpdateMeasurementProtocolSecretRequest.serialize, response_deserializer=resources.MeasurementProtocolSecret.deserialize, @@ -1049,7 +1134,7 @@ def acknowledge_user_data_collection( if "acknowledge_user_data_collection" not in self._stubs: self._stubs[ "acknowledge_user_data_collection" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/AcknowledgeUserDataCollection", request_serializer=analytics_admin.AcknowledgeUserDataCollectionRequest.serialize, response_deserializer=analytics_admin.AcknowledgeUserDataCollectionResponse.deserialize, @@ -1081,7 +1166,7 @@ def get_sk_ad_network_conversion_value_schema( if "get_sk_ad_network_conversion_value_schema" not in self._stubs: self._stubs[ "get_sk_ad_network_conversion_value_schema" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetSKAdNetworkConversionValueSchema", request_serializer=analytics_admin.GetSKAdNetworkConversionValueSchemaRequest.serialize, response_deserializer=resources.SKAdNetworkConversionValueSchema.deserialize, @@ -1113,7 +1198,7 @@ def create_sk_ad_network_conversion_value_schema( if "create_sk_ad_network_conversion_value_schema" not in self._stubs: self._stubs[ "create_sk_ad_network_conversion_value_schema" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateSKAdNetworkConversionValueSchema", request_serializer=analytics_admin.CreateSKAdNetworkConversionValueSchemaRequest.serialize, response_deserializer=resources.SKAdNetworkConversionValueSchema.deserialize, @@ -1145,7 +1230,7 @@ def delete_sk_ad_network_conversion_value_schema( if "delete_sk_ad_network_conversion_value_schema" not in self._stubs: self._stubs[ "delete_sk_ad_network_conversion_value_schema" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteSKAdNetworkConversionValueSchema", request_serializer=analytics_admin.DeleteSKAdNetworkConversionValueSchemaRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1177,7 +1262,7 @@ def update_sk_ad_network_conversion_value_schema( if "update_sk_ad_network_conversion_value_schema" not in self._stubs: self._stubs[ "update_sk_ad_network_conversion_value_schema" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateSKAdNetworkConversionValueSchema", request_serializer=analytics_admin.UpdateSKAdNetworkConversionValueSchemaRequest.serialize, response_deserializer=resources.SKAdNetworkConversionValueSchema.deserialize, @@ -1211,7 +1296,7 @@ def list_sk_ad_network_conversion_value_schemas( if "list_sk_ad_network_conversion_value_schemas" not in self._stubs: self._stubs[ "list_sk_ad_network_conversion_value_schemas" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListSKAdNetworkConversionValueSchemas", request_serializer=analytics_admin.ListSKAdNetworkConversionValueSchemasRequest.serialize, response_deserializer=analytics_admin.ListSKAdNetworkConversionValueSchemasResponse.deserialize, @@ -1241,7 +1326,9 @@ def search_change_history_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_change_history_events" not in self._stubs: - self._stubs["search_change_history_events"] = self.grpc_channel.unary_unary( + self._stubs[ + "search_change_history_events" + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/SearchChangeHistoryEvents", request_serializer=analytics_admin.SearchChangeHistoryEventsRequest.serialize, response_deserializer=analytics_admin.SearchChangeHistoryEventsResponse.deserialize, @@ -1270,7 +1357,9 @@ def get_google_signals_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_google_signals_settings" not in self._stubs: - self._stubs["get_google_signals_settings"] = self.grpc_channel.unary_unary( + self._stubs[ + "get_google_signals_settings" + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetGoogleSignalsSettings", request_serializer=analytics_admin.GetGoogleSignalsSettingsRequest.serialize, response_deserializer=resources.GoogleSignalsSettings.deserialize, @@ -1301,7 +1390,7 @@ def update_google_signals_settings( if "update_google_signals_settings" not in self._stubs: self._stubs[ "update_google_signals_settings" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateGoogleSignalsSettings", request_serializer=analytics_admin.UpdateGoogleSignalsSettingsRequest.serialize, response_deserializer=resources.GoogleSignalsSettings.deserialize, @@ -1331,7 +1420,7 @@ def create_conversion_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_conversion_event" not in self._stubs: - self._stubs["create_conversion_event"] = self.grpc_channel.unary_unary( + self._stubs["create_conversion_event"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateConversionEvent", request_serializer=analytics_admin.CreateConversionEventRequest.serialize, response_deserializer=resources.ConversionEvent.deserialize, @@ -1361,7 +1450,7 @@ def update_conversion_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_conversion_event" not in self._stubs: - self._stubs["update_conversion_event"] = self.grpc_channel.unary_unary( + self._stubs["update_conversion_event"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateConversionEvent", request_serializer=analytics_admin.UpdateConversionEventRequest.serialize, response_deserializer=resources.ConversionEvent.deserialize, @@ -1391,7 +1480,7 @@ def get_conversion_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_conversion_event" not in self._stubs: - self._stubs["get_conversion_event"] = self.grpc_channel.unary_unary( + self._stubs["get_conversion_event"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetConversionEvent", request_serializer=analytics_admin.GetConversionEventRequest.serialize, response_deserializer=resources.ConversionEvent.deserialize, @@ -1420,7 +1509,7 @@ def delete_conversion_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_conversion_event" not in self._stubs: - self._stubs["delete_conversion_event"] = self.grpc_channel.unary_unary( + self._stubs["delete_conversion_event"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteConversionEvent", request_serializer=analytics_admin.DeleteConversionEventRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1452,7 +1541,7 @@ def list_conversion_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_conversion_events" not in self._stubs: - self._stubs["list_conversion_events"] = self.grpc_channel.unary_unary( + self._stubs["list_conversion_events"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListConversionEvents", request_serializer=analytics_admin.ListConversionEventsRequest.serialize, response_deserializer=analytics_admin.ListConversionEventsResponse.deserialize, @@ -1480,7 +1569,7 @@ def create_key_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_key_event" not in self._stubs: - self._stubs["create_key_event"] = self.grpc_channel.unary_unary( + self._stubs["create_key_event"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateKeyEvent", request_serializer=analytics_admin.CreateKeyEventRequest.serialize, response_deserializer=resources.KeyEvent.deserialize, @@ -1508,7 +1597,7 @@ def update_key_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_key_event" not in self._stubs: - self._stubs["update_key_event"] = self.grpc_channel.unary_unary( + self._stubs["update_key_event"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateKeyEvent", request_serializer=analytics_admin.UpdateKeyEventRequest.serialize, response_deserializer=resources.KeyEvent.deserialize, @@ -1534,7 +1623,7 @@ def get_key_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_key_event" not in self._stubs: - self._stubs["get_key_event"] = self.grpc_channel.unary_unary( + self._stubs["get_key_event"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetKeyEvent", request_serializer=analytics_admin.GetKeyEventRequest.serialize, response_deserializer=resources.KeyEvent.deserialize, @@ -1560,7 +1649,7 @@ def delete_key_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_key_event" not in self._stubs: - self._stubs["delete_key_event"] = self.grpc_channel.unary_unary( + self._stubs["delete_key_event"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteKeyEvent", request_serializer=analytics_admin.DeleteKeyEventRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1591,7 +1680,7 @@ def list_key_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_key_events" not in self._stubs: - self._stubs["list_key_events"] = self.grpc_channel.unary_unary( + self._stubs["list_key_events"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListKeyEvents", request_serializer=analytics_admin.ListKeyEventsRequest.serialize, response_deserializer=analytics_admin.ListKeyEventsResponse.deserialize, @@ -1623,7 +1712,7 @@ def get_display_video360_advertiser_link( if "get_display_video360_advertiser_link" not in self._stubs: self._stubs[ "get_display_video360_advertiser_link" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetDisplayVideo360AdvertiserLink", request_serializer=analytics_admin.GetDisplayVideo360AdvertiserLinkRequest.serialize, response_deserializer=resources.DisplayVideo360AdvertiserLink.deserialize, @@ -1656,7 +1745,7 @@ def list_display_video360_advertiser_links( if "list_display_video360_advertiser_links" not in self._stubs: self._stubs[ "list_display_video360_advertiser_links" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListDisplayVideo360AdvertiserLinks", request_serializer=analytics_admin.ListDisplayVideo360AdvertiserLinksRequest.serialize, response_deserializer=analytics_admin.ListDisplayVideo360AdvertiserLinksResponse.deserialize, @@ -1693,7 +1782,7 @@ def create_display_video360_advertiser_link( if "create_display_video360_advertiser_link" not in self._stubs: self._stubs[ "create_display_video360_advertiser_link" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateDisplayVideo360AdvertiserLink", request_serializer=analytics_admin.CreateDisplayVideo360AdvertiserLinkRequest.serialize, response_deserializer=resources.DisplayVideo360AdvertiserLink.deserialize, @@ -1726,7 +1815,7 @@ def delete_display_video360_advertiser_link( if "delete_display_video360_advertiser_link" not in self._stubs: self._stubs[ "delete_display_video360_advertiser_link" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteDisplayVideo360AdvertiserLink", request_serializer=analytics_admin.DeleteDisplayVideo360AdvertiserLinkRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1759,7 +1848,7 @@ def update_display_video360_advertiser_link( if "update_display_video360_advertiser_link" not in self._stubs: self._stubs[ "update_display_video360_advertiser_link" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateDisplayVideo360AdvertiserLink", request_serializer=analytics_admin.UpdateDisplayVideo360AdvertiserLinkRequest.serialize, response_deserializer=resources.DisplayVideo360AdvertiserLink.deserialize, @@ -1792,7 +1881,7 @@ def get_display_video360_advertiser_link_proposal( if "get_display_video360_advertiser_link_proposal" not in self._stubs: self._stubs[ "get_display_video360_advertiser_link_proposal" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetDisplayVideo360AdvertiserLinkProposal", request_serializer=analytics_admin.GetDisplayVideo360AdvertiserLinkProposalRequest.serialize, response_deserializer=resources.DisplayVideo360AdvertiserLinkProposal.deserialize, @@ -1825,7 +1914,7 @@ def list_display_video360_advertiser_link_proposals( if "list_display_video360_advertiser_link_proposals" not in self._stubs: self._stubs[ "list_display_video360_advertiser_link_proposals" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListDisplayVideo360AdvertiserLinkProposals", request_serializer=analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsRequest.serialize, response_deserializer=analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse.deserialize, @@ -1857,7 +1946,7 @@ def create_display_video360_advertiser_link_proposal( if "create_display_video360_advertiser_link_proposal" not in self._stubs: self._stubs[ "create_display_video360_advertiser_link_proposal" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateDisplayVideo360AdvertiserLinkProposal", request_serializer=analytics_admin.CreateDisplayVideo360AdvertiserLinkProposalRequest.serialize, response_deserializer=resources.DisplayVideo360AdvertiserLinkProposal.deserialize, @@ -1890,7 +1979,7 @@ def delete_display_video360_advertiser_link_proposal( if "delete_display_video360_advertiser_link_proposal" not in self._stubs: self._stubs[ "delete_display_video360_advertiser_link_proposal" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteDisplayVideo360AdvertiserLinkProposal", request_serializer=analytics_admin.DeleteDisplayVideo360AdvertiserLinkProposalRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1925,7 +2014,7 @@ def approve_display_video360_advertiser_link_proposal( if "approve_display_video360_advertiser_link_proposal" not in self._stubs: self._stubs[ "approve_display_video360_advertiser_link_proposal" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ApproveDisplayVideo360AdvertiserLinkProposal", request_serializer=analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalRequest.serialize, response_deserializer=analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalResponse.deserialize, @@ -1964,7 +2053,7 @@ def cancel_display_video360_advertiser_link_proposal( if "cancel_display_video360_advertiser_link_proposal" not in self._stubs: self._stubs[ "cancel_display_video360_advertiser_link_proposal" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CancelDisplayVideo360AdvertiserLinkProposal", request_serializer=analytics_admin.CancelDisplayVideo360AdvertiserLinkProposalRequest.serialize, response_deserializer=resources.DisplayVideo360AdvertiserLinkProposal.deserialize, @@ -1993,7 +2082,7 @@ def create_custom_dimension( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_custom_dimension" not in self._stubs: - self._stubs["create_custom_dimension"] = self.grpc_channel.unary_unary( + self._stubs["create_custom_dimension"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateCustomDimension", request_serializer=analytics_admin.CreateCustomDimensionRequest.serialize, response_deserializer=resources.CustomDimension.deserialize, @@ -2022,7 +2111,7 @@ def update_custom_dimension( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_custom_dimension" not in self._stubs: - self._stubs["update_custom_dimension"] = self.grpc_channel.unary_unary( + self._stubs["update_custom_dimension"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateCustomDimension", request_serializer=analytics_admin.UpdateCustomDimensionRequest.serialize, response_deserializer=resources.CustomDimension.deserialize, @@ -2051,7 +2140,7 @@ def list_custom_dimensions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_custom_dimensions" not in self._stubs: - self._stubs["list_custom_dimensions"] = self.grpc_channel.unary_unary( + self._stubs["list_custom_dimensions"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListCustomDimensions", request_serializer=analytics_admin.ListCustomDimensionsRequest.serialize, response_deserializer=analytics_admin.ListCustomDimensionsResponse.deserialize, @@ -2079,7 +2168,7 @@ def archive_custom_dimension( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "archive_custom_dimension" not in self._stubs: - self._stubs["archive_custom_dimension"] = self.grpc_channel.unary_unary( + self._stubs["archive_custom_dimension"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ArchiveCustomDimension", request_serializer=analytics_admin.ArchiveCustomDimensionRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -2108,7 +2197,7 @@ def get_custom_dimension( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_custom_dimension" not in self._stubs: - self._stubs["get_custom_dimension"] = self.grpc_channel.unary_unary( + self._stubs["get_custom_dimension"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetCustomDimension", request_serializer=analytics_admin.GetCustomDimensionRequest.serialize, response_deserializer=resources.CustomDimension.deserialize, @@ -2136,7 +2225,7 @@ def create_custom_metric( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_custom_metric" not in self._stubs: - self._stubs["create_custom_metric"] = self.grpc_channel.unary_unary( + self._stubs["create_custom_metric"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateCustomMetric", request_serializer=analytics_admin.CreateCustomMetricRequest.serialize, response_deserializer=resources.CustomMetric.deserialize, @@ -2164,7 +2253,7 @@ def update_custom_metric( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_custom_metric" not in self._stubs: - self._stubs["update_custom_metric"] = self.grpc_channel.unary_unary( + self._stubs["update_custom_metric"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateCustomMetric", request_serializer=analytics_admin.UpdateCustomMetricRequest.serialize, response_deserializer=resources.CustomMetric.deserialize, @@ -2193,7 +2282,7 @@ def list_custom_metrics( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_custom_metrics" not in self._stubs: - self._stubs["list_custom_metrics"] = self.grpc_channel.unary_unary( + self._stubs["list_custom_metrics"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListCustomMetrics", request_serializer=analytics_admin.ListCustomMetricsRequest.serialize, response_deserializer=analytics_admin.ListCustomMetricsResponse.deserialize, @@ -2221,7 +2310,7 @@ def archive_custom_metric( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "archive_custom_metric" not in self._stubs: - self._stubs["archive_custom_metric"] = self.grpc_channel.unary_unary( + self._stubs["archive_custom_metric"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ArchiveCustomMetric", request_serializer=analytics_admin.ArchiveCustomMetricRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -2249,7 +2338,7 @@ def get_custom_metric( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_custom_metric" not in self._stubs: - self._stubs["get_custom_metric"] = self.grpc_channel.unary_unary( + self._stubs["get_custom_metric"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetCustomMetric", request_serializer=analytics_admin.GetCustomMetricRequest.serialize, response_deserializer=resources.CustomMetric.deserialize, @@ -2279,7 +2368,9 @@ def get_data_retention_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_data_retention_settings" not in self._stubs: - self._stubs["get_data_retention_settings"] = self.grpc_channel.unary_unary( + self._stubs[ + "get_data_retention_settings" + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetDataRetentionSettings", request_serializer=analytics_admin.GetDataRetentionSettingsRequest.serialize, response_deserializer=resources.DataRetentionSettings.deserialize, @@ -2311,7 +2402,7 @@ def update_data_retention_settings( if "update_data_retention_settings" not in self._stubs: self._stubs[ "update_data_retention_settings" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateDataRetentionSettings", request_serializer=analytics_admin.UpdateDataRetentionSettingsRequest.serialize, response_deserializer=resources.DataRetentionSettings.deserialize, @@ -2339,7 +2430,7 @@ def create_data_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_data_stream" not in self._stubs: - self._stubs["create_data_stream"] = self.grpc_channel.unary_unary( + self._stubs["create_data_stream"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateDataStream", request_serializer=analytics_admin.CreateDataStreamRequest.serialize, response_deserializer=resources.DataStream.deserialize, @@ -2367,7 +2458,7 @@ def delete_data_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_data_stream" not in self._stubs: - self._stubs["delete_data_stream"] = self.grpc_channel.unary_unary( + self._stubs["delete_data_stream"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteDataStream", request_serializer=analytics_admin.DeleteDataStreamRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -2395,7 +2486,7 @@ def update_data_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_data_stream" not in self._stubs: - self._stubs["update_data_stream"] = self.grpc_channel.unary_unary( + self._stubs["update_data_stream"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateDataStream", request_serializer=analytics_admin.UpdateDataStreamRequest.serialize, response_deserializer=resources.DataStream.deserialize, @@ -2424,7 +2515,7 @@ def list_data_streams( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_data_streams" not in self._stubs: - self._stubs["list_data_streams"] = self.grpc_channel.unary_unary( + self._stubs["list_data_streams"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListDataStreams", request_serializer=analytics_admin.ListDataStreamsRequest.serialize, response_deserializer=analytics_admin.ListDataStreamsResponse.deserialize, @@ -2452,7 +2543,7 @@ def get_data_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_data_stream" not in self._stubs: - self._stubs["get_data_stream"] = self.grpc_channel.unary_unary( + self._stubs["get_data_stream"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetDataStream", request_serializer=analytics_admin.GetDataStreamRequest.serialize, response_deserializer=resources.DataStream.deserialize, @@ -2480,7 +2571,7 @@ def get_audience( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_audience" not in self._stubs: - self._stubs["get_audience"] = self.grpc_channel.unary_unary( + self._stubs["get_audience"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetAudience", request_serializer=analytics_admin.GetAudienceRequest.serialize, response_deserializer=audience.Audience.deserialize, @@ -2511,7 +2602,7 @@ def list_audiences( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_audiences" not in self._stubs: - self._stubs["list_audiences"] = self.grpc_channel.unary_unary( + self._stubs["list_audiences"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListAudiences", request_serializer=analytics_admin.ListAudiencesRequest.serialize, response_deserializer=analytics_admin.ListAudiencesResponse.deserialize, @@ -2539,7 +2630,7 @@ def create_audience( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_audience" not in self._stubs: - self._stubs["create_audience"] = self.grpc_channel.unary_unary( + self._stubs["create_audience"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateAudience", request_serializer=analytics_admin.CreateAudienceRequest.serialize, response_deserializer=gaa_audience.Audience.deserialize, @@ -2567,7 +2658,7 @@ def update_audience( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_audience" not in self._stubs: - self._stubs["update_audience"] = self.grpc_channel.unary_unary( + self._stubs["update_audience"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateAudience", request_serializer=analytics_admin.UpdateAudienceRequest.serialize, response_deserializer=gaa_audience.Audience.deserialize, @@ -2593,7 +2684,7 @@ def archive_audience( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "archive_audience" not in self._stubs: - self._stubs["archive_audience"] = self.grpc_channel.unary_unary( + self._stubs["archive_audience"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ArchiveAudience", request_serializer=analytics_admin.ArchiveAudienceRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -2622,7 +2713,7 @@ def get_search_ads360_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_search_ads360_link" not in self._stubs: - self._stubs["get_search_ads360_link"] = self.grpc_channel.unary_unary( + self._stubs["get_search_ads360_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetSearchAds360Link", request_serializer=analytics_admin.GetSearchAds360LinkRequest.serialize, response_deserializer=resources.SearchAds360Link.deserialize, @@ -2651,7 +2742,7 @@ def list_search_ads360_links( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_search_ads360_links" not in self._stubs: - self._stubs["list_search_ads360_links"] = self.grpc_channel.unary_unary( + self._stubs["list_search_ads360_links"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListSearchAds360Links", request_serializer=analytics_admin.ListSearchAds360LinksRequest.serialize, response_deserializer=analytics_admin.ListSearchAds360LinksResponse.deserialize, @@ -2680,7 +2771,7 @@ def create_search_ads360_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_search_ads360_link" not in self._stubs: - self._stubs["create_search_ads360_link"] = self.grpc_channel.unary_unary( + self._stubs["create_search_ads360_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateSearchAds360Link", request_serializer=analytics_admin.CreateSearchAds360LinkRequest.serialize, response_deserializer=resources.SearchAds360Link.deserialize, @@ -2708,7 +2799,7 @@ def delete_search_ads360_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_search_ads360_link" not in self._stubs: - self._stubs["delete_search_ads360_link"] = self.grpc_channel.unary_unary( + self._stubs["delete_search_ads360_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteSearchAds360Link", request_serializer=analytics_admin.DeleteSearchAds360LinkRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -2737,7 +2828,7 @@ def update_search_ads360_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_search_ads360_link" not in self._stubs: - self._stubs["update_search_ads360_link"] = self.grpc_channel.unary_unary( + self._stubs["update_search_ads360_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateSearchAds360Link", request_serializer=analytics_admin.UpdateSearchAds360LinkRequest.serialize, response_deserializer=resources.SearchAds360Link.deserialize, @@ -2766,7 +2857,7 @@ def get_attribution_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_attribution_settings" not in self._stubs: - self._stubs["get_attribution_settings"] = self.grpc_channel.unary_unary( + self._stubs["get_attribution_settings"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetAttributionSettings", request_serializer=analytics_admin.GetAttributionSettingsRequest.serialize, response_deserializer=resources.AttributionSettings.deserialize, @@ -2795,7 +2886,9 @@ def update_attribution_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_attribution_settings" not in self._stubs: - self._stubs["update_attribution_settings"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_attribution_settings" + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateAttributionSettings", request_serializer=analytics_admin.UpdateAttributionSettingsRequest.serialize, response_deserializer=resources.AttributionSettings.deserialize, @@ -2839,7 +2932,7 @@ def run_access_report( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "run_access_report" not in self._stubs: - self._stubs["run_access_report"] = self.grpc_channel.unary_unary( + self._stubs["run_access_report"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/RunAccessReport", request_serializer=analytics_admin.RunAccessReportRequest.serialize, response_deserializer=analytics_admin.RunAccessReportResponse.deserialize, @@ -2867,7 +2960,7 @@ def create_access_binding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_access_binding" not in self._stubs: - self._stubs["create_access_binding"] = self.grpc_channel.unary_unary( + self._stubs["create_access_binding"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateAccessBinding", request_serializer=analytics_admin.CreateAccessBindingRequest.serialize, response_deserializer=resources.AccessBinding.deserialize, @@ -2895,7 +2988,7 @@ def get_access_binding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_access_binding" not in self._stubs: - self._stubs["get_access_binding"] = self.grpc_channel.unary_unary( + self._stubs["get_access_binding"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetAccessBinding", request_serializer=analytics_admin.GetAccessBindingRequest.serialize, response_deserializer=resources.AccessBinding.deserialize, @@ -2923,7 +3016,7 @@ def update_access_binding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_access_binding" not in self._stubs: - self._stubs["update_access_binding"] = self.grpc_channel.unary_unary( + self._stubs["update_access_binding"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateAccessBinding", request_serializer=analytics_admin.UpdateAccessBindingRequest.serialize, response_deserializer=resources.AccessBinding.deserialize, @@ -2951,7 +3044,7 @@ def delete_access_binding( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_access_binding" not in self._stubs: - self._stubs["delete_access_binding"] = self.grpc_channel.unary_unary( + self._stubs["delete_access_binding"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteAccessBinding", request_serializer=analytics_admin.DeleteAccessBindingRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -2980,7 +3073,7 @@ def list_access_bindings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_access_bindings" not in self._stubs: - self._stubs["list_access_bindings"] = self.grpc_channel.unary_unary( + self._stubs["list_access_bindings"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListAccessBindings", request_serializer=analytics_admin.ListAccessBindingsRequest.serialize, response_deserializer=analytics_admin.ListAccessBindingsResponse.deserialize, @@ -3014,7 +3107,9 @@ def batch_create_access_bindings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_create_access_bindings" not in self._stubs: - self._stubs["batch_create_access_bindings"] = self.grpc_channel.unary_unary( + self._stubs[ + "batch_create_access_bindings" + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/BatchCreateAccessBindings", request_serializer=analytics_admin.BatchCreateAccessBindingsRequest.serialize, response_deserializer=analytics_admin.BatchCreateAccessBindingsResponse.deserialize, @@ -3044,7 +3139,7 @@ def batch_get_access_bindings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_get_access_bindings" not in self._stubs: - self._stubs["batch_get_access_bindings"] = self.grpc_channel.unary_unary( + self._stubs["batch_get_access_bindings"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/BatchGetAccessBindings", request_serializer=analytics_admin.BatchGetAccessBindingsRequest.serialize, response_deserializer=analytics_admin.BatchGetAccessBindingsResponse.deserialize, @@ -3074,7 +3169,9 @@ def batch_update_access_bindings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_update_access_bindings" not in self._stubs: - self._stubs["batch_update_access_bindings"] = self.grpc_channel.unary_unary( + self._stubs[ + "batch_update_access_bindings" + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/BatchUpdateAccessBindings", request_serializer=analytics_admin.BatchUpdateAccessBindingsRequest.serialize, response_deserializer=analytics_admin.BatchUpdateAccessBindingsResponse.deserialize, @@ -3103,7 +3200,9 @@ def batch_delete_access_bindings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_delete_access_bindings" not in self._stubs: - self._stubs["batch_delete_access_bindings"] = self.grpc_channel.unary_unary( + self._stubs[ + "batch_delete_access_bindings" + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/BatchDeleteAccessBindings", request_serializer=analytics_admin.BatchDeleteAccessBindingsRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -3132,7 +3231,7 @@ def get_expanded_data_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_expanded_data_set" not in self._stubs: - self._stubs["get_expanded_data_set"] = self.grpc_channel.unary_unary( + self._stubs["get_expanded_data_set"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetExpandedDataSet", request_serializer=analytics_admin.GetExpandedDataSetRequest.serialize, response_deserializer=expanded_data_set.ExpandedDataSet.deserialize, @@ -3161,7 +3260,7 @@ def list_expanded_data_sets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_expanded_data_sets" not in self._stubs: - self._stubs["list_expanded_data_sets"] = self.grpc_channel.unary_unary( + self._stubs["list_expanded_data_sets"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListExpandedDataSets", request_serializer=analytics_admin.ListExpandedDataSetsRequest.serialize, response_deserializer=analytics_admin.ListExpandedDataSetsResponse.deserialize, @@ -3190,7 +3289,7 @@ def create_expanded_data_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_expanded_data_set" not in self._stubs: - self._stubs["create_expanded_data_set"] = self.grpc_channel.unary_unary( + self._stubs["create_expanded_data_set"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateExpandedDataSet", request_serializer=analytics_admin.CreateExpandedDataSetRequest.serialize, response_deserializer=gaa_expanded_data_set.ExpandedDataSet.deserialize, @@ -3219,7 +3318,7 @@ def update_expanded_data_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_expanded_data_set" not in self._stubs: - self._stubs["update_expanded_data_set"] = self.grpc_channel.unary_unary( + self._stubs["update_expanded_data_set"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateExpandedDataSet", request_serializer=analytics_admin.UpdateExpandedDataSetRequest.serialize, response_deserializer=gaa_expanded_data_set.ExpandedDataSet.deserialize, @@ -3247,7 +3346,7 @@ def delete_expanded_data_set( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_expanded_data_set" not in self._stubs: - self._stubs["delete_expanded_data_set"] = self.grpc_channel.unary_unary( + self._stubs["delete_expanded_data_set"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteExpandedDataSet", request_serializer=analytics_admin.DeleteExpandedDataSetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -3275,7 +3374,7 @@ def get_channel_group( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_channel_group" not in self._stubs: - self._stubs["get_channel_group"] = self.grpc_channel.unary_unary( + self._stubs["get_channel_group"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetChannelGroup", request_serializer=analytics_admin.GetChannelGroupRequest.serialize, response_deserializer=channel_group.ChannelGroup.deserialize, @@ -3304,7 +3403,7 @@ def list_channel_groups( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_channel_groups" not in self._stubs: - self._stubs["list_channel_groups"] = self.grpc_channel.unary_unary( + self._stubs["list_channel_groups"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListChannelGroups", request_serializer=analytics_admin.ListChannelGroupsRequest.serialize, response_deserializer=analytics_admin.ListChannelGroupsResponse.deserialize, @@ -3333,7 +3432,7 @@ def create_channel_group( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_channel_group" not in self._stubs: - self._stubs["create_channel_group"] = self.grpc_channel.unary_unary( + self._stubs["create_channel_group"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateChannelGroup", request_serializer=analytics_admin.CreateChannelGroupRequest.serialize, response_deserializer=gaa_channel_group.ChannelGroup.deserialize, @@ -3362,7 +3461,7 @@ def update_channel_group( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_channel_group" not in self._stubs: - self._stubs["update_channel_group"] = self.grpc_channel.unary_unary( + self._stubs["update_channel_group"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateChannelGroup", request_serializer=analytics_admin.UpdateChannelGroupRequest.serialize, response_deserializer=gaa_channel_group.ChannelGroup.deserialize, @@ -3390,7 +3489,7 @@ def delete_channel_group( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_channel_group" not in self._stubs: - self._stubs["delete_channel_group"] = self.grpc_channel.unary_unary( + self._stubs["delete_channel_group"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteChannelGroup", request_serializer=analytics_admin.DeleteChannelGroupRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -3424,7 +3523,7 @@ def set_automated_ga4_configuration_opt_out( if "set_automated_ga4_configuration_opt_out" not in self._stubs: self._stubs[ "set_automated_ga4_configuration_opt_out" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/SetAutomatedGa4ConfigurationOptOut", request_serializer=analytics_admin.SetAutomatedGa4ConfigurationOptOutRequest.serialize, response_deserializer=analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse.deserialize, @@ -3458,7 +3557,7 @@ def fetch_automated_ga4_configuration_opt_out( if "fetch_automated_ga4_configuration_opt_out" not in self._stubs: self._stubs[ "fetch_automated_ga4_configuration_opt_out" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/FetchAutomatedGa4ConfigurationOptOut", request_serializer=analytics_admin.FetchAutomatedGa4ConfigurationOptOutRequest.serialize, response_deserializer=analytics_admin.FetchAutomatedGa4ConfigurationOptOutResponse.deserialize, @@ -3486,7 +3585,7 @@ def create_big_query_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_big_query_link" not in self._stubs: - self._stubs["create_big_query_link"] = self.grpc_channel.unary_unary( + self._stubs["create_big_query_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateBigQueryLink", request_serializer=analytics_admin.CreateBigQueryLinkRequest.serialize, response_deserializer=resources.BigQueryLink.deserialize, @@ -3514,7 +3613,7 @@ def get_big_query_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_big_query_link" not in self._stubs: - self._stubs["get_big_query_link"] = self.grpc_channel.unary_unary( + self._stubs["get_big_query_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetBigQueryLink", request_serializer=analytics_admin.GetBigQueryLinkRequest.serialize, response_deserializer=resources.BigQueryLink.deserialize, @@ -3543,7 +3642,7 @@ def list_big_query_links( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_big_query_links" not in self._stubs: - self._stubs["list_big_query_links"] = self.grpc_channel.unary_unary( + self._stubs["list_big_query_links"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListBigQueryLinks", request_serializer=analytics_admin.ListBigQueryLinksRequest.serialize, response_deserializer=analytics_admin.ListBigQueryLinksResponse.deserialize, @@ -3571,7 +3670,7 @@ def delete_big_query_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_big_query_link" not in self._stubs: - self._stubs["delete_big_query_link"] = self.grpc_channel.unary_unary( + self._stubs["delete_big_query_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteBigQueryLink", request_serializer=analytics_admin.DeleteBigQueryLinkRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -3599,7 +3698,7 @@ def update_big_query_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_big_query_link" not in self._stubs: - self._stubs["update_big_query_link"] = self.grpc_channel.unary_unary( + self._stubs["update_big_query_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateBigQueryLink", request_serializer=analytics_admin.UpdateBigQueryLinkRequest.serialize, response_deserializer=resources.BigQueryLink.deserialize, @@ -3633,7 +3732,7 @@ def get_enhanced_measurement_settings( if "get_enhanced_measurement_settings" not in self._stubs: self._stubs[ "get_enhanced_measurement_settings" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetEnhancedMeasurementSettings", request_serializer=analytics_admin.GetEnhancedMeasurementSettingsRequest.serialize, response_deserializer=resources.EnhancedMeasurementSettings.deserialize, @@ -3667,7 +3766,7 @@ def update_enhanced_measurement_settings( if "update_enhanced_measurement_settings" not in self._stubs: self._stubs[ "update_enhanced_measurement_settings" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateEnhancedMeasurementSettings", request_serializer=analytics_admin.UpdateEnhancedMeasurementSettingsRequest.serialize, response_deserializer=resources.EnhancedMeasurementSettings.deserialize, @@ -3699,7 +3798,7 @@ def create_connected_site_tag( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_connected_site_tag" not in self._stubs: - self._stubs["create_connected_site_tag"] = self.grpc_channel.unary_unary( + self._stubs["create_connected_site_tag"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateConnectedSiteTag", request_serializer=analytics_admin.CreateConnectedSiteTagRequest.serialize, response_deserializer=analytics_admin.CreateConnectedSiteTagResponse.deserialize, @@ -3729,7 +3828,7 @@ def delete_connected_site_tag( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_connected_site_tag" not in self._stubs: - self._stubs["delete_connected_site_tag"] = self.grpc_channel.unary_unary( + self._stubs["delete_connected_site_tag"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteConnectedSiteTag", request_serializer=analytics_admin.DeleteConnectedSiteTagRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -3761,7 +3860,7 @@ def list_connected_site_tags( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_connected_site_tags" not in self._stubs: - self._stubs["list_connected_site_tags"] = self.grpc_channel.unary_unary( + self._stubs["list_connected_site_tags"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListConnectedSiteTags", request_serializer=analytics_admin.ListConnectedSiteTagsRequest.serialize, response_deserializer=analytics_admin.ListConnectedSiteTagsResponse.deserialize, @@ -3792,7 +3891,9 @@ def fetch_connected_ga4_property( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "fetch_connected_ga4_property" not in self._stubs: - self._stubs["fetch_connected_ga4_property"] = self.grpc_channel.unary_unary( + self._stubs[ + "fetch_connected_ga4_property" + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/FetchConnectedGa4Property", request_serializer=analytics_admin.FetchConnectedGa4PropertyRequest.serialize, response_deserializer=analytics_admin.FetchConnectedGa4PropertyResponse.deserialize, @@ -3820,7 +3921,7 @@ def get_ad_sense_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_ad_sense_link" not in self._stubs: - self._stubs["get_ad_sense_link"] = self.grpc_channel.unary_unary( + self._stubs["get_ad_sense_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetAdSenseLink", request_serializer=analytics_admin.GetAdSenseLinkRequest.serialize, response_deserializer=resources.AdSenseLink.deserialize, @@ -3848,7 +3949,7 @@ def create_ad_sense_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_ad_sense_link" not in self._stubs: - self._stubs["create_ad_sense_link"] = self.grpc_channel.unary_unary( + self._stubs["create_ad_sense_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateAdSenseLink", request_serializer=analytics_admin.CreateAdSenseLinkRequest.serialize, response_deserializer=resources.AdSenseLink.deserialize, @@ -3876,7 +3977,7 @@ def delete_ad_sense_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_ad_sense_link" not in self._stubs: - self._stubs["delete_ad_sense_link"] = self.grpc_channel.unary_unary( + self._stubs["delete_ad_sense_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteAdSenseLink", request_serializer=analytics_admin.DeleteAdSenseLinkRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -3905,7 +4006,7 @@ def list_ad_sense_links( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_ad_sense_links" not in self._stubs: - self._stubs["list_ad_sense_links"] = self.grpc_channel.unary_unary( + self._stubs["list_ad_sense_links"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListAdSenseLinks", request_serializer=analytics_admin.ListAdSenseLinksRequest.serialize, response_deserializer=analytics_admin.ListAdSenseLinksResponse.deserialize, @@ -3934,7 +4035,7 @@ def get_event_create_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_event_create_rule" not in self._stubs: - self._stubs["get_event_create_rule"] = self.grpc_channel.unary_unary( + self._stubs["get_event_create_rule"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetEventCreateRule", request_serializer=analytics_admin.GetEventCreateRuleRequest.serialize, response_deserializer=event_create_and_edit.EventCreateRule.deserialize, @@ -3963,7 +4064,7 @@ def list_event_create_rules( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_event_create_rules" not in self._stubs: - self._stubs["list_event_create_rules"] = self.grpc_channel.unary_unary( + self._stubs["list_event_create_rules"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListEventCreateRules", request_serializer=analytics_admin.ListEventCreateRulesRequest.serialize, response_deserializer=analytics_admin.ListEventCreateRulesResponse.deserialize, @@ -3992,7 +4093,7 @@ def create_event_create_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_event_create_rule" not in self._stubs: - self._stubs["create_event_create_rule"] = self.grpc_channel.unary_unary( + self._stubs["create_event_create_rule"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateEventCreateRule", request_serializer=analytics_admin.CreateEventCreateRuleRequest.serialize, response_deserializer=event_create_and_edit.EventCreateRule.deserialize, @@ -4021,7 +4122,7 @@ def update_event_create_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_event_create_rule" not in self._stubs: - self._stubs["update_event_create_rule"] = self.grpc_channel.unary_unary( + self._stubs["update_event_create_rule"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateEventCreateRule", request_serializer=analytics_admin.UpdateEventCreateRuleRequest.serialize, response_deserializer=event_create_and_edit.EventCreateRule.deserialize, @@ -4049,7 +4150,7 @@ def delete_event_create_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_event_create_rule" not in self._stubs: - self._stubs["delete_event_create_rule"] = self.grpc_channel.unary_unary( + self._stubs["delete_event_create_rule"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteEventCreateRule", request_serializer=analytics_admin.DeleteEventCreateRuleRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -4078,7 +4179,7 @@ def get_event_edit_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_event_edit_rule" not in self._stubs: - self._stubs["get_event_edit_rule"] = self.grpc_channel.unary_unary( + self._stubs["get_event_edit_rule"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetEventEditRule", request_serializer=analytics_admin.GetEventEditRuleRequest.serialize, response_deserializer=event_create_and_edit.EventEditRule.deserialize, @@ -4107,7 +4208,7 @@ def list_event_edit_rules( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_event_edit_rules" not in self._stubs: - self._stubs["list_event_edit_rules"] = self.grpc_channel.unary_unary( + self._stubs["list_event_edit_rules"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListEventEditRules", request_serializer=analytics_admin.ListEventEditRulesRequest.serialize, response_deserializer=analytics_admin.ListEventEditRulesResponse.deserialize, @@ -4136,7 +4237,7 @@ def create_event_edit_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_event_edit_rule" not in self._stubs: - self._stubs["create_event_edit_rule"] = self.grpc_channel.unary_unary( + self._stubs["create_event_edit_rule"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateEventEditRule", request_serializer=analytics_admin.CreateEventEditRuleRequest.serialize, response_deserializer=event_create_and_edit.EventEditRule.deserialize, @@ -4165,7 +4266,7 @@ def update_event_edit_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_event_edit_rule" not in self._stubs: - self._stubs["update_event_edit_rule"] = self.grpc_channel.unary_unary( + self._stubs["update_event_edit_rule"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateEventEditRule", request_serializer=analytics_admin.UpdateEventEditRuleRequest.serialize, response_deserializer=event_create_and_edit.EventEditRule.deserialize, @@ -4193,7 +4294,7 @@ def delete_event_edit_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_event_edit_rule" not in self._stubs: - self._stubs["delete_event_edit_rule"] = self.grpc_channel.unary_unary( + self._stubs["delete_event_edit_rule"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteEventEditRule", request_serializer=analytics_admin.DeleteEventEditRuleRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -4222,7 +4323,7 @@ def reorder_event_edit_rules( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reorder_event_edit_rules" not in self._stubs: - self._stubs["reorder_event_edit_rules"] = self.grpc_channel.unary_unary( + self._stubs["reorder_event_edit_rules"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ReorderEventEditRules", request_serializer=analytics_admin.ReorderEventEditRulesRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -4253,7 +4354,7 @@ def update_data_redaction_settings( if "update_data_redaction_settings" not in self._stubs: self._stubs[ "update_data_redaction_settings" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateDataRedactionSettings", request_serializer=analytics_admin.UpdateDataRedactionSettingsRequest.serialize, response_deserializer=resources.DataRedactionSettings.deserialize, @@ -4282,7 +4383,9 @@ def get_data_redaction_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_data_redaction_settings" not in self._stubs: - self._stubs["get_data_redaction_settings"] = self.grpc_channel.unary_unary( + self._stubs[ + "get_data_redaction_settings" + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetDataRedactionSettings", request_serializer=analytics_admin.GetDataRedactionSettingsRequest.serialize, response_deserializer=resources.DataRedactionSettings.deserialize, @@ -4311,7 +4414,7 @@ def get_calculated_metric( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_calculated_metric" not in self._stubs: - self._stubs["get_calculated_metric"] = self.grpc_channel.unary_unary( + self._stubs["get_calculated_metric"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetCalculatedMetric", request_serializer=analytics_admin.GetCalculatedMetricRequest.serialize, response_deserializer=resources.CalculatedMetric.deserialize, @@ -4340,7 +4443,7 @@ def create_calculated_metric( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_calculated_metric" not in self._stubs: - self._stubs["create_calculated_metric"] = self.grpc_channel.unary_unary( + self._stubs["create_calculated_metric"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateCalculatedMetric", request_serializer=analytics_admin.CreateCalculatedMetricRequest.serialize, response_deserializer=resources.CalculatedMetric.deserialize, @@ -4369,7 +4472,7 @@ def list_calculated_metrics( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_calculated_metrics" not in self._stubs: - self._stubs["list_calculated_metrics"] = self.grpc_channel.unary_unary( + self._stubs["list_calculated_metrics"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListCalculatedMetrics", request_serializer=analytics_admin.ListCalculatedMetricsRequest.serialize, response_deserializer=analytics_admin.ListCalculatedMetricsResponse.deserialize, @@ -4398,7 +4501,7 @@ def update_calculated_metric( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_calculated_metric" not in self._stubs: - self._stubs["update_calculated_metric"] = self.grpc_channel.unary_unary( + self._stubs["update_calculated_metric"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateCalculatedMetric", request_serializer=analytics_admin.UpdateCalculatedMetricRequest.serialize, response_deserializer=resources.CalculatedMetric.deserialize, @@ -4426,7 +4529,7 @@ def delete_calculated_metric( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_calculated_metric" not in self._stubs: - self._stubs["delete_calculated_metric"] = self.grpc_channel.unary_unary( + self._stubs["delete_calculated_metric"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteCalculatedMetric", request_serializer=analytics_admin.DeleteCalculatedMetricRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -4456,7 +4559,7 @@ def create_rollup_property( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_rollup_property" not in self._stubs: - self._stubs["create_rollup_property"] = self.grpc_channel.unary_unary( + self._stubs["create_rollup_property"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateRollupProperty", request_serializer=analytics_admin.CreateRollupPropertyRequest.serialize, response_deserializer=analytics_admin.CreateRollupPropertyResponse.deserialize, @@ -4491,7 +4594,7 @@ def get_rollup_property_source_link( if "get_rollup_property_source_link" not in self._stubs: self._stubs[ "get_rollup_property_source_link" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetRollupPropertySourceLink", request_serializer=analytics_admin.GetRollupPropertySourceLinkRequest.serialize, response_deserializer=resources.RollupPropertySourceLink.deserialize, @@ -4526,7 +4629,7 @@ def list_rollup_property_source_links( if "list_rollup_property_source_links" not in self._stubs: self._stubs[ "list_rollup_property_source_links" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListRollupPropertySourceLinks", request_serializer=analytics_admin.ListRollupPropertySourceLinksRequest.serialize, response_deserializer=analytics_admin.ListRollupPropertySourceLinksResponse.deserialize, @@ -4561,7 +4664,7 @@ def create_rollup_property_source_link( if "create_rollup_property_source_link" not in self._stubs: self._stubs[ "create_rollup_property_source_link" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateRollupPropertySourceLink", request_serializer=analytics_admin.CreateRollupPropertySourceLinkRequest.serialize, response_deserializer=resources.RollupPropertySourceLink.deserialize, @@ -4596,7 +4699,7 @@ def delete_rollup_property_source_link( if "delete_rollup_property_source_link" not in self._stubs: self._stubs[ "delete_rollup_property_source_link" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteRollupPropertySourceLink", request_serializer=analytics_admin.DeleteRollupPropertySourceLinkRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -4626,7 +4729,7 @@ def provision_subproperty( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "provision_subproperty" not in self._stubs: - self._stubs["provision_subproperty"] = self.grpc_channel.unary_unary( + self._stubs["provision_subproperty"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ProvisionSubproperty", request_serializer=analytics_admin.ProvisionSubpropertyRequest.serialize, response_deserializer=analytics_admin.ProvisionSubpropertyResponse.deserialize, @@ -4658,7 +4761,7 @@ def create_subproperty_event_filter( if "create_subproperty_event_filter" not in self._stubs: self._stubs[ "create_subproperty_event_filter" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/CreateSubpropertyEventFilter", request_serializer=analytics_admin.CreateSubpropertyEventFilterRequest.serialize, response_deserializer=gaa_subproperty_event_filter.SubpropertyEventFilter.deserialize, @@ -4687,7 +4790,9 @@ def get_subproperty_event_filter( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_subproperty_event_filter" not in self._stubs: - self._stubs["get_subproperty_event_filter"] = self.grpc_channel.unary_unary( + self._stubs[ + "get_subproperty_event_filter" + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/GetSubpropertyEventFilter", request_serializer=analytics_admin.GetSubpropertyEventFilterRequest.serialize, response_deserializer=subproperty_event_filter.SubpropertyEventFilter.deserialize, @@ -4718,7 +4823,7 @@ def list_subproperty_event_filters( if "list_subproperty_event_filters" not in self._stubs: self._stubs[ "list_subproperty_event_filters" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/ListSubpropertyEventFilters", request_serializer=analytics_admin.ListSubpropertyEventFiltersRequest.serialize, response_deserializer=analytics_admin.ListSubpropertyEventFiltersResponse.deserialize, @@ -4750,7 +4855,7 @@ def update_subproperty_event_filter( if "update_subproperty_event_filter" not in self._stubs: self._stubs[ "update_subproperty_event_filter" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/UpdateSubpropertyEventFilter", request_serializer=analytics_admin.UpdateSubpropertyEventFilterRequest.serialize, response_deserializer=gaa_subproperty_event_filter.SubpropertyEventFilter.deserialize, @@ -4782,7 +4887,7 @@ def delete_subproperty_event_filter( if "delete_subproperty_event_filter" not in self._stubs: self._stubs[ "delete_subproperty_event_filter" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1alpha.AnalyticsAdminService/DeleteSubpropertyEventFilter", request_serializer=analytics_admin.DeleteSubpropertyEventFilterRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -5550,7 +5655,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-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/rest.py b/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/rest.py index 9b61700aa138..f9cdd0e8ea09 100644 --- a/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_service/transports/rest.py +++ b/packages/google-analytics-admin/google/analytics/admin_v1alpha/services/analytics_admin_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 @@ -52,6 +52,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, @@ -1176,9 +1184,10 @@ def post_update_subproperty_event_filter(self, response): def pre_acknowledge_user_data_collection( self, request: analytics_admin.AcknowledgeUserDataCollectionRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.AcknowledgeUserDataCollectionRequest, Sequence[Tuple[str, str]] + analytics_admin.AcknowledgeUserDataCollectionRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for acknowledge_user_data_collection @@ -1201,10 +1210,10 @@ def post_acknowledge_user_data_collection( def pre_approve_display_video360_advertiser_link_proposal( self, request: analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for approve_display_video360_advertiser_link_proposal @@ -1228,8 +1237,10 @@ def post_approve_display_video360_advertiser_link_proposal( def pre_archive_audience( self, request: analytics_admin.ArchiveAudienceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.ArchiveAudienceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.ArchiveAudienceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for archive_audience Override in a subclass to manipulate the request or metadata @@ -1240,9 +1251,10 @@ def pre_archive_audience( def pre_archive_custom_dimension( self, request: analytics_admin.ArchiveCustomDimensionRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.ArchiveCustomDimensionRequest, Sequence[Tuple[str, str]] + analytics_admin.ArchiveCustomDimensionRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for archive_custom_dimension @@ -1254,8 +1266,11 @@ def pre_archive_custom_dimension( def pre_archive_custom_metric( self, request: analytics_admin.ArchiveCustomMetricRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.ArchiveCustomMetricRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.ArchiveCustomMetricRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for archive_custom_metric Override in a subclass to manipulate the request or metadata @@ -1266,9 +1281,10 @@ def pre_archive_custom_metric( def pre_batch_create_access_bindings( self, request: analytics_admin.BatchCreateAccessBindingsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.BatchCreateAccessBindingsRequest, Sequence[Tuple[str, str]] + analytics_admin.BatchCreateAccessBindingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for batch_create_access_bindings @@ -1291,9 +1307,10 @@ def post_batch_create_access_bindings( def pre_batch_delete_access_bindings( self, request: analytics_admin.BatchDeleteAccessBindingsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.BatchDeleteAccessBindingsRequest, Sequence[Tuple[str, str]] + analytics_admin.BatchDeleteAccessBindingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for batch_delete_access_bindings @@ -1305,9 +1322,10 @@ def pre_batch_delete_access_bindings( def pre_batch_get_access_bindings( self, request: analytics_admin.BatchGetAccessBindingsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.BatchGetAccessBindingsRequest, Sequence[Tuple[str, str]] + analytics_admin.BatchGetAccessBindingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for batch_get_access_bindings @@ -1330,9 +1348,10 @@ def post_batch_get_access_bindings( def pre_batch_update_access_bindings( self, request: analytics_admin.BatchUpdateAccessBindingsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.BatchUpdateAccessBindingsRequest, Sequence[Tuple[str, str]] + analytics_admin.BatchUpdateAccessBindingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for batch_update_access_bindings @@ -1355,10 +1374,10 @@ def post_batch_update_access_bindings( def pre_cancel_display_video360_advertiser_link_proposal( self, request: analytics_admin.CancelDisplayVideo360AdvertiserLinkProposalRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ analytics_admin.CancelDisplayVideo360AdvertiserLinkProposalRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for cancel_display_video360_advertiser_link_proposal @@ -1381,8 +1400,11 @@ def post_cancel_display_video360_advertiser_link_proposal( def pre_create_access_binding( self, request: analytics_admin.CreateAccessBindingRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.CreateAccessBindingRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.CreateAccessBindingRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_access_binding Override in a subclass to manipulate the request or metadata @@ -1404,8 +1426,11 @@ def post_create_access_binding( def pre_create_ad_sense_link( self, request: analytics_admin.CreateAdSenseLinkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.CreateAdSenseLinkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.CreateAdSenseLinkRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_ad_sense_link Override in a subclass to manipulate the request or metadata @@ -1427,8 +1452,10 @@ def post_create_ad_sense_link( def pre_create_audience( self, request: analytics_admin.CreateAudienceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.CreateAudienceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.CreateAudienceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_audience Override in a subclass to manipulate the request or metadata @@ -1450,8 +1477,11 @@ def post_create_audience( def pre_create_big_query_link( self, request: analytics_admin.CreateBigQueryLinkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.CreateBigQueryLinkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.CreateBigQueryLinkRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_big_query_link Override in a subclass to manipulate the request or metadata @@ -1473,9 +1503,10 @@ def post_create_big_query_link( def pre_create_calculated_metric( self, request: analytics_admin.CreateCalculatedMetricRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.CreateCalculatedMetricRequest, Sequence[Tuple[str, str]] + analytics_admin.CreateCalculatedMetricRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_calculated_metric @@ -1498,8 +1529,11 @@ def post_create_calculated_metric( def pre_create_channel_group( self, request: analytics_admin.CreateChannelGroupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.CreateChannelGroupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.CreateChannelGroupRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_channel_group Override in a subclass to manipulate the request or metadata @@ -1521,9 +1555,10 @@ def post_create_channel_group( def pre_create_connected_site_tag( self, request: analytics_admin.CreateConnectedSiteTagRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.CreateConnectedSiteTagRequest, Sequence[Tuple[str, str]] + analytics_admin.CreateConnectedSiteTagRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_connected_site_tag @@ -1546,8 +1581,11 @@ def post_create_connected_site_tag( def pre_create_conversion_event( self, request: analytics_admin.CreateConversionEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.CreateConversionEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.CreateConversionEventRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_conversion_event Override in a subclass to manipulate the request or metadata @@ -1569,8 +1607,11 @@ def post_create_conversion_event( def pre_create_custom_dimension( self, request: analytics_admin.CreateCustomDimensionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.CreateCustomDimensionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.CreateCustomDimensionRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_custom_dimension Override in a subclass to manipulate the request or metadata @@ -1592,8 +1633,11 @@ def post_create_custom_dimension( def pre_create_custom_metric( self, request: analytics_admin.CreateCustomMetricRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.CreateCustomMetricRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.CreateCustomMetricRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_custom_metric Override in a subclass to manipulate the request or metadata @@ -1615,8 +1659,10 @@ def post_create_custom_metric( def pre_create_data_stream( self, request: analytics_admin.CreateDataStreamRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.CreateDataStreamRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.CreateDataStreamRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_data_stream Override in a subclass to manipulate the request or metadata @@ -1638,10 +1684,10 @@ def post_create_data_stream( def pre_create_display_video360_advertiser_link( self, request: analytics_admin.CreateDisplayVideo360AdvertiserLinkRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ analytics_admin.CreateDisplayVideo360AdvertiserLinkRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_display_video360_advertiser_link @@ -1664,10 +1710,10 @@ def post_create_display_video360_advertiser_link( def pre_create_display_video360_advertiser_link_proposal( self, request: analytics_admin.CreateDisplayVideo360AdvertiserLinkProposalRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ analytics_admin.CreateDisplayVideo360AdvertiserLinkProposalRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_display_video360_advertiser_link_proposal @@ -1690,8 +1736,11 @@ def post_create_display_video360_advertiser_link_proposal( def pre_create_event_create_rule( self, request: analytics_admin.CreateEventCreateRuleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.CreateEventCreateRuleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.CreateEventCreateRuleRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_event_create_rule Override in a subclass to manipulate the request or metadata @@ -1713,8 +1762,11 @@ def post_create_event_create_rule( def pre_create_event_edit_rule( self, request: analytics_admin.CreateEventEditRuleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.CreateEventEditRuleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.CreateEventEditRuleRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_event_edit_rule Override in a subclass to manipulate the request or metadata @@ -1736,8 +1788,11 @@ def post_create_event_edit_rule( def pre_create_expanded_data_set( self, request: analytics_admin.CreateExpandedDataSetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.CreateExpandedDataSetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.CreateExpandedDataSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_expanded_data_set Override in a subclass to manipulate the request or metadata @@ -1759,8 +1814,11 @@ def post_create_expanded_data_set( def pre_create_firebase_link( self, request: analytics_admin.CreateFirebaseLinkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.CreateFirebaseLinkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.CreateFirebaseLinkRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_firebase_link Override in a subclass to manipulate the request or metadata @@ -1782,8 +1840,11 @@ def post_create_firebase_link( def pre_create_google_ads_link( self, request: analytics_admin.CreateGoogleAdsLinkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.CreateGoogleAdsLinkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.CreateGoogleAdsLinkRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_google_ads_link Override in a subclass to manipulate the request or metadata @@ -1805,8 +1866,10 @@ def post_create_google_ads_link( def pre_create_key_event( self, request: analytics_admin.CreateKeyEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.CreateKeyEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.CreateKeyEventRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_key_event Override in a subclass to manipulate the request or metadata @@ -1826,10 +1889,10 @@ def post_create_key_event(self, response: resources.KeyEvent) -> resources.KeyEv def pre_create_measurement_protocol_secret( self, request: analytics_admin.CreateMeasurementProtocolSecretRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ analytics_admin.CreateMeasurementProtocolSecretRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_measurement_protocol_secret @@ -1852,8 +1915,10 @@ def post_create_measurement_protocol_secret( def pre_create_property( self, request: analytics_admin.CreatePropertyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.CreatePropertyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.CreatePropertyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_property Override in a subclass to manipulate the request or metadata @@ -1873,8 +1938,11 @@ def post_create_property(self, response: resources.Property) -> resources.Proper def pre_create_rollup_property( self, request: analytics_admin.CreateRollupPropertyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.CreateRollupPropertyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.CreateRollupPropertyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_rollup_property Override in a subclass to manipulate the request or metadata @@ -1896,9 +1964,10 @@ def post_create_rollup_property( def pre_create_rollup_property_source_link( self, request: analytics_admin.CreateRollupPropertySourceLinkRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.CreateRollupPropertySourceLinkRequest, Sequence[Tuple[str, str]] + analytics_admin.CreateRollupPropertySourceLinkRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_rollup_property_source_link @@ -1921,9 +1990,10 @@ def post_create_rollup_property_source_link( def pre_create_search_ads360_link( self, request: analytics_admin.CreateSearchAds360LinkRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.CreateSearchAds360LinkRequest, Sequence[Tuple[str, str]] + analytics_admin.CreateSearchAds360LinkRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_search_ads360_link @@ -1946,10 +2016,10 @@ def post_create_search_ads360_link( def pre_create_sk_ad_network_conversion_value_schema( self, request: analytics_admin.CreateSKAdNetworkConversionValueSchemaRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ analytics_admin.CreateSKAdNetworkConversionValueSchemaRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_sk_ad_network_conversion_value_schema @@ -1972,9 +2042,10 @@ def post_create_sk_ad_network_conversion_value_schema( def pre_create_subproperty_event_filter( self, request: analytics_admin.CreateSubpropertyEventFilterRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.CreateSubpropertyEventFilterRequest, Sequence[Tuple[str, str]] + analytics_admin.CreateSubpropertyEventFilterRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_subproperty_event_filter @@ -1997,8 +2068,11 @@ def post_create_subproperty_event_filter( def pre_delete_access_binding( self, request: analytics_admin.DeleteAccessBindingRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.DeleteAccessBindingRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.DeleteAccessBindingRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_access_binding Override in a subclass to manipulate the request or metadata @@ -2009,8 +2083,10 @@ def pre_delete_access_binding( def pre_delete_account( self, request: analytics_admin.DeleteAccountRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.DeleteAccountRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.DeleteAccountRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_account Override in a subclass to manipulate the request or metadata @@ -2021,8 +2097,11 @@ def pre_delete_account( def pre_delete_ad_sense_link( self, request: analytics_admin.DeleteAdSenseLinkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.DeleteAdSenseLinkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.DeleteAdSenseLinkRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_ad_sense_link Override in a subclass to manipulate the request or metadata @@ -2033,8 +2112,11 @@ def pre_delete_ad_sense_link( def pre_delete_big_query_link( self, request: analytics_admin.DeleteBigQueryLinkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.DeleteBigQueryLinkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.DeleteBigQueryLinkRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_big_query_link Override in a subclass to manipulate the request or metadata @@ -2045,9 +2127,10 @@ def pre_delete_big_query_link( def pre_delete_calculated_metric( self, request: analytics_admin.DeleteCalculatedMetricRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.DeleteCalculatedMetricRequest, Sequence[Tuple[str, str]] + analytics_admin.DeleteCalculatedMetricRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_calculated_metric @@ -2059,8 +2142,11 @@ def pre_delete_calculated_metric( def pre_delete_channel_group( self, request: analytics_admin.DeleteChannelGroupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.DeleteChannelGroupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.DeleteChannelGroupRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_channel_group Override in a subclass to manipulate the request or metadata @@ -2071,9 +2157,10 @@ def pre_delete_channel_group( def pre_delete_connected_site_tag( self, request: analytics_admin.DeleteConnectedSiteTagRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.DeleteConnectedSiteTagRequest, Sequence[Tuple[str, str]] + analytics_admin.DeleteConnectedSiteTagRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_connected_site_tag @@ -2085,8 +2172,11 @@ def pre_delete_connected_site_tag( def pre_delete_conversion_event( self, request: analytics_admin.DeleteConversionEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.DeleteConversionEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.DeleteConversionEventRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_conversion_event Override in a subclass to manipulate the request or metadata @@ -2097,8 +2187,10 @@ def pre_delete_conversion_event( def pre_delete_data_stream( self, request: analytics_admin.DeleteDataStreamRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.DeleteDataStreamRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.DeleteDataStreamRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_data_stream Override in a subclass to manipulate the request or metadata @@ -2109,10 +2201,10 @@ def pre_delete_data_stream( def pre_delete_display_video360_advertiser_link( self, request: analytics_admin.DeleteDisplayVideo360AdvertiserLinkRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ analytics_admin.DeleteDisplayVideo360AdvertiserLinkRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_display_video360_advertiser_link @@ -2124,10 +2216,10 @@ def pre_delete_display_video360_advertiser_link( def pre_delete_display_video360_advertiser_link_proposal( self, request: analytics_admin.DeleteDisplayVideo360AdvertiserLinkProposalRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ analytics_admin.DeleteDisplayVideo360AdvertiserLinkProposalRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_display_video360_advertiser_link_proposal @@ -2139,8 +2231,11 @@ def pre_delete_display_video360_advertiser_link_proposal( def pre_delete_event_create_rule( self, request: analytics_admin.DeleteEventCreateRuleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.DeleteEventCreateRuleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.DeleteEventCreateRuleRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_event_create_rule Override in a subclass to manipulate the request or metadata @@ -2151,8 +2246,11 @@ def pre_delete_event_create_rule( def pre_delete_event_edit_rule( self, request: analytics_admin.DeleteEventEditRuleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.DeleteEventEditRuleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.DeleteEventEditRuleRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_event_edit_rule Override in a subclass to manipulate the request or metadata @@ -2163,8 +2261,11 @@ def pre_delete_event_edit_rule( def pre_delete_expanded_data_set( self, request: analytics_admin.DeleteExpandedDataSetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.DeleteExpandedDataSetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.DeleteExpandedDataSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_expanded_data_set Override in a subclass to manipulate the request or metadata @@ -2175,8 +2276,11 @@ def pre_delete_expanded_data_set( def pre_delete_firebase_link( self, request: analytics_admin.DeleteFirebaseLinkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.DeleteFirebaseLinkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.DeleteFirebaseLinkRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_firebase_link Override in a subclass to manipulate the request or metadata @@ -2187,8 +2291,11 @@ def pre_delete_firebase_link( def pre_delete_google_ads_link( self, request: analytics_admin.DeleteGoogleAdsLinkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.DeleteGoogleAdsLinkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.DeleteGoogleAdsLinkRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_google_ads_link Override in a subclass to manipulate the request or metadata @@ -2199,8 +2306,10 @@ def pre_delete_google_ads_link( def pre_delete_key_event( self, request: analytics_admin.DeleteKeyEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.DeleteKeyEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.DeleteKeyEventRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_key_event Override in a subclass to manipulate the request or metadata @@ -2211,10 +2320,10 @@ def pre_delete_key_event( def pre_delete_measurement_protocol_secret( self, request: analytics_admin.DeleteMeasurementProtocolSecretRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ analytics_admin.DeleteMeasurementProtocolSecretRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_measurement_protocol_secret @@ -2226,8 +2335,10 @@ def pre_delete_measurement_protocol_secret( def pre_delete_property( self, request: analytics_admin.DeletePropertyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.DeletePropertyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.DeletePropertyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_property Override in a subclass to manipulate the request or metadata @@ -2247,9 +2358,10 @@ def post_delete_property(self, response: resources.Property) -> resources.Proper def pre_delete_rollup_property_source_link( self, request: analytics_admin.DeleteRollupPropertySourceLinkRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.DeleteRollupPropertySourceLinkRequest, Sequence[Tuple[str, str]] + analytics_admin.DeleteRollupPropertySourceLinkRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_rollup_property_source_link @@ -2261,9 +2373,10 @@ def pre_delete_rollup_property_source_link( def pre_delete_search_ads360_link( self, request: analytics_admin.DeleteSearchAds360LinkRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.DeleteSearchAds360LinkRequest, Sequence[Tuple[str, str]] + analytics_admin.DeleteSearchAds360LinkRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_search_ads360_link @@ -2275,10 +2388,10 @@ def pre_delete_search_ads360_link( def pre_delete_sk_ad_network_conversion_value_schema( self, request: analytics_admin.DeleteSKAdNetworkConversionValueSchemaRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ analytics_admin.DeleteSKAdNetworkConversionValueSchemaRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_sk_ad_network_conversion_value_schema @@ -2290,9 +2403,10 @@ def pre_delete_sk_ad_network_conversion_value_schema( def pre_delete_subproperty_event_filter( self, request: analytics_admin.DeleteSubpropertyEventFilterRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.DeleteSubpropertyEventFilterRequest, Sequence[Tuple[str, str]] + analytics_admin.DeleteSubpropertyEventFilterRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_subproperty_event_filter @@ -2304,10 +2418,10 @@ def pre_delete_subproperty_event_filter( def pre_fetch_automated_ga4_configuration_opt_out( self, request: analytics_admin.FetchAutomatedGa4ConfigurationOptOutRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ analytics_admin.FetchAutomatedGa4ConfigurationOptOutRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for fetch_automated_ga4_configuration_opt_out @@ -2330,9 +2444,10 @@ def post_fetch_automated_ga4_configuration_opt_out( def pre_fetch_connected_ga4_property( self, request: analytics_admin.FetchConnectedGa4PropertyRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.FetchConnectedGa4PropertyRequest, Sequence[Tuple[str, str]] + analytics_admin.FetchConnectedGa4PropertyRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for fetch_connected_ga4_property @@ -2355,8 +2470,10 @@ def post_fetch_connected_ga4_property( def pre_get_access_binding( self, request: analytics_admin.GetAccessBindingRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.GetAccessBindingRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.GetAccessBindingRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_access_binding Override in a subclass to manipulate the request or metadata @@ -2378,8 +2495,10 @@ def post_get_access_binding( def pre_get_account( self, request: analytics_admin.GetAccountRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.GetAccountRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.GetAccountRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_account Override in a subclass to manipulate the request or metadata @@ -2399,8 +2518,10 @@ def post_get_account(self, response: resources.Account) -> resources.Account: def pre_get_ad_sense_link( self, request: analytics_admin.GetAdSenseLinkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.GetAdSenseLinkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.GetAdSenseLinkRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_ad_sense_link Override in a subclass to manipulate the request or metadata @@ -2422,9 +2543,10 @@ def post_get_ad_sense_link( def pre_get_attribution_settings( self, request: analytics_admin.GetAttributionSettingsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.GetAttributionSettingsRequest, Sequence[Tuple[str, str]] + analytics_admin.GetAttributionSettingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_attribution_settings @@ -2447,8 +2569,10 @@ def post_get_attribution_settings( def pre_get_audience( self, request: analytics_admin.GetAudienceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.GetAudienceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.GetAudienceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_audience Override in a subclass to manipulate the request or metadata @@ -2468,8 +2592,10 @@ def post_get_audience(self, response: audience.Audience) -> audience.Audience: def pre_get_big_query_link( self, request: analytics_admin.GetBigQueryLinkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.GetBigQueryLinkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.GetBigQueryLinkRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_big_query_link Override in a subclass to manipulate the request or metadata @@ -2491,8 +2617,11 @@ def post_get_big_query_link( def pre_get_calculated_metric( self, request: analytics_admin.GetCalculatedMetricRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.GetCalculatedMetricRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.GetCalculatedMetricRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_calculated_metric Override in a subclass to manipulate the request or metadata @@ -2514,8 +2643,10 @@ def post_get_calculated_metric( def pre_get_channel_group( self, request: analytics_admin.GetChannelGroupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.GetChannelGroupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.GetChannelGroupRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_channel_group Override in a subclass to manipulate the request or metadata @@ -2537,8 +2668,11 @@ def post_get_channel_group( def pre_get_conversion_event( self, request: analytics_admin.GetConversionEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.GetConversionEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.GetConversionEventRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_conversion_event Override in a subclass to manipulate the request or metadata @@ -2560,8 +2694,11 @@ def post_get_conversion_event( def pre_get_custom_dimension( self, request: analytics_admin.GetCustomDimensionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.GetCustomDimensionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.GetCustomDimensionRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_custom_dimension Override in a subclass to manipulate the request or metadata @@ -2583,8 +2720,10 @@ def post_get_custom_dimension( def pre_get_custom_metric( self, request: analytics_admin.GetCustomMetricRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.GetCustomMetricRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.GetCustomMetricRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_custom_metric Override in a subclass to manipulate the request or metadata @@ -2606,9 +2745,10 @@ def post_get_custom_metric( def pre_get_data_redaction_settings( self, request: analytics_admin.GetDataRedactionSettingsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.GetDataRedactionSettingsRequest, Sequence[Tuple[str, str]] + analytics_admin.GetDataRedactionSettingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_data_redaction_settings @@ -2631,9 +2771,10 @@ def post_get_data_redaction_settings( def pre_get_data_retention_settings( self, request: analytics_admin.GetDataRetentionSettingsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.GetDataRetentionSettingsRequest, Sequence[Tuple[str, str]] + analytics_admin.GetDataRetentionSettingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_data_retention_settings @@ -2656,9 +2797,10 @@ def post_get_data_retention_settings( def pre_get_data_sharing_settings( self, request: analytics_admin.GetDataSharingSettingsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.GetDataSharingSettingsRequest, Sequence[Tuple[str, str]] + analytics_admin.GetDataSharingSettingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_data_sharing_settings @@ -2681,8 +2823,10 @@ def post_get_data_sharing_settings( def pre_get_data_stream( self, request: analytics_admin.GetDataStreamRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.GetDataStreamRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.GetDataStreamRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_data_stream Override in a subclass to manipulate the request or metadata @@ -2704,10 +2848,10 @@ def post_get_data_stream( def pre_get_display_video360_advertiser_link( self, request: analytics_admin.GetDisplayVideo360AdvertiserLinkRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ analytics_admin.GetDisplayVideo360AdvertiserLinkRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_display_video360_advertiser_link @@ -2730,10 +2874,10 @@ def post_get_display_video360_advertiser_link( def pre_get_display_video360_advertiser_link_proposal( self, request: analytics_admin.GetDisplayVideo360AdvertiserLinkProposalRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ analytics_admin.GetDisplayVideo360AdvertiserLinkProposalRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_display_video360_advertiser_link_proposal @@ -2756,9 +2900,10 @@ def post_get_display_video360_advertiser_link_proposal( def pre_get_enhanced_measurement_settings( self, request: analytics_admin.GetEnhancedMeasurementSettingsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.GetEnhancedMeasurementSettingsRequest, Sequence[Tuple[str, str]] + analytics_admin.GetEnhancedMeasurementSettingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_enhanced_measurement_settings @@ -2781,8 +2926,11 @@ def post_get_enhanced_measurement_settings( def pre_get_event_create_rule( self, request: analytics_admin.GetEventCreateRuleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.GetEventCreateRuleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.GetEventCreateRuleRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_event_create_rule Override in a subclass to manipulate the request or metadata @@ -2804,8 +2952,10 @@ def post_get_event_create_rule( def pre_get_event_edit_rule( self, request: analytics_admin.GetEventEditRuleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.GetEventEditRuleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.GetEventEditRuleRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_event_edit_rule Override in a subclass to manipulate the request or metadata @@ -2827,8 +2977,11 @@ def post_get_event_edit_rule( def pre_get_expanded_data_set( self, request: analytics_admin.GetExpandedDataSetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.GetExpandedDataSetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.GetExpandedDataSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_expanded_data_set Override in a subclass to manipulate the request or metadata @@ -2850,8 +3003,10 @@ def post_get_expanded_data_set( def pre_get_global_site_tag( self, request: analytics_admin.GetGlobalSiteTagRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.GetGlobalSiteTagRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.GetGlobalSiteTagRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_global_site_tag Override in a subclass to manipulate the request or metadata @@ -2873,9 +3028,10 @@ def post_get_global_site_tag( def pre_get_google_signals_settings( self, request: analytics_admin.GetGoogleSignalsSettingsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.GetGoogleSignalsSettingsRequest, Sequence[Tuple[str, str]] + analytics_admin.GetGoogleSignalsSettingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_google_signals_settings @@ -2898,8 +3054,10 @@ def post_get_google_signals_settings( def pre_get_key_event( self, request: analytics_admin.GetKeyEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.GetKeyEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.GetKeyEventRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_key_event Override in a subclass to manipulate the request or metadata @@ -2919,9 +3077,10 @@ def post_get_key_event(self, response: resources.KeyEvent) -> resources.KeyEvent def pre_get_measurement_protocol_secret( self, request: analytics_admin.GetMeasurementProtocolSecretRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.GetMeasurementProtocolSecretRequest, Sequence[Tuple[str, str]] + analytics_admin.GetMeasurementProtocolSecretRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_measurement_protocol_secret @@ -2944,8 +3103,10 @@ def post_get_measurement_protocol_secret( def pre_get_property( self, request: analytics_admin.GetPropertyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.GetPropertyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.GetPropertyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_property Override in a subclass to manipulate the request or metadata @@ -2965,9 +3126,10 @@ def post_get_property(self, response: resources.Property) -> resources.Property: def pre_get_rollup_property_source_link( self, request: analytics_admin.GetRollupPropertySourceLinkRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.GetRollupPropertySourceLinkRequest, Sequence[Tuple[str, str]] + analytics_admin.GetRollupPropertySourceLinkRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_rollup_property_source_link @@ -2990,8 +3152,11 @@ def post_get_rollup_property_source_link( def pre_get_search_ads360_link( self, request: analytics_admin.GetSearchAds360LinkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.GetSearchAds360LinkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.GetSearchAds360LinkRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_search_ads360_link Override in a subclass to manipulate the request or metadata @@ -3013,10 +3178,10 @@ def post_get_search_ads360_link( def pre_get_sk_ad_network_conversion_value_schema( self, request: analytics_admin.GetSKAdNetworkConversionValueSchemaRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ analytics_admin.GetSKAdNetworkConversionValueSchemaRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_sk_ad_network_conversion_value_schema @@ -3039,9 +3204,10 @@ def post_get_sk_ad_network_conversion_value_schema( def pre_get_subproperty_event_filter( self, request: analytics_admin.GetSubpropertyEventFilterRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.GetSubpropertyEventFilterRequest, Sequence[Tuple[str, str]] + analytics_admin.GetSubpropertyEventFilterRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_subproperty_event_filter @@ -3064,8 +3230,11 @@ def post_get_subproperty_event_filter( def pre_list_access_bindings( self, request: analytics_admin.ListAccessBindingsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.ListAccessBindingsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.ListAccessBindingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_access_bindings Override in a subclass to manipulate the request or metadata @@ -3087,8 +3256,10 @@ def post_list_access_bindings( def pre_list_accounts( self, request: analytics_admin.ListAccountsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.ListAccountsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.ListAccountsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_accounts Override in a subclass to manipulate the request or metadata @@ -3110,8 +3281,11 @@ def post_list_accounts( def pre_list_account_summaries( self, request: analytics_admin.ListAccountSummariesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.ListAccountSummariesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.ListAccountSummariesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_account_summaries Override in a subclass to manipulate the request or metadata @@ -3133,8 +3307,10 @@ def post_list_account_summaries( def pre_list_ad_sense_links( self, request: analytics_admin.ListAdSenseLinksRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.ListAdSenseLinksRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.ListAdSenseLinksRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_ad_sense_links Override in a subclass to manipulate the request or metadata @@ -3156,8 +3332,10 @@ def post_list_ad_sense_links( def pre_list_audiences( self, request: analytics_admin.ListAudiencesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.ListAudiencesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.ListAudiencesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_audiences Override in a subclass to manipulate the request or metadata @@ -3179,8 +3357,11 @@ def post_list_audiences( def pre_list_big_query_links( self, request: analytics_admin.ListBigQueryLinksRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.ListBigQueryLinksRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.ListBigQueryLinksRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_big_query_links Override in a subclass to manipulate the request or metadata @@ -3202,8 +3383,11 @@ def post_list_big_query_links( def pre_list_calculated_metrics( self, request: analytics_admin.ListCalculatedMetricsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.ListCalculatedMetricsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.ListCalculatedMetricsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_calculated_metrics Override in a subclass to manipulate the request or metadata @@ -3225,8 +3409,11 @@ def post_list_calculated_metrics( def pre_list_channel_groups( self, request: analytics_admin.ListChannelGroupsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.ListChannelGroupsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.ListChannelGroupsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_channel_groups Override in a subclass to manipulate the request or metadata @@ -3248,8 +3435,11 @@ def post_list_channel_groups( def pre_list_connected_site_tags( self, request: analytics_admin.ListConnectedSiteTagsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.ListConnectedSiteTagsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.ListConnectedSiteTagsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_connected_site_tags Override in a subclass to manipulate the request or metadata @@ -3271,8 +3461,11 @@ def post_list_connected_site_tags( def pre_list_conversion_events( self, request: analytics_admin.ListConversionEventsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.ListConversionEventsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.ListConversionEventsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_conversion_events Override in a subclass to manipulate the request or metadata @@ -3294,8 +3487,11 @@ def post_list_conversion_events( def pre_list_custom_dimensions( self, request: analytics_admin.ListCustomDimensionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.ListCustomDimensionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.ListCustomDimensionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_custom_dimensions Override in a subclass to manipulate the request or metadata @@ -3317,8 +3513,11 @@ def post_list_custom_dimensions( def pre_list_custom_metrics( self, request: analytics_admin.ListCustomMetricsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.ListCustomMetricsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.ListCustomMetricsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_custom_metrics Override in a subclass to manipulate the request or metadata @@ -3340,8 +3539,10 @@ def post_list_custom_metrics( def pre_list_data_streams( self, request: analytics_admin.ListDataStreamsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.ListDataStreamsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.ListDataStreamsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_data_streams Override in a subclass to manipulate the request or metadata @@ -3363,10 +3564,10 @@ def post_list_data_streams( def pre_list_display_video360_advertiser_link_proposals( self, request: analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_display_video360_advertiser_link_proposals @@ -3390,10 +3591,10 @@ def post_list_display_video360_advertiser_link_proposals( def pre_list_display_video360_advertiser_links( self, request: analytics_admin.ListDisplayVideo360AdvertiserLinksRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ analytics_admin.ListDisplayVideo360AdvertiserLinksRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_display_video360_advertiser_links @@ -3416,8 +3617,11 @@ def post_list_display_video360_advertiser_links( def pre_list_event_create_rules( self, request: analytics_admin.ListEventCreateRulesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.ListEventCreateRulesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.ListEventCreateRulesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_event_create_rules Override in a subclass to manipulate the request or metadata @@ -3439,8 +3643,11 @@ def post_list_event_create_rules( def pre_list_event_edit_rules( self, request: analytics_admin.ListEventEditRulesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.ListEventEditRulesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.ListEventEditRulesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_event_edit_rules Override in a subclass to manipulate the request or metadata @@ -3462,8 +3669,11 @@ def post_list_event_edit_rules( def pre_list_expanded_data_sets( self, request: analytics_admin.ListExpandedDataSetsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.ListExpandedDataSetsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.ListExpandedDataSetsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_expanded_data_sets Override in a subclass to manipulate the request or metadata @@ -3485,8 +3695,11 @@ def post_list_expanded_data_sets( def pre_list_firebase_links( self, request: analytics_admin.ListFirebaseLinksRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.ListFirebaseLinksRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.ListFirebaseLinksRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_firebase_links Override in a subclass to manipulate the request or metadata @@ -3508,8 +3721,11 @@ def post_list_firebase_links( def pre_list_google_ads_links( self, request: analytics_admin.ListGoogleAdsLinksRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.ListGoogleAdsLinksRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.ListGoogleAdsLinksRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_google_ads_links Override in a subclass to manipulate the request or metadata @@ -3531,8 +3747,10 @@ def post_list_google_ads_links( def pre_list_key_events( self, request: analytics_admin.ListKeyEventsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.ListKeyEventsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.ListKeyEventsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_key_events Override in a subclass to manipulate the request or metadata @@ -3554,9 +3772,10 @@ def post_list_key_events( def pre_list_measurement_protocol_secrets( self, request: analytics_admin.ListMeasurementProtocolSecretsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.ListMeasurementProtocolSecretsRequest, Sequence[Tuple[str, str]] + analytics_admin.ListMeasurementProtocolSecretsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_measurement_protocol_secrets @@ -3579,8 +3798,10 @@ def post_list_measurement_protocol_secrets( def pre_list_properties( self, request: analytics_admin.ListPropertiesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.ListPropertiesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.ListPropertiesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_properties Override in a subclass to manipulate the request or metadata @@ -3602,9 +3823,10 @@ def post_list_properties( def pre_list_rollup_property_source_links( self, request: analytics_admin.ListRollupPropertySourceLinksRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.ListRollupPropertySourceLinksRequest, Sequence[Tuple[str, str]] + analytics_admin.ListRollupPropertySourceLinksRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_rollup_property_source_links @@ -3627,8 +3849,11 @@ def post_list_rollup_property_source_links( def pre_list_search_ads360_links( self, request: analytics_admin.ListSearchAds360LinksRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.ListSearchAds360LinksRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.ListSearchAds360LinksRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_search_ads360_links Override in a subclass to manipulate the request or metadata @@ -3650,10 +3875,10 @@ def post_list_search_ads360_links( def pre_list_sk_ad_network_conversion_value_schemas( self, request: analytics_admin.ListSKAdNetworkConversionValueSchemasRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ analytics_admin.ListSKAdNetworkConversionValueSchemasRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_sk_ad_network_conversion_value_schemas @@ -3676,9 +3901,10 @@ def post_list_sk_ad_network_conversion_value_schemas( def pre_list_subproperty_event_filters( self, request: analytics_admin.ListSubpropertyEventFiltersRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.ListSubpropertyEventFiltersRequest, Sequence[Tuple[str, str]] + analytics_admin.ListSubpropertyEventFiltersRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_subproperty_event_filters @@ -3701,9 +3927,10 @@ def post_list_subproperty_event_filters( def pre_provision_account_ticket( self, request: analytics_admin.ProvisionAccountTicketRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.ProvisionAccountTicketRequest, Sequence[Tuple[str, str]] + analytics_admin.ProvisionAccountTicketRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for provision_account_ticket @@ -3726,8 +3953,11 @@ def post_provision_account_ticket( def pre_provision_subproperty( self, request: analytics_admin.ProvisionSubpropertyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.ProvisionSubpropertyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.ProvisionSubpropertyRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for provision_subproperty Override in a subclass to manipulate the request or metadata @@ -3749,8 +3979,11 @@ def post_provision_subproperty( def pre_reorder_event_edit_rules( self, request: analytics_admin.ReorderEventEditRulesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.ReorderEventEditRulesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.ReorderEventEditRulesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for reorder_event_edit_rules Override in a subclass to manipulate the request or metadata @@ -3761,8 +3994,10 @@ def pre_reorder_event_edit_rules( def pre_run_access_report( self, request: analytics_admin.RunAccessReportRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.RunAccessReportRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.RunAccessReportRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for run_access_report Override in a subclass to manipulate the request or metadata @@ -3784,9 +4019,10 @@ def post_run_access_report( def pre_search_change_history_events( self, request: analytics_admin.SearchChangeHistoryEventsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.SearchChangeHistoryEventsRequest, Sequence[Tuple[str, str]] + analytics_admin.SearchChangeHistoryEventsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for search_change_history_events @@ -3809,10 +4045,10 @@ def post_search_change_history_events( def pre_set_automated_ga4_configuration_opt_out( self, request: analytics_admin.SetAutomatedGa4ConfigurationOptOutRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ analytics_admin.SetAutomatedGa4ConfigurationOptOutRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for set_automated_ga4_configuration_opt_out @@ -3835,8 +4071,11 @@ def post_set_automated_ga4_configuration_opt_out( def pre_update_access_binding( self, request: analytics_admin.UpdateAccessBindingRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.UpdateAccessBindingRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.UpdateAccessBindingRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_access_binding Override in a subclass to manipulate the request or metadata @@ -3858,8 +4097,10 @@ def post_update_access_binding( def pre_update_account( self, request: analytics_admin.UpdateAccountRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.UpdateAccountRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.UpdateAccountRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_account Override in a subclass to manipulate the request or metadata @@ -3879,9 +4120,10 @@ def post_update_account(self, response: resources.Account) -> resources.Account: def pre_update_attribution_settings( self, request: analytics_admin.UpdateAttributionSettingsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.UpdateAttributionSettingsRequest, Sequence[Tuple[str, str]] + analytics_admin.UpdateAttributionSettingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_attribution_settings @@ -3904,8 +4146,10 @@ def post_update_attribution_settings( def pre_update_audience( self, request: analytics_admin.UpdateAudienceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.UpdateAudienceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.UpdateAudienceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_audience Override in a subclass to manipulate the request or metadata @@ -3927,8 +4171,11 @@ def post_update_audience( def pre_update_big_query_link( self, request: analytics_admin.UpdateBigQueryLinkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.UpdateBigQueryLinkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.UpdateBigQueryLinkRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_big_query_link Override in a subclass to manipulate the request or metadata @@ -3950,9 +4197,10 @@ def post_update_big_query_link( def pre_update_calculated_metric( self, request: analytics_admin.UpdateCalculatedMetricRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.UpdateCalculatedMetricRequest, Sequence[Tuple[str, str]] + analytics_admin.UpdateCalculatedMetricRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_calculated_metric @@ -3975,8 +4223,11 @@ def post_update_calculated_metric( def pre_update_channel_group( self, request: analytics_admin.UpdateChannelGroupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.UpdateChannelGroupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.UpdateChannelGroupRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_channel_group Override in a subclass to manipulate the request or metadata @@ -3998,8 +4249,11 @@ def post_update_channel_group( def pre_update_conversion_event( self, request: analytics_admin.UpdateConversionEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.UpdateConversionEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.UpdateConversionEventRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_conversion_event Override in a subclass to manipulate the request or metadata @@ -4021,8 +4275,11 @@ def post_update_conversion_event( def pre_update_custom_dimension( self, request: analytics_admin.UpdateCustomDimensionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.UpdateCustomDimensionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.UpdateCustomDimensionRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_custom_dimension Override in a subclass to manipulate the request or metadata @@ -4044,8 +4301,11 @@ def post_update_custom_dimension( def pre_update_custom_metric( self, request: analytics_admin.UpdateCustomMetricRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.UpdateCustomMetricRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.UpdateCustomMetricRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_custom_metric Override in a subclass to manipulate the request or metadata @@ -4067,9 +4327,10 @@ def post_update_custom_metric( def pre_update_data_redaction_settings( self, request: analytics_admin.UpdateDataRedactionSettingsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.UpdateDataRedactionSettingsRequest, Sequence[Tuple[str, str]] + analytics_admin.UpdateDataRedactionSettingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_data_redaction_settings @@ -4092,9 +4353,10 @@ def post_update_data_redaction_settings( def pre_update_data_retention_settings( self, request: analytics_admin.UpdateDataRetentionSettingsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.UpdateDataRetentionSettingsRequest, Sequence[Tuple[str, str]] + analytics_admin.UpdateDataRetentionSettingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_data_retention_settings @@ -4117,8 +4379,10 @@ def post_update_data_retention_settings( def pre_update_data_stream( self, request: analytics_admin.UpdateDataStreamRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.UpdateDataStreamRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.UpdateDataStreamRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_data_stream Override in a subclass to manipulate the request or metadata @@ -4140,10 +4404,10 @@ def post_update_data_stream( def pre_update_display_video360_advertiser_link( self, request: analytics_admin.UpdateDisplayVideo360AdvertiserLinkRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ analytics_admin.UpdateDisplayVideo360AdvertiserLinkRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_display_video360_advertiser_link @@ -4166,10 +4430,10 @@ def post_update_display_video360_advertiser_link( def pre_update_enhanced_measurement_settings( self, request: analytics_admin.UpdateEnhancedMeasurementSettingsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ analytics_admin.UpdateEnhancedMeasurementSettingsRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_enhanced_measurement_settings @@ -4192,8 +4456,11 @@ def post_update_enhanced_measurement_settings( def pre_update_event_create_rule( self, request: analytics_admin.UpdateEventCreateRuleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.UpdateEventCreateRuleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.UpdateEventCreateRuleRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_event_create_rule Override in a subclass to manipulate the request or metadata @@ -4215,8 +4482,11 @@ def post_update_event_create_rule( def pre_update_event_edit_rule( self, request: analytics_admin.UpdateEventEditRuleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.UpdateEventEditRuleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.UpdateEventEditRuleRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_event_edit_rule Override in a subclass to manipulate the request or metadata @@ -4238,8 +4508,11 @@ def post_update_event_edit_rule( def pre_update_expanded_data_set( self, request: analytics_admin.UpdateExpandedDataSetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.UpdateExpandedDataSetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.UpdateExpandedDataSetRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_expanded_data_set Override in a subclass to manipulate the request or metadata @@ -4261,8 +4534,11 @@ def post_update_expanded_data_set( def pre_update_google_ads_link( self, request: analytics_admin.UpdateGoogleAdsLinkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.UpdateGoogleAdsLinkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.UpdateGoogleAdsLinkRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_google_ads_link Override in a subclass to manipulate the request or metadata @@ -4284,9 +4560,10 @@ def post_update_google_ads_link( def pre_update_google_signals_settings( self, request: analytics_admin.UpdateGoogleSignalsSettingsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.UpdateGoogleSignalsSettingsRequest, Sequence[Tuple[str, str]] + analytics_admin.UpdateGoogleSignalsSettingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_google_signals_settings @@ -4309,8 +4586,10 @@ def post_update_google_signals_settings( def pre_update_key_event( self, request: analytics_admin.UpdateKeyEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.UpdateKeyEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.UpdateKeyEventRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_key_event Override in a subclass to manipulate the request or metadata @@ -4330,10 +4609,10 @@ def post_update_key_event(self, response: resources.KeyEvent) -> resources.KeyEv def pre_update_measurement_protocol_secret( self, request: analytics_admin.UpdateMeasurementProtocolSecretRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ analytics_admin.UpdateMeasurementProtocolSecretRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_measurement_protocol_secret @@ -4356,8 +4635,10 @@ def post_update_measurement_protocol_secret( def pre_update_property( self, request: analytics_admin.UpdatePropertyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.UpdatePropertyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.UpdatePropertyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_property Override in a subclass to manipulate the request or metadata @@ -4377,9 +4658,10 @@ def post_update_property(self, response: resources.Property) -> resources.Proper def pre_update_search_ads360_link( self, request: analytics_admin.UpdateSearchAds360LinkRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.UpdateSearchAds360LinkRequest, Sequence[Tuple[str, str]] + analytics_admin.UpdateSearchAds360LinkRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_search_ads360_link @@ -4402,10 +4684,10 @@ def post_update_search_ads360_link( def pre_update_sk_ad_network_conversion_value_schema( self, request: analytics_admin.UpdateSKAdNetworkConversionValueSchemaRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ analytics_admin.UpdateSKAdNetworkConversionValueSchemaRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_sk_ad_network_conversion_value_schema @@ -4428,9 +4710,10 @@ def post_update_sk_ad_network_conversion_value_schema( def pre_update_subproperty_event_filter( self, request: analytics_admin.UpdateSubpropertyEventFilterRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.UpdateSubpropertyEventFilterRequest, Sequence[Tuple[str, str]] + analytics_admin.UpdateSubpropertyEventFilterRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_subproperty_event_filter @@ -4575,7 +4858,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.AcknowledgeUserDataCollectionResponse: r"""Call the acknowledge user data collection method over HTTP. @@ -4587,8 +4870,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.AcknowledgeUserDataCollectionResponse: @@ -4600,6 +4885,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseAcknowledgeUserDataCollection._get_http_options() ) + request, metadata = self._interceptor.pre_acknowledge_user_data_collection( request, metadata ) @@ -4616,6 +4902,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.AcknowledgeUserDataCollection", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "AcknowledgeUserDataCollection", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._AcknowledgeUserDataCollection._get_response( self._host, @@ -4637,7 +4950,33 @@ def __call__( pb_resp = analytics_admin.AcknowledgeUserDataCollectionResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_acknowledge_user_data_collection(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.AcknowledgeUserDataCollectionResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.acknowledge_user_data_collection", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "AcknowledgeUserDataCollection", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ApproveDisplayVideo360AdvertiserLinkProposal( @@ -4678,7 +5017,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalResponse: r"""Call the approve display video360 advertiser link proposal method over HTTP. @@ -4691,8 +5030,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalResponse: @@ -4705,6 +5046,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseApproveDisplayVideo360AdvertiserLinkProposal._get_http_options() ) + ( request, metadata, @@ -4724,6 +5066,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.ApproveDisplayVideo360AdvertiserLinkProposal", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ApproveDisplayVideo360AdvertiserLinkProposal", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._ApproveDisplayVideo360AdvertiserLinkProposal._get_response( self._host, @@ -4751,9 +5120,33 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_approve_display_video360_advertiser_link_proposal( resp ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.approve_display_video360_advertiser_link_proposal", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ApproveDisplayVideo360AdvertiserLinkProposal", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ArchiveAudience( @@ -4792,7 +5185,7 @@ 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 archive audience method over HTTP. @@ -4803,13 +5196,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 = ( _BaseAnalyticsAdminServiceRestTransport._BaseArchiveAudience._get_http_options() ) + request, metadata = self._interceptor.pre_archive_audience( request, metadata ) @@ -4826,6 +5222,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.ArchiveAudience", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ArchiveAudience", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._ArchiveAudience._get_response( @@ -4880,7 +5303,7 @@ 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 archive custom dimension method over HTTP. @@ -4891,13 +5314,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 = ( _BaseAnalyticsAdminServiceRestTransport._BaseArchiveCustomDimension._get_http_options() ) + request, metadata = self._interceptor.pre_archive_custom_dimension( request, metadata ) @@ -4914,6 +5340,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.ArchiveCustomDimension", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ArchiveCustomDimension", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._ArchiveCustomDimension._get_response( self._host, @@ -4966,7 +5419,7 @@ 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 archive custom metric method over HTTP. @@ -4977,13 +5430,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 = ( _BaseAnalyticsAdminServiceRestTransport._BaseArchiveCustomMetric._get_http_options() ) + request, metadata = self._interceptor.pre_archive_custom_metric( request, metadata ) @@ -5000,6 +5456,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.ArchiveCustomMetric", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ArchiveCustomMetric", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._ArchiveCustomMetric._get_response( @@ -5054,7 +5537,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.BatchCreateAccessBindingsResponse: r"""Call the batch create access bindings method over HTTP. @@ -5066,8 +5549,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.BatchCreateAccessBindingsResponse: @@ -5079,6 +5564,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseBatchCreateAccessBindings._get_http_options() ) + request, metadata = self._interceptor.pre_batch_create_access_bindings( request, metadata ) @@ -5095,6 +5581,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.BatchCreateAccessBindings", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "BatchCreateAccessBindings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._BatchCreateAccessBindings._get_response( self._host, @@ -5116,7 +5629,33 @@ def __call__( pb_resp = analytics_admin.BatchCreateAccessBindingsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_create_access_bindings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.BatchCreateAccessBindingsResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.batch_create_access_bindings", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "BatchCreateAccessBindings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchDeleteAccessBindings( @@ -5155,7 +5694,7 @@ 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 delete access bindings method over HTTP. @@ -5167,13 +5706,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 = ( _BaseAnalyticsAdminServiceRestTransport._BaseBatchDeleteAccessBindings._get_http_options() ) + request, metadata = self._interceptor.pre_batch_delete_access_bindings( request, metadata ) @@ -5190,6 +5732,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.BatchDeleteAccessBindings", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "BatchDeleteAccessBindings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._BatchDeleteAccessBindings._get_response( self._host, @@ -5241,7 +5810,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.BatchGetAccessBindingsResponse: r"""Call the batch get access bindings method over HTTP. @@ -5252,8 +5821,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.BatchGetAccessBindingsResponse: @@ -5265,6 +5836,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseBatchGetAccessBindings._get_http_options() ) + request, metadata = self._interceptor.pre_batch_get_access_bindings( request, metadata ) @@ -5277,6 +5849,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.BatchGetAccessBindings", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "BatchGetAccessBindings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._BatchGetAccessBindings._get_response( self._host, @@ -5297,7 +5896,31 @@ def __call__( pb_resp = analytics_admin.BatchGetAccessBindingsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_get_access_bindings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.BatchGetAccessBindingsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.batch_get_access_bindings", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "BatchGetAccessBindings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchUpdateAccessBindings( @@ -5336,7 +5959,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.BatchUpdateAccessBindingsResponse: r"""Call the batch update access bindings method over HTTP. @@ -5348,8 +5971,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.BatchUpdateAccessBindingsResponse: @@ -5361,6 +5986,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseBatchUpdateAccessBindings._get_http_options() ) + request, metadata = self._interceptor.pre_batch_update_access_bindings( request, metadata ) @@ -5377,6 +6003,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.BatchUpdateAccessBindings", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "BatchUpdateAccessBindings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._BatchUpdateAccessBindings._get_response( self._host, @@ -5398,7 +6051,33 @@ def __call__( pb_resp = analytics_admin.BatchUpdateAccessBindingsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_update_access_bindings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.BatchUpdateAccessBindingsResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.batch_update_access_bindings", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "BatchUpdateAccessBindings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CancelDisplayVideo360AdvertiserLinkProposal( @@ -5439,7 +6118,7 @@ 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.DisplayVideo360AdvertiserLinkProposal: r"""Call the cancel display video360 advertiser link proposal method over HTTP. @@ -5452,8 +6131,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.DisplayVideo360AdvertiserLinkProposal: @@ -5473,6 +6154,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseCancelDisplayVideo360AdvertiserLinkProposal._get_http_options() ) + ( request, metadata, @@ -5492,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 = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.CancelDisplayVideo360AdvertiserLinkProposal", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CancelDisplayVideo360AdvertiserLinkProposal", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._CancelDisplayVideo360AdvertiserLinkProposal._get_response( self._host, @@ -5513,11 +6222,37 @@ def __call__( pb_resp = resources.DisplayVideo360AdvertiserLinkProposal.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = ( self._interceptor.post_cancel_display_video360_advertiser_link_proposal( resp ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + resources.DisplayVideo360AdvertiserLinkProposal.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.cancel_display_video360_advertiser_link_proposal", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CancelDisplayVideo360AdvertiserLinkProposal", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateAccessBinding( @@ -5556,7 +6291,7 @@ 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.AccessBinding: r"""Call the create access binding method over HTTP. @@ -5567,8 +6302,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.AccessBinding: @@ -5580,6 +6317,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseCreateAccessBinding._get_http_options() ) + request, metadata = self._interceptor.pre_create_access_binding( request, metadata ) @@ -5596,6 +6334,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.CreateAccessBinding", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateAccessBinding", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._CreateAccessBinding._get_response( @@ -5619,7 +6384,29 @@ def __call__( pb_resp = resources.AccessBinding.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_access_binding(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.AccessBinding.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_access_binding", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateAccessBinding", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateAdSenseLink( @@ -5658,7 +6445,7 @@ 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.AdSenseLink: r"""Call the create ad sense link method over HTTP. @@ -5669,8 +6456,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.AdSenseLink: @@ -5682,6 +6471,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseCreateAdSenseLink._get_http_options() ) + request, metadata = self._interceptor.pre_create_ad_sense_link( request, metadata ) @@ -5698,6 +6488,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.CreateAdSenseLink", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateAdSenseLink", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._CreateAdSenseLink._get_response( @@ -5721,7 +6538,29 @@ def __call__( pb_resp = resources.AdSenseLink.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_ad_sense_link(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.AdSenseLink.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_ad_sense_link", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateAdSenseLink", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateAudience( @@ -5760,7 +6599,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gaa_audience.Audience: r"""Call the create audience method over HTTP. @@ -5771,8 +6610,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gaa_audience.Audience: @@ -5784,6 +6625,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseCreateAudience._get_http_options() ) + request, metadata = self._interceptor.pre_create_audience(request, metadata) transcoded_request = _BaseAnalyticsAdminServiceRestTransport._BaseCreateAudience._get_transcoded_request( http_options, request @@ -5798,6 +6640,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.CreateAudience", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateAudience", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._CreateAudience._get_response( self._host, @@ -5819,7 +6688,29 @@ def __call__( pb_resp = gaa_audience.Audience.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_audience(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gaa_audience.Audience.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_audience", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateAudience", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateBigQueryLink( @@ -5858,7 +6749,7 @@ 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.BigQueryLink: r"""Call the create big query link method over HTTP. @@ -5869,8 +6760,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.BigQueryLink: @@ -5882,6 +6775,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseCreateBigQueryLink._get_http_options() ) + request, metadata = self._interceptor.pre_create_big_query_link( request, metadata ) @@ -5898,7 +6792,34 @@ def __call__( transcoded_request ) - # Send the request + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.CreateBigQueryLink", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateBigQueryLink", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + + # Send the request response = ( AnalyticsAdminServiceRestTransport._CreateBigQueryLink._get_response( self._host, @@ -5921,7 +6842,29 @@ def __call__( pb_resp = resources.BigQueryLink.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_big_query_link(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.BigQueryLink.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_big_query_link", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateBigQueryLink", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateCalculatedMetric( @@ -5960,7 +6903,7 @@ 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.CalculatedMetric: r"""Call the create calculated metric method over HTTP. @@ -5971,8 +6914,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.CalculatedMetric: @@ -5982,6 +6927,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseCreateCalculatedMetric._get_http_options() ) + request, metadata = self._interceptor.pre_create_calculated_metric( request, metadata ) @@ -5998,6 +6944,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.CreateCalculatedMetric", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateCalculatedMetric", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._CreateCalculatedMetric._get_response( self._host, @@ -6019,7 +6992,29 @@ def __call__( pb_resp = resources.CalculatedMetric.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_calculated_metric(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.CalculatedMetric.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_calculated_metric", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateCalculatedMetric", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateChannelGroup( @@ -6058,7 +7053,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gaa_channel_group.ChannelGroup: r"""Call the create channel group method over HTTP. @@ -6069,8 +7064,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gaa_channel_group.ChannelGroup: @@ -6082,6 +7079,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseCreateChannelGroup._get_http_options() ) + request, metadata = self._interceptor.pre_create_channel_group( request, metadata ) @@ -6098,6 +7096,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.CreateChannelGroup", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateChannelGroup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._CreateChannelGroup._get_response( @@ -6121,7 +7146,29 @@ def __call__( pb_resp = gaa_channel_group.ChannelGroup.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_channel_group(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gaa_channel_group.ChannelGroup.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_channel_group", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateChannelGroup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateConnectedSiteTag( @@ -6160,7 +7207,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.CreateConnectedSiteTagResponse: r"""Call the create connected site tag method over HTTP. @@ -6171,8 +7218,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.CreateConnectedSiteTagResponse: @@ -6184,6 +7233,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseCreateConnectedSiteTag._get_http_options() ) + request, metadata = self._interceptor.pre_create_connected_site_tag( request, metadata ) @@ -6200,6 +7250,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.CreateConnectedSiteTag", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateConnectedSiteTag", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._CreateConnectedSiteTag._get_response( self._host, @@ -6221,7 +7298,31 @@ def __call__( pb_resp = analytics_admin.CreateConnectedSiteTagResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_connected_site_tag(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.CreateConnectedSiteTagResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_connected_site_tag", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateConnectedSiteTag", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateConversionEvent( @@ -6260,7 +7361,7 @@ 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.ConversionEvent: r"""Call the create conversion event method over HTTP. @@ -6271,8 +7372,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ConversionEvent: @@ -6284,6 +7387,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseCreateConversionEvent._get_http_options() ) + request, metadata = self._interceptor.pre_create_conversion_event( request, metadata ) @@ -6300,6 +7404,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.CreateConversionEvent", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateConversionEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._CreateConversionEvent._get_response( @@ -6323,7 +7454,29 @@ def __call__( pb_resp = resources.ConversionEvent.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_conversion_event(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.ConversionEvent.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_conversion_event", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateConversionEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateCustomDimension( @@ -6362,7 +7515,7 @@ 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.CustomDimension: r"""Call the create custom dimension method over HTTP. @@ -6373,8 +7526,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.CustomDimension: @@ -6384,6 +7539,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseCreateCustomDimension._get_http_options() ) + request, metadata = self._interceptor.pre_create_custom_dimension( request, metadata ) @@ -6400,6 +7556,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.CreateCustomDimension", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateCustomDimension", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._CreateCustomDimension._get_response( @@ -6423,7 +7606,29 @@ def __call__( pb_resp = resources.CustomDimension.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_custom_dimension(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.CustomDimension.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_custom_dimension", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateCustomDimension", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateCustomMetric( @@ -6462,7 +7667,7 @@ 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.CustomMetric: r"""Call the create custom metric method over HTTP. @@ -6473,8 +7678,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.CustomMetric: @@ -6484,6 +7691,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseCreateCustomMetric._get_http_options() ) + request, metadata = self._interceptor.pre_create_custom_metric( request, metadata ) @@ -6500,6 +7708,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.CreateCustomMetric", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateCustomMetric", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._CreateCustomMetric._get_response( @@ -6523,7 +7758,29 @@ def __call__( pb_resp = resources.CustomMetric.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_custom_metric(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.CustomMetric.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_custom_metric", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateCustomMetric", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateDataStream( @@ -6562,7 +7819,7 @@ 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.DataStream: r"""Call the create data stream method over HTTP. @@ -6573,8 +7830,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.DataStream: @@ -6586,6 +7845,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseCreateDataStream._get_http_options() ) + request, metadata = self._interceptor.pre_create_data_stream( request, metadata ) @@ -6602,6 +7862,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.CreateDataStream", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateDataStream", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._CreateDataStream._get_response( @@ -6625,7 +7912,29 @@ def __call__( pb_resp = resources.DataStream.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_data_stream(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.DataStream.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_data_stream", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateDataStream", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateDisplayVideo360AdvertiserLink( @@ -6666,7 +7975,7 @@ 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.DisplayVideo360AdvertiserLink: r"""Call the create display video360 advertiser link method over HTTP. @@ -6678,8 +7987,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.DisplayVideo360AdvertiserLink: @@ -6691,6 +8002,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseCreateDisplayVideo360AdvertiserLink._get_http_options() ) + ( request, metadata, @@ -6710,6 +8022,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.CreateDisplayVideo360AdvertiserLink", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateDisplayVideo360AdvertiserLink", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._CreateDisplayVideo360AdvertiserLink._get_response( self._host, @@ -6731,7 +8070,31 @@ def __call__( pb_resp = resources.DisplayVideo360AdvertiserLink.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_display_video360_advertiser_link(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.DisplayVideo360AdvertiserLink.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_display_video360_advertiser_link", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateDisplayVideo360AdvertiserLink", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateDisplayVideo360AdvertiserLinkProposal( @@ -6772,7 +8135,7 @@ 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.DisplayVideo360AdvertiserLinkProposal: r"""Call the create display video360 advertiser link proposal method over HTTP. @@ -6785,8 +8148,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.DisplayVideo360AdvertiserLinkProposal: @@ -6806,6 +8171,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseCreateDisplayVideo360AdvertiserLinkProposal._get_http_options() ) + ( request, metadata, @@ -6825,6 +8191,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.CreateDisplayVideo360AdvertiserLinkProposal", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateDisplayVideo360AdvertiserLinkProposal", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._CreateDisplayVideo360AdvertiserLinkProposal._get_response( self._host, @@ -6846,11 +8239,37 @@ def __call__( pb_resp = resources.DisplayVideo360AdvertiserLinkProposal.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = ( self._interceptor.post_create_display_video360_advertiser_link_proposal( resp ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + resources.DisplayVideo360AdvertiserLinkProposal.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_display_video360_advertiser_link_proposal", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateDisplayVideo360AdvertiserLinkProposal", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateEventCreateRule( @@ -6889,7 +8308,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> event_create_and_edit.EventCreateRule: r"""Call the create event create rule method over HTTP. @@ -6900,8 +8319,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.event_create_and_edit.EventCreateRule: @@ -6925,6 +8346,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseCreateEventCreateRule._get_http_options() ) + request, metadata = self._interceptor.pre_create_event_create_rule( request, metadata ) @@ -6941,6 +8363,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.CreateEventCreateRule", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateEventCreateRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._CreateEventCreateRule._get_response( @@ -6964,7 +8413,31 @@ def __call__( pb_resp = event_create_and_edit.EventCreateRule.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_event_create_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = event_create_and_edit.EventCreateRule.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_event_create_rule", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateEventCreateRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateEventEditRule( @@ -7003,7 +8476,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> event_create_and_edit.EventEditRule: r"""Call the create event edit rule method over HTTP. @@ -7014,8 +8487,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.event_create_and_edit.EventEditRule: @@ -7039,6 +8514,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseCreateEventEditRule._get_http_options() ) + request, metadata = self._interceptor.pre_create_event_edit_rule( request, metadata ) @@ -7055,6 +8531,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.CreateEventEditRule", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateEventEditRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._CreateEventEditRule._get_response( @@ -7078,7 +8581,31 @@ def __call__( pb_resp = event_create_and_edit.EventEditRule.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_event_edit_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = event_create_and_edit.EventEditRule.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_event_edit_rule", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateEventEditRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateExpandedDataSet( @@ -7117,7 +8644,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gaa_expanded_data_set.ExpandedDataSet: r"""Call the create expanded data set method over HTTP. @@ -7128,8 +8655,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gaa_expanded_data_set.ExpandedDataSet: @@ -7141,6 +8670,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseCreateExpandedDataSet._get_http_options() ) + request, metadata = self._interceptor.pre_create_expanded_data_set( request, metadata ) @@ -7157,6 +8687,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.CreateExpandedDataSet", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateExpandedDataSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._CreateExpandedDataSet._get_response( @@ -7180,7 +8737,31 @@ def __call__( pb_resp = gaa_expanded_data_set.ExpandedDataSet.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_expanded_data_set(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gaa_expanded_data_set.ExpandedDataSet.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_expanded_data_set", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateExpandedDataSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateFirebaseLink( @@ -7219,7 +8800,7 @@ 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.FirebaseLink: r"""Call the create firebase link method over HTTP. @@ -7230,8 +8811,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.FirebaseLink: @@ -7243,6 +8826,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseCreateFirebaseLink._get_http_options() ) + request, metadata = self._interceptor.pre_create_firebase_link( request, metadata ) @@ -7259,6 +8843,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.CreateFirebaseLink", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateFirebaseLink", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._CreateFirebaseLink._get_response( @@ -7282,7 +8893,29 @@ def __call__( pb_resp = resources.FirebaseLink.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_firebase_link(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.FirebaseLink.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_firebase_link", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateFirebaseLink", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateGoogleAdsLink( @@ -7321,7 +8954,7 @@ 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.GoogleAdsLink: r"""Call the create google ads link method over HTTP. @@ -7332,8 +8965,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.GoogleAdsLink: @@ -7345,6 +8980,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseCreateGoogleAdsLink._get_http_options() ) + request, metadata = self._interceptor.pre_create_google_ads_link( request, metadata ) @@ -7361,6 +8997,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.CreateGoogleAdsLink", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateGoogleAdsLink", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._CreateGoogleAdsLink._get_response( @@ -7384,7 +9047,29 @@ def __call__( pb_resp = resources.GoogleAdsLink.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_google_ads_link(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.GoogleAdsLink.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_google_ads_link", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateGoogleAdsLink", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateKeyEvent( @@ -7423,7 +9108,7 @@ 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.KeyEvent: r"""Call the create key event method over HTTP. @@ -7434,8 +9119,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.KeyEvent: @@ -7447,6 +9134,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseCreateKeyEvent._get_http_options() ) + request, metadata = self._interceptor.pre_create_key_event( request, metadata ) @@ -7463,6 +9151,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.CreateKeyEvent", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateKeyEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._CreateKeyEvent._get_response( self._host, @@ -7484,7 +9199,29 @@ def __call__( pb_resp = resources.KeyEvent.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_key_event(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.KeyEvent.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_key_event", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateKeyEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateMeasurementProtocolSecret( @@ -7525,7 +9262,7 @@ 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.MeasurementProtocolSecret: r"""Call the create measurement protocol secret method over HTTP. @@ -7537,8 +9274,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.MeasurementProtocolSecret: @@ -7550,6 +9289,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseCreateMeasurementProtocolSecret._get_http_options() ) + ( request, metadata, @@ -7569,6 +9309,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.CreateMeasurementProtocolSecret", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateMeasurementProtocolSecret", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._CreateMeasurementProtocolSecret._get_response( self._host, @@ -7590,7 +9357,31 @@ def __call__( pb_resp = resources.MeasurementProtocolSecret.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_measurement_protocol_secret(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.MeasurementProtocolSecret.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_measurement_protocol_secret", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateMeasurementProtocolSecret", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateProperty( @@ -7629,7 +9420,7 @@ 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.Property: r"""Call the create property method over HTTP. @@ -7640,8 +9431,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.Property: @@ -7653,6 +9446,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseCreateProperty._get_http_options() ) + request, metadata = self._interceptor.pre_create_property(request, metadata) transcoded_request = _BaseAnalyticsAdminServiceRestTransport._BaseCreateProperty._get_transcoded_request( http_options, request @@ -7667,6 +9461,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.CreateProperty", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateProperty", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._CreateProperty._get_response( self._host, @@ -7688,7 +9509,29 @@ def __call__( pb_resp = resources.Property.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_property(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Property.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_property", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateProperty", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateRollupProperty( @@ -7727,7 +9570,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.CreateRollupPropertyResponse: r"""Call the create rollup property method over HTTP. @@ -7738,8 +9581,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.CreateRollupPropertyResponse: @@ -7751,6 +9596,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseCreateRollupProperty._get_http_options() ) + request, metadata = self._interceptor.pre_create_rollup_property( request, metadata ) @@ -7767,6 +9613,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.CreateRollupProperty", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateRollupProperty", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._CreateRollupProperty._get_response( @@ -7790,7 +9663,31 @@ def __call__( pb_resp = analytics_admin.CreateRollupPropertyResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_rollup_property(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.CreateRollupPropertyResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_rollup_property", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateRollupProperty", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateRollupPropertySourceLink( @@ -7831,7 +9728,7 @@ 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.RollupPropertySourceLink: r"""Call the create rollup property source link method over HTTP. @@ -7843,8 +9740,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.RollupPropertySourceLink: @@ -7857,6 +9756,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseCreateRollupPropertySourceLink._get_http_options() ) + ( request, metadata, @@ -7876,6 +9776,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.CreateRollupPropertySourceLink", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateRollupPropertySourceLink", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._CreateRollupPropertySourceLink._get_response( self._host, @@ -7897,7 +9824,31 @@ def __call__( pb_resp = resources.RollupPropertySourceLink.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_rollup_property_source_link(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.RollupPropertySourceLink.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_rollup_property_source_link", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateRollupPropertySourceLink", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSearchAds360Link( @@ -7936,7 +9887,7 @@ 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.SearchAds360Link: r"""Call the create search ads360 link method over HTTP. @@ -7947,8 +9898,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.SearchAds360Link: @@ -7960,6 +9913,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseCreateSearchAds360Link._get_http_options() ) + request, metadata = self._interceptor.pre_create_search_ads360_link( request, metadata ) @@ -7976,6 +9930,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.CreateSearchAds360Link", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateSearchAds360Link", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._CreateSearchAds360Link._get_response( self._host, @@ -7997,7 +9978,29 @@ def __call__( pb_resp = resources.SearchAds360Link.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_search_ads360_link(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.SearchAds360Link.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_search_ads360_link", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateSearchAds360Link", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSKAdNetworkConversionValueSchema( @@ -8038,7 +10041,7 @@ 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.SKAdNetworkConversionValueSchema: r"""Call the create sk ad network conversion value schema method over HTTP. @@ -8051,8 +10054,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.SKAdNetworkConversionValueSchema: @@ -8064,6 +10069,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseCreateSKAdNetworkConversionValueSchema._get_http_options() ) + ( request, metadata, @@ -8083,6 +10089,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.CreateSKAdNetworkConversionValueSchema", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateSKAdNetworkConversionValueSchema", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._CreateSKAdNetworkConversionValueSchema._get_response( self._host, @@ -8104,9 +10137,33 @@ def __call__( pb_resp = resources.SKAdNetworkConversionValueSchema.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_sk_ad_network_conversion_value_schema( resp ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + resources.SKAdNetworkConversionValueSchema.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_sk_ad_network_conversion_value_schema", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateSKAdNetworkConversionValueSchema", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSubpropertyEventFilter( @@ -8147,7 +10204,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gaa_subproperty_event_filter.SubpropertyEventFilter: r"""Call the create subproperty event filter method over HTTP. @@ -8159,8 +10216,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gaa_subproperty_event_filter.SubpropertyEventFilter: @@ -8172,6 +10231,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseCreateSubpropertyEventFilter._get_http_options() ) + request, metadata = self._interceptor.pre_create_subproperty_event_filter( request, metadata ) @@ -8188,6 +10248,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.CreateSubpropertyEventFilter", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateSubpropertyEventFilter", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._CreateSubpropertyEventFilter._get_response( self._host, @@ -8209,7 +10296,33 @@ def __call__( pb_resp = gaa_subproperty_event_filter.SubpropertyEventFilter.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_subproperty_event_filter(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + gaa_subproperty_event_filter.SubpropertyEventFilter.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.create_subproperty_event_filter", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "CreateSubpropertyEventFilter", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteAccessBinding( @@ -8247,7 +10360,7 @@ 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 access binding method over HTTP. @@ -8258,13 +10371,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 = ( _BaseAnalyticsAdminServiceRestTransport._BaseDeleteAccessBinding._get_http_options() ) + request, metadata = self._interceptor.pre_delete_access_binding( request, metadata ) @@ -8277,6 +10393,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.DeleteAccessBinding", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "DeleteAccessBinding", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._DeleteAccessBinding._get_response( @@ -8329,7 +10472,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete account method over HTTP. @@ -8340,13 +10483,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 = ( _BaseAnalyticsAdminServiceRestTransport._BaseDeleteAccount._get_http_options() ) + request, metadata = self._interceptor.pre_delete_account(request, metadata) transcoded_request = _BaseAnalyticsAdminServiceRestTransport._BaseDeleteAccount._get_transcoded_request( http_options, request @@ -8357,6 +10503,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.DeleteAccount", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "DeleteAccount", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._DeleteAccount._get_response( self._host, @@ -8407,7 +10580,7 @@ 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 ad sense link method over HTTP. @@ -8418,13 +10591,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 = ( _BaseAnalyticsAdminServiceRestTransport._BaseDeleteAdSenseLink._get_http_options() ) + request, metadata = self._interceptor.pre_delete_ad_sense_link( request, metadata ) @@ -8437,6 +10613,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.DeleteAdSenseLink", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "DeleteAdSenseLink", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._DeleteAdSenseLink._get_response( @@ -8489,7 +10692,7 @@ 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 big query link method over HTTP. @@ -8500,13 +10703,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 = ( _BaseAnalyticsAdminServiceRestTransport._BaseDeleteBigQueryLink._get_http_options() ) + request, metadata = self._interceptor.pre_delete_big_query_link( request, metadata ) @@ -8519,6 +10725,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.DeleteBigQueryLink", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "DeleteBigQueryLink", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._DeleteBigQueryLink._get_response( @@ -8571,7 +10804,7 @@ 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 calculated metric method over HTTP. @@ -8582,13 +10815,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 = ( _BaseAnalyticsAdminServiceRestTransport._BaseDeleteCalculatedMetric._get_http_options() ) + request, metadata = self._interceptor.pre_delete_calculated_metric( request, metadata ) @@ -8601,6 +10837,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.DeleteCalculatedMetric", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "DeleteCalculatedMetric", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._DeleteCalculatedMetric._get_response( self._host, @@ -8651,7 +10914,7 @@ 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 channel group method over HTTP. @@ -8662,13 +10925,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 = ( _BaseAnalyticsAdminServiceRestTransport._BaseDeleteChannelGroup._get_http_options() ) + request, metadata = self._interceptor.pre_delete_channel_group( request, metadata ) @@ -8681,6 +10947,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.DeleteChannelGroup", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "DeleteChannelGroup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._DeleteChannelGroup._get_response( @@ -8734,7 +11027,7 @@ 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 connected site tag method over HTTP. @@ -8745,13 +11038,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 = ( _BaseAnalyticsAdminServiceRestTransport._BaseDeleteConnectedSiteTag._get_http_options() ) + request, metadata = self._interceptor.pre_delete_connected_site_tag( request, metadata ) @@ -8768,6 +11064,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.DeleteConnectedSiteTag", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "DeleteConnectedSiteTag", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._DeleteConnectedSiteTag._get_response( self._host, @@ -8819,7 +11142,7 @@ 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 conversion event method over HTTP. @@ -8830,13 +11153,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 = ( _BaseAnalyticsAdminServiceRestTransport._BaseDeleteConversionEvent._get_http_options() ) + request, metadata = self._interceptor.pre_delete_conversion_event( request, metadata ) @@ -8849,6 +11175,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.DeleteConversionEvent", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "DeleteConversionEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._DeleteConversionEvent._get_response( @@ -8901,7 +11254,7 @@ 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 stream method over HTTP. @@ -8912,13 +11265,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 = ( _BaseAnalyticsAdminServiceRestTransport._BaseDeleteDataStream._get_http_options() ) + request, metadata = self._interceptor.pre_delete_data_stream( request, metadata ) @@ -8931,6 +11287,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.DeleteDataStream", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "DeleteDataStream", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._DeleteDataStream._get_response( @@ -8985,7 +11368,7 @@ 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 display video360 advertiser link method over HTTP. @@ -8997,13 +11380,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 = ( _BaseAnalyticsAdminServiceRestTransport._BaseDeleteDisplayVideo360AdvertiserLink._get_http_options() ) + ( request, metadata, @@ -9019,6 +11405,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.DeleteDisplayVideo360AdvertiserLink", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "DeleteDisplayVideo360AdvertiserLink", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._DeleteDisplayVideo360AdvertiserLink._get_response( self._host, @@ -9071,7 +11484,7 @@ 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 display video360 advertiser link proposal method over HTTP. @@ -9084,13 +11497,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 = ( _BaseAnalyticsAdminServiceRestTransport._BaseDeleteDisplayVideo360AdvertiserLinkProposal._get_http_options() ) + ( request, metadata, @@ -9106,6 +11522,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.DeleteDisplayVideo360AdvertiserLinkProposal", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "DeleteDisplayVideo360AdvertiserLinkProposal", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._DeleteDisplayVideo360AdvertiserLinkProposal._get_response( self._host, @@ -9156,7 +11599,7 @@ 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 create rule method over HTTP. @@ -9167,13 +11610,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 = ( _BaseAnalyticsAdminServiceRestTransport._BaseDeleteEventCreateRule._get_http_options() ) + request, metadata = self._interceptor.pre_delete_event_create_rule( request, metadata ) @@ -9186,6 +11632,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.DeleteEventCreateRule", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "DeleteEventCreateRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._DeleteEventCreateRule._get_response( @@ -9238,7 +11711,7 @@ 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 edit rule method over HTTP. @@ -9249,13 +11722,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 = ( _BaseAnalyticsAdminServiceRestTransport._BaseDeleteEventEditRule._get_http_options() ) + request, metadata = self._interceptor.pre_delete_event_edit_rule( request, metadata ) @@ -9268,6 +11744,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.DeleteEventEditRule", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "DeleteEventEditRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._DeleteEventEditRule._get_response( @@ -9320,7 +11823,7 @@ 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 expanded data set method over HTTP. @@ -9331,13 +11834,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 = ( _BaseAnalyticsAdminServiceRestTransport._BaseDeleteExpandedDataSet._get_http_options() ) + request, metadata = self._interceptor.pre_delete_expanded_data_set( request, metadata ) @@ -9350,6 +11856,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.DeleteExpandedDataSet", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "DeleteExpandedDataSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._DeleteExpandedDataSet._get_response( @@ -9402,7 +11935,7 @@ 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 firebase link method over HTTP. @@ -9413,13 +11946,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 = ( _BaseAnalyticsAdminServiceRestTransport._BaseDeleteFirebaseLink._get_http_options() ) + request, metadata = self._interceptor.pre_delete_firebase_link( request, metadata ) @@ -9432,6 +11968,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.DeleteFirebaseLink", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "DeleteFirebaseLink", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._DeleteFirebaseLink._get_response( @@ -9484,7 +12047,7 @@ 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 google ads link method over HTTP. @@ -9495,13 +12058,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 = ( _BaseAnalyticsAdminServiceRestTransport._BaseDeleteGoogleAdsLink._get_http_options() ) + request, metadata = self._interceptor.pre_delete_google_ads_link( request, metadata ) @@ -9514,6 +12080,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.DeleteGoogleAdsLink", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "DeleteGoogleAdsLink", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._DeleteGoogleAdsLink._get_response( @@ -9566,7 +12159,7 @@ 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 key event method over HTTP. @@ -9577,13 +12170,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 = ( _BaseAnalyticsAdminServiceRestTransport._BaseDeleteKeyEvent._get_http_options() ) + request, metadata = self._interceptor.pre_delete_key_event( request, metadata ) @@ -9596,6 +12192,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.DeleteKeyEvent", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "DeleteKeyEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._DeleteKeyEvent._get_response( self._host, @@ -9648,7 +12271,7 @@ 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 measurement protocol secret method over HTTP. @@ -9660,13 +12283,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 = ( _BaseAnalyticsAdminServiceRestTransport._BaseDeleteMeasurementProtocolSecret._get_http_options() ) + ( request, metadata, @@ -9682,6 +12308,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.DeleteMeasurementProtocolSecret", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "DeleteMeasurementProtocolSecret", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._DeleteMeasurementProtocolSecret._get_response( self._host, @@ -9732,7 +12385,7 @@ 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.Property: r"""Call the delete property method over HTTP. @@ -9743,8 +12396,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.Property: @@ -9756,6 +12411,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseDeleteProperty._get_http_options() ) + request, metadata = self._interceptor.pre_delete_property(request, metadata) transcoded_request = _BaseAnalyticsAdminServiceRestTransport._BaseDeleteProperty._get_transcoded_request( http_options, request @@ -9766,6 +12422,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.DeleteProperty", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "DeleteProperty", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._DeleteProperty._get_response( self._host, @@ -9786,7 +12469,29 @@ def __call__( pb_resp = resources.Property.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_property(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Property.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.delete_property", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "DeleteProperty", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteRollupPropertySourceLink( @@ -9826,7 +12531,7 @@ 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 rollup property source link method over HTTP. @@ -9838,13 +12543,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 = ( _BaseAnalyticsAdminServiceRestTransport._BaseDeleteRollupPropertySourceLink._get_http_options() ) + ( request, metadata, @@ -9860,6 +12568,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.DeleteRollupPropertySourceLink", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "DeleteRollupPropertySourceLink", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._DeleteRollupPropertySourceLink._get_response( self._host, @@ -9910,7 +12645,7 @@ 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 ads360 link method over HTTP. @@ -9921,13 +12656,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 = ( _BaseAnalyticsAdminServiceRestTransport._BaseDeleteSearchAds360Link._get_http_options() ) + request, metadata = self._interceptor.pre_delete_search_ads360_link( request, metadata ) @@ -9940,6 +12678,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.DeleteSearchAds360Link", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "DeleteSearchAds360Link", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._DeleteSearchAds360Link._get_response( self._host, @@ -9992,7 +12757,7 @@ 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 sk ad network conversion value schema method over HTTP. @@ -10005,13 +12770,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 = ( _BaseAnalyticsAdminServiceRestTransport._BaseDeleteSKAdNetworkConversionValueSchema._get_http_options() ) + ( request, metadata, @@ -10027,6 +12795,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.DeleteSKAdNetworkConversionValueSchema", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "DeleteSKAdNetworkConversionValueSchema", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._DeleteSKAdNetworkConversionValueSchema._get_response( self._host, @@ -10079,7 +12874,7 @@ 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 subproperty event filter method over HTTP. @@ -10091,13 +12886,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 = ( _BaseAnalyticsAdminServiceRestTransport._BaseDeleteSubpropertyEventFilter._get_http_options() ) + request, metadata = self._interceptor.pre_delete_subproperty_event_filter( request, metadata ) @@ -10110,6 +12908,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.DeleteSubpropertyEventFilter", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "DeleteSubpropertyEventFilter", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._DeleteSubpropertyEventFilter._get_response( self._host, @@ -10163,7 +12988,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.FetchAutomatedGa4ConfigurationOptOutResponse: r"""Call the fetch automated ga4 configuration opt out method over HTTP. @@ -10176,8 +13001,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.FetchAutomatedGa4ConfigurationOptOutResponse: @@ -10190,6 +13017,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseFetchAutomatedGa4ConfigurationOptOut._get_http_options() ) + ( request, metadata, @@ -10209,6 +13037,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.FetchAutomatedGa4ConfigurationOptOut", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "FetchAutomatedGa4ConfigurationOptOut", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._FetchAutomatedGa4ConfigurationOptOut._get_response( self._host, @@ -10232,9 +13087,33 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_fetch_automated_ga4_configuration_opt_out( resp ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = analytics_admin.FetchAutomatedGa4ConfigurationOptOutResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.fetch_automated_ga4_configuration_opt_out", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "FetchAutomatedGa4ConfigurationOptOut", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _FetchConnectedGa4Property( @@ -10272,7 +13151,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.FetchConnectedGa4PropertyResponse: r"""Call the fetch connected ga4 property method over HTTP. @@ -10284,8 +13163,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.FetchConnectedGa4PropertyResponse: @@ -10297,6 +13178,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseFetchConnectedGa4Property._get_http_options() ) + request, metadata = self._interceptor.pre_fetch_connected_ga4_property( request, metadata ) @@ -10309,6 +13191,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.FetchConnectedGa4Property", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "FetchConnectedGa4Property", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._FetchConnectedGa4Property._get_response( self._host, @@ -10329,7 +13238,33 @@ def __call__( pb_resp = analytics_admin.FetchConnectedGa4PropertyResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_fetch_connected_ga4_property(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.FetchConnectedGa4PropertyResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.fetch_connected_ga4_property", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "FetchConnectedGa4Property", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAccessBinding( @@ -10367,7 +13302,7 @@ 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.AccessBinding: r"""Call the get access binding method over HTTP. @@ -10378,8 +13313,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.AccessBinding: @@ -10391,6 +13328,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetAccessBinding._get_http_options() ) + request, metadata = self._interceptor.pre_get_access_binding( request, metadata ) @@ -10403,6 +13341,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.GetAccessBinding", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetAccessBinding", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._GetAccessBinding._get_response( @@ -10425,7 +13390,29 @@ def __call__( pb_resp = resources.AccessBinding.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_access_binding(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.AccessBinding.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_access_binding", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetAccessBinding", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAccount( @@ -10463,7 +13450,7 @@ 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.Account: r"""Call the get account method over HTTP. @@ -10473,8 +13460,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.Account: @@ -10486,6 +13475,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetAccount._get_http_options() ) + request, metadata = self._interceptor.pre_get_account(request, metadata) transcoded_request = _BaseAnalyticsAdminServiceRestTransport._BaseGetAccount._get_transcoded_request( http_options, request @@ -10496,6 +13486,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.GetAccount", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetAccount", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._GetAccount._get_response( self._host, @@ -10516,7 +13533,29 @@ def __call__( pb_resp = resources.Account.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_account(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Account.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_account", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetAccount", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAdSenseLink( @@ -10554,7 +13593,7 @@ 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.AdSenseLink: r"""Call the get ad sense link method over HTTP. @@ -10565,8 +13604,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.AdSenseLink: @@ -10578,6 +13619,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetAdSenseLink._get_http_options() ) + request, metadata = self._interceptor.pre_get_ad_sense_link( request, metadata ) @@ -10590,6 +13632,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.GetAdSenseLink", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetAdSenseLink", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._GetAdSenseLink._get_response( self._host, @@ -10610,7 +13679,29 @@ def __call__( pb_resp = resources.AdSenseLink.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_ad_sense_link(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.AdSenseLink.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_ad_sense_link", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetAdSenseLink", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAttributionSettings( @@ -10648,7 +13739,7 @@ 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.AttributionSettings: r"""Call the get attribution settings method over HTTP. @@ -10659,8 +13750,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.AttributionSettings: @@ -10673,6 +13766,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetAttributionSettings._get_http_options() ) + request, metadata = self._interceptor.pre_get_attribution_settings( request, metadata ) @@ -10685,6 +13779,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.GetAttributionSettings", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetAttributionSettings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._GetAttributionSettings._get_response( self._host, @@ -10705,7 +13826,29 @@ def __call__( pb_resp = resources.AttributionSettings.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_attribution_settings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.AttributionSettings.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_attribution_settings", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetAttributionSettings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAudience( @@ -10743,7 +13886,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> audience.Audience: r"""Call the get audience method over HTTP. @@ -10753,8 +13896,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.audience.Audience: @@ -10766,6 +13911,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetAudience._get_http_options() ) + request, metadata = self._interceptor.pre_get_audience(request, metadata) transcoded_request = _BaseAnalyticsAdminServiceRestTransport._BaseGetAudience._get_transcoded_request( http_options, request @@ -10776,6 +13922,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.GetAudience", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetAudience", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._GetAudience._get_response( self._host, @@ -10796,7 +13969,29 @@ def __call__( pb_resp = audience.Audience.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_audience(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = audience.Audience.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_audience", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetAudience", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetBigQueryLink( @@ -10834,7 +14029,7 @@ 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.BigQueryLink: r"""Call the get big query link method over HTTP. @@ -10845,8 +14040,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.BigQueryLink: @@ -10858,6 +14055,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetBigQueryLink._get_http_options() ) + request, metadata = self._interceptor.pre_get_big_query_link( request, metadata ) @@ -10870,6 +14068,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.GetBigQueryLink", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetBigQueryLink", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._GetBigQueryLink._get_response( @@ -10892,7 +14117,29 @@ def __call__( pb_resp = resources.BigQueryLink.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_big_query_link(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.BigQueryLink.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_big_query_link", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetBigQueryLink", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCalculatedMetric( @@ -10930,7 +14177,7 @@ 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.CalculatedMetric: r"""Call the get calculated metric method over HTTP. @@ -10941,8 +14188,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.CalculatedMetric: @@ -10952,6 +14201,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetCalculatedMetric._get_http_options() ) + request, metadata = self._interceptor.pre_get_calculated_metric( request, metadata ) @@ -10964,6 +14214,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.GetCalculatedMetric", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetCalculatedMetric", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._GetCalculatedMetric._get_response( @@ -10986,7 +14263,29 @@ def __call__( pb_resp = resources.CalculatedMetric.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_calculated_metric(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.CalculatedMetric.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_calculated_metric", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetCalculatedMetric", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetChannelGroup( @@ -11024,7 +14323,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> channel_group.ChannelGroup: r"""Call the get channel group method over HTTP. @@ -11035,8 +14334,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.channel_group.ChannelGroup: @@ -11048,6 +14349,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetChannelGroup._get_http_options() ) + request, metadata = self._interceptor.pre_get_channel_group( request, metadata ) @@ -11060,6 +14362,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.GetChannelGroup", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetChannelGroup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._GetChannelGroup._get_response( @@ -11082,7 +14411,29 @@ def __call__( pb_resp = channel_group.ChannelGroup.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_channel_group(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = channel_group.ChannelGroup.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_channel_group", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetChannelGroup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetConversionEvent( @@ -11120,7 +14471,7 @@ 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.ConversionEvent: r"""Call the get conversion event method over HTTP. @@ -11131,8 +14482,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ConversionEvent: @@ -11144,6 +14497,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetConversionEvent._get_http_options() ) + request, metadata = self._interceptor.pre_get_conversion_event( request, metadata ) @@ -11156,6 +14510,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.GetConversionEvent", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetConversionEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._GetConversionEvent._get_response( @@ -11178,7 +14559,29 @@ def __call__( pb_resp = resources.ConversionEvent.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_conversion_event(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.ConversionEvent.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_conversion_event", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetConversionEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCustomDimension( @@ -11216,7 +14619,7 @@ 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.CustomDimension: r"""Call the get custom dimension method over HTTP. @@ -11227,8 +14630,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.CustomDimension: @@ -11238,6 +14643,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetCustomDimension._get_http_options() ) + request, metadata = self._interceptor.pre_get_custom_dimension( request, metadata ) @@ -11250,6 +14656,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.GetCustomDimension", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetCustomDimension", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._GetCustomDimension._get_response( @@ -11272,7 +14705,29 @@ def __call__( pb_resp = resources.CustomDimension.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_custom_dimension(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.CustomDimension.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_custom_dimension", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetCustomDimension", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCustomMetric( @@ -11310,7 +14765,7 @@ 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.CustomMetric: r"""Call the get custom metric method over HTTP. @@ -11321,8 +14776,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.CustomMetric: @@ -11332,6 +14789,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetCustomMetric._get_http_options() ) + request, metadata = self._interceptor.pre_get_custom_metric( request, metadata ) @@ -11344,6 +14802,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.GetCustomMetric", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetCustomMetric", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._GetCustomMetric._get_response( @@ -11366,7 +14851,29 @@ def __call__( pb_resp = resources.CustomMetric.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_custom_metric(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.CustomMetric.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_custom_metric", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetCustomMetric", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDataRedactionSettings( @@ -11404,7 +14911,7 @@ 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.DataRedactionSettings: r"""Call the get data redaction settings method over HTTP. @@ -11416,8 +14923,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.DataRedactionSettings: @@ -11430,6 +14939,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetDataRedactionSettings._get_http_options() ) + request, metadata = self._interceptor.pre_get_data_redaction_settings( request, metadata ) @@ -11442,6 +14952,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.GetDataRedactionSettings", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetDataRedactionSettings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._GetDataRedactionSettings._get_response( self._host, @@ -11462,7 +14999,29 @@ def __call__( pb_resp = resources.DataRedactionSettings.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_data_redaction_settings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.DataRedactionSettings.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_data_redaction_settings", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetDataRedactionSettings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDataRetentionSettings( @@ -11500,7 +15059,7 @@ 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.DataRetentionSettings: r"""Call the get data retention settings method over HTTP. @@ -11512,8 +15071,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.DataRetentionSettings: @@ -11525,6 +15086,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetDataRetentionSettings._get_http_options() ) + request, metadata = self._interceptor.pre_get_data_retention_settings( request, metadata ) @@ -11537,6 +15099,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.GetDataRetentionSettings", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetDataRetentionSettings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._GetDataRetentionSettings._get_response( self._host, @@ -11557,7 +15146,29 @@ def __call__( pb_resp = resources.DataRetentionSettings.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_data_retention_settings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.DataRetentionSettings.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_data_retention_settings", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetDataRetentionSettings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDataSharingSettings( @@ -11595,7 +15206,7 @@ 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.DataSharingSettings: r"""Call the get data sharing settings method over HTTP. @@ -11606,8 +15217,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.DataSharingSettings: @@ -11620,6 +15233,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetDataSharingSettings._get_http_options() ) + request, metadata = self._interceptor.pre_get_data_sharing_settings( request, metadata ) @@ -11632,6 +15246,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.GetDataSharingSettings", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetDataSharingSettings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._GetDataSharingSettings._get_response( self._host, @@ -11652,7 +15293,29 @@ def __call__( pb_resp = resources.DataSharingSettings.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_data_sharing_settings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.DataSharingSettings.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_data_sharing_settings", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetDataSharingSettings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDataStream( @@ -11690,7 +15353,7 @@ 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.DataStream: r"""Call the get data stream method over HTTP. @@ -11701,8 +15364,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.DataStream: @@ -11714,6 +15379,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetDataStream._get_http_options() ) + request, metadata = self._interceptor.pre_get_data_stream(request, metadata) transcoded_request = _BaseAnalyticsAdminServiceRestTransport._BaseGetDataStream._get_transcoded_request( http_options, request @@ -11724,6 +15390,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.GetDataStream", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetDataStream", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._GetDataStream._get_response( self._host, @@ -11744,7 +15437,29 @@ def __call__( pb_resp = resources.DataStream.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_data_stream(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.DataStream.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_data_stream", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetDataStream", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDisplayVideo360AdvertiserLink( @@ -11784,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]]] = (), ) -> resources.DisplayVideo360AdvertiserLink: r"""Call the get display video360 advertiser link method over HTTP. @@ -11796,8 +15511,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.DisplayVideo360AdvertiserLink: @@ -11809,6 +15526,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetDisplayVideo360AdvertiserLink._get_http_options() ) + ( request, metadata, @@ -11824,6 +15542,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.GetDisplayVideo360AdvertiserLink", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetDisplayVideo360AdvertiserLink", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._GetDisplayVideo360AdvertiserLink._get_response( self._host, @@ -11844,7 +15589,31 @@ def __call__( pb_resp = resources.DisplayVideo360AdvertiserLink.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_display_video360_advertiser_link(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.DisplayVideo360AdvertiserLink.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_display_video360_advertiser_link", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetDisplayVideo360AdvertiserLink", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDisplayVideo360AdvertiserLinkProposal( @@ -11884,7 +15653,7 @@ 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.DisplayVideo360AdvertiserLinkProposal: r"""Call the get display video360 advertiser link proposal method over HTTP. @@ -11897,8 +15666,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.DisplayVideo360AdvertiserLinkProposal: @@ -11918,6 +15689,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetDisplayVideo360AdvertiserLinkProposal._get_http_options() ) + ( request, metadata, @@ -11933,6 +15705,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.GetDisplayVideo360AdvertiserLinkProposal", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetDisplayVideo360AdvertiserLinkProposal", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._GetDisplayVideo360AdvertiserLinkProposal._get_response( self._host, @@ -11953,9 +15752,35 @@ def __call__( pb_resp = resources.DisplayVideo360AdvertiserLinkProposal.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_display_video360_advertiser_link_proposal( resp ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + resources.DisplayVideo360AdvertiserLinkProposal.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_display_video360_advertiser_link_proposal", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetDisplayVideo360AdvertiserLinkProposal", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetEnhancedMeasurementSettings( @@ -11995,7 +15820,7 @@ 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.EnhancedMeasurementSettings: r"""Call the get enhanced measurement settings method over HTTP. @@ -12007,8 +15832,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.EnhancedMeasurementSettings: @@ -12022,6 +15849,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetEnhancedMeasurementSettings._get_http_options() ) + request, metadata = self._interceptor.pre_get_enhanced_measurement_settings( request, metadata ) @@ -12034,6 +15862,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.GetEnhancedMeasurementSettings", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetEnhancedMeasurementSettings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._GetEnhancedMeasurementSettings._get_response( self._host, @@ -12054,7 +15909,31 @@ def __call__( pb_resp = resources.EnhancedMeasurementSettings.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_enhanced_measurement_settings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.EnhancedMeasurementSettings.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_enhanced_measurement_settings", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetEnhancedMeasurementSettings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetEventCreateRule( @@ -12092,7 +15971,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> event_create_and_edit.EventCreateRule: r"""Call the get event create rule method over HTTP. @@ -12103,8 +15982,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.event_create_and_edit.EventCreateRule: @@ -12128,6 +16009,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetEventCreateRule._get_http_options() ) + request, metadata = self._interceptor.pre_get_event_create_rule( request, metadata ) @@ -12140,6 +16022,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.GetEventCreateRule", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetEventCreateRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._GetEventCreateRule._get_response( @@ -12162,7 +16071,31 @@ def __call__( pb_resp = event_create_and_edit.EventCreateRule.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_event_create_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = event_create_and_edit.EventCreateRule.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_event_create_rule", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetEventCreateRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetEventEditRule( @@ -12200,7 +16133,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> event_create_and_edit.EventEditRule: r"""Call the get event edit rule method over HTTP. @@ -12211,8 +16144,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.event_create_and_edit.EventEditRule: @@ -12236,6 +16171,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetEventEditRule._get_http_options() ) + request, metadata = self._interceptor.pre_get_event_edit_rule( request, metadata ) @@ -12248,6 +16184,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.GetEventEditRule", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetEventEditRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._GetEventEditRule._get_response( @@ -12270,7 +16233,31 @@ def __call__( pb_resp = event_create_and_edit.EventEditRule.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_event_edit_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = event_create_and_edit.EventEditRule.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_event_edit_rule", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetEventEditRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetExpandedDataSet( @@ -12308,7 +16295,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> expanded_data_set.ExpandedDataSet: r"""Call the get expanded data set method over HTTP. @@ -12319,8 +16306,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.expanded_data_set.ExpandedDataSet: @@ -12332,6 +16321,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetExpandedDataSet._get_http_options() ) + request, metadata = self._interceptor.pre_get_expanded_data_set( request, metadata ) @@ -12344,6 +16334,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.GetExpandedDataSet", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetExpandedDataSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._GetExpandedDataSet._get_response( @@ -12366,7 +16383,31 @@ def __call__( pb_resp = expanded_data_set.ExpandedDataSet.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_expanded_data_set(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = expanded_data_set.ExpandedDataSet.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_expanded_data_set", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetExpandedDataSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetGlobalSiteTag( @@ -12404,7 +16445,7 @@ 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.GlobalSiteTag: r"""Call the get global site tag method over HTTP. @@ -12415,8 +16456,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.GlobalSiteTag: @@ -12430,6 +16473,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetGlobalSiteTag._get_http_options() ) + request, metadata = self._interceptor.pre_get_global_site_tag( request, metadata ) @@ -12442,6 +16486,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.GetGlobalSiteTag", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetGlobalSiteTag", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._GetGlobalSiteTag._get_response( @@ -12464,7 +16535,29 @@ def __call__( pb_resp = resources.GlobalSiteTag.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_global_site_tag(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.GlobalSiteTag.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_global_site_tag", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetGlobalSiteTag", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetGoogleSignalsSettings( @@ -12502,7 +16595,7 @@ 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.GoogleSignalsSettings: r"""Call the get google signals settings method over HTTP. @@ -12514,8 +16607,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.GoogleSignalsSettings: @@ -12527,6 +16622,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetGoogleSignalsSettings._get_http_options() ) + request, metadata = self._interceptor.pre_get_google_signals_settings( request, metadata ) @@ -12539,6 +16635,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.GetGoogleSignalsSettings", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetGoogleSignalsSettings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._GetGoogleSignalsSettings._get_response( self._host, @@ -12559,7 +16682,29 @@ def __call__( pb_resp = resources.GoogleSignalsSettings.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_google_signals_settings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.GoogleSignalsSettings.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_google_signals_settings", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetGoogleSignalsSettings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetKeyEvent( @@ -12597,7 +16742,7 @@ 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.KeyEvent: r"""Call the get key event method over HTTP. @@ -12607,8 +16752,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.KeyEvent: @@ -12620,6 +16767,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetKeyEvent._get_http_options() ) + request, metadata = self._interceptor.pre_get_key_event(request, metadata) transcoded_request = _BaseAnalyticsAdminServiceRestTransport._BaseGetKeyEvent._get_transcoded_request( http_options, request @@ -12630,6 +16778,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.GetKeyEvent", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetKeyEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._GetKeyEvent._get_response( self._host, @@ -12650,7 +16825,29 @@ def __call__( pb_resp = resources.KeyEvent.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_key_event(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.KeyEvent.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_key_event", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetKeyEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetMeasurementProtocolSecret( @@ -12690,7 +16887,7 @@ 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.MeasurementProtocolSecret: r"""Call the get measurement protocol secret method over HTTP. @@ -12702,8 +16899,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.MeasurementProtocolSecret: @@ -12715,6 +16914,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetMeasurementProtocolSecret._get_http_options() ) + request, metadata = self._interceptor.pre_get_measurement_protocol_secret( request, metadata ) @@ -12727,6 +16927,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.GetMeasurementProtocolSecret", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetMeasurementProtocolSecret", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._GetMeasurementProtocolSecret._get_response( self._host, @@ -12747,7 +16974,31 @@ def __call__( pb_resp = resources.MeasurementProtocolSecret.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_measurement_protocol_secret(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.MeasurementProtocolSecret.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_measurement_protocol_secret", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetMeasurementProtocolSecret", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetProperty( @@ -12785,7 +17036,7 @@ 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.Property: r"""Call the get property method over HTTP. @@ -12795,8 +17046,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.Property: @@ -12808,6 +17061,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetProperty._get_http_options() ) + request, metadata = self._interceptor.pre_get_property(request, metadata) transcoded_request = _BaseAnalyticsAdminServiceRestTransport._BaseGetProperty._get_transcoded_request( http_options, request @@ -12818,6 +17072,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.GetProperty", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetProperty", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._GetProperty._get_response( self._host, @@ -12838,7 +17119,29 @@ def __call__( pb_resp = resources.Property.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_property(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Property.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_property", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetProperty", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetRollupPropertySourceLink( @@ -12878,7 +17181,7 @@ 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.RollupPropertySourceLink: r"""Call the get rollup property source link method over HTTP. @@ -12890,8 +17193,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.RollupPropertySourceLink: @@ -12904,6 +17209,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetRollupPropertySourceLink._get_http_options() ) + request, metadata = self._interceptor.pre_get_rollup_property_source_link( request, metadata ) @@ -12916,6 +17222,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.GetRollupPropertySourceLink", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetRollupPropertySourceLink", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._GetRollupPropertySourceLink._get_response( self._host, @@ -12936,7 +17269,31 @@ def __call__( pb_resp = resources.RollupPropertySourceLink.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_rollup_property_source_link(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.RollupPropertySourceLink.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_rollup_property_source_link", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetRollupPropertySourceLink", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSearchAds360Link( @@ -12974,7 +17331,7 @@ 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.SearchAds360Link: r"""Call the get search ads360 link method over HTTP. @@ -12985,8 +17342,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.SearchAds360Link: @@ -12998,6 +17357,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetSearchAds360Link._get_http_options() ) + request, metadata = self._interceptor.pre_get_search_ads360_link( request, metadata ) @@ -13010,6 +17370,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.GetSearchAds360Link", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetSearchAds360Link", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._GetSearchAds360Link._get_response( @@ -13032,7 +17419,29 @@ def __call__( pb_resp = resources.SearchAds360Link.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_search_ads360_link(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.SearchAds360Link.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_search_ads360_link", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetSearchAds360Link", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSKAdNetworkConversionValueSchema( @@ -13072,7 +17481,7 @@ 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.SKAdNetworkConversionValueSchema: r"""Call the get sk ad network conversion value schema method over HTTP. @@ -13084,8 +17493,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.SKAdNetworkConversionValueSchema: @@ -13097,6 +17508,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetSKAdNetworkConversionValueSchema._get_http_options() ) + ( request, metadata, @@ -13112,6 +17524,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.GetSKAdNetworkConversionValueSchema", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetSKAdNetworkConversionValueSchema", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._GetSKAdNetworkConversionValueSchema._get_response( self._host, @@ -13132,9 +17571,33 @@ def __call__( pb_resp = resources.SKAdNetworkConversionValueSchema.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_sk_ad_network_conversion_value_schema( resp ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + resources.SKAdNetworkConversionValueSchema.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_sk_ad_network_conversion_value_schema", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetSKAdNetworkConversionValueSchema", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSubpropertyEventFilter( @@ -13172,7 +17635,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> subproperty_event_filter.SubpropertyEventFilter: r"""Call the get subproperty event filter method over HTTP. @@ -13184,8 +17647,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.subproperty_event_filter.SubpropertyEventFilter: @@ -13197,6 +17662,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetSubpropertyEventFilter._get_http_options() ) + request, metadata = self._interceptor.pre_get_subproperty_event_filter( request, metadata ) @@ -13209,6 +17675,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.GetSubpropertyEventFilter", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetSubpropertyEventFilter", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._GetSubpropertyEventFilter._get_response( self._host, @@ -13229,7 +17722,33 @@ def __call__( pb_resp = subproperty_event_filter.SubpropertyEventFilter.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_subproperty_event_filter(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + subproperty_event_filter.SubpropertyEventFilter.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.get_subproperty_event_filter", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "GetSubpropertyEventFilter", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAccessBindings( @@ -13267,7 +17786,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListAccessBindingsResponse: r"""Call the list access bindings method over HTTP. @@ -13278,8 +17797,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListAccessBindingsResponse: @@ -13291,6 +17812,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListAccessBindings._get_http_options() ) + request, metadata = self._interceptor.pre_list_access_bindings( request, metadata ) @@ -13303,6 +17825,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.ListAccessBindings", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListAccessBindings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._ListAccessBindings._get_response( @@ -13325,7 +17874,31 @@ def __call__( pb_resp = analytics_admin.ListAccessBindingsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_access_bindings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.ListAccessBindingsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_access_bindings", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListAccessBindings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAccounts( @@ -13363,7 +17936,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListAccountsResponse: r"""Call the list accounts method over HTTP. @@ -13373,8 +17946,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListAccountsResponse: @@ -13384,6 +17959,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListAccounts._get_http_options() ) + request, metadata = self._interceptor.pre_list_accounts(request, metadata) transcoded_request = _BaseAnalyticsAdminServiceRestTransport._BaseListAccounts._get_transcoded_request( http_options, request @@ -13394,6 +17970,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.ListAccounts", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListAccounts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._ListAccounts._get_response( self._host, @@ -13414,7 +18017,31 @@ def __call__( pb_resp = analytics_admin.ListAccountsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_accounts(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = analytics_admin.ListAccountsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_accounts", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListAccounts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAccountSummaries( @@ -13452,7 +18079,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListAccountSummariesResponse: r"""Call the list account summaries method over HTTP. @@ -13463,8 +18090,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListAccountSummariesResponse: @@ -13476,6 +18105,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListAccountSummaries._get_http_options() ) + request, metadata = self._interceptor.pre_list_account_summaries( request, metadata ) @@ -13488,6 +18118,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.ListAccountSummaries", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListAccountSummaries", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._ListAccountSummaries._get_response( @@ -13510,7 +18167,31 @@ def __call__( pb_resp = analytics_admin.ListAccountSummariesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_account_summaries(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.ListAccountSummariesResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_account_summaries", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListAccountSummaries", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAdSenseLinks( @@ -13548,7 +18229,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListAdSenseLinksResponse: r"""Call the list ad sense links method over HTTP. @@ -13559,8 +18240,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListAdSenseLinksResponse: @@ -13572,6 +18255,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListAdSenseLinks._get_http_options() ) + request, metadata = self._interceptor.pre_list_ad_sense_links( request, metadata ) @@ -13584,6 +18268,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.ListAdSenseLinks", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListAdSenseLinks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._ListAdSenseLinks._get_response( @@ -13606,7 +18317,31 @@ def __call__( pb_resp = analytics_admin.ListAdSenseLinksResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_ad_sense_links(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = analytics_admin.ListAdSenseLinksResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_ad_sense_links", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListAdSenseLinks", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAudiences( @@ -13644,7 +18379,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListAudiencesResponse: r"""Call the list audiences method over HTTP. @@ -13655,8 +18390,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListAudiencesResponse: @@ -13668,6 +18405,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListAudiences._get_http_options() ) + request, metadata = self._interceptor.pre_list_audiences(request, metadata) transcoded_request = _BaseAnalyticsAdminServiceRestTransport._BaseListAudiences._get_transcoded_request( http_options, request @@ -13678,6 +18416,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.ListAudiences", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListAudiences", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._ListAudiences._get_response( self._host, @@ -13698,7 +18463,31 @@ def __call__( pb_resp = analytics_admin.ListAudiencesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_audiences(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = analytics_admin.ListAudiencesResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_audiences", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListAudiences", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListBigQueryLinks( @@ -13736,7 +18525,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListBigQueryLinksResponse: r"""Call the list big query links method over HTTP. @@ -13747,8 +18536,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListBigQueryLinksResponse: @@ -13760,6 +18551,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListBigQueryLinks._get_http_options() ) + request, metadata = self._interceptor.pre_list_big_query_links( request, metadata ) @@ -13772,6 +18564,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.ListBigQueryLinks", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListBigQueryLinks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._ListBigQueryLinks._get_response( @@ -13794,7 +18613,31 @@ def __call__( pb_resp = analytics_admin.ListBigQueryLinksResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_big_query_links(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.ListBigQueryLinksResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_big_query_links", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListBigQueryLinks", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCalculatedMetrics( @@ -13832,7 +18675,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListCalculatedMetricsResponse: r"""Call the list calculated metrics method over HTTP. @@ -13843,8 +18686,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListCalculatedMetricsResponse: @@ -13856,6 +18701,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListCalculatedMetrics._get_http_options() ) + request, metadata = self._interceptor.pre_list_calculated_metrics( request, metadata ) @@ -13868,6 +18714,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.ListCalculatedMetrics", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListCalculatedMetrics", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._ListCalculatedMetrics._get_response( @@ -13890,7 +18763,31 @@ def __call__( pb_resp = analytics_admin.ListCalculatedMetricsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_calculated_metrics(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.ListCalculatedMetricsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_calculated_metrics", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListCalculatedMetrics", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListChannelGroups( @@ -13928,7 +18825,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListChannelGroupsResponse: r"""Call the list channel groups method over HTTP. @@ -13939,8 +18836,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListChannelGroupsResponse: @@ -13952,6 +18851,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListChannelGroups._get_http_options() ) + request, metadata = self._interceptor.pre_list_channel_groups( request, metadata ) @@ -13964,6 +18864,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.ListChannelGroups", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListChannelGroups", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._ListChannelGroups._get_response( @@ -13986,7 +18913,31 @@ def __call__( pb_resp = analytics_admin.ListChannelGroupsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_channel_groups(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.ListChannelGroupsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_channel_groups", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListChannelGroups", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListConnectedSiteTags( @@ -14025,7 +18976,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListConnectedSiteTagsResponse: r"""Call the list connected site tags method over HTTP. @@ -14036,8 +18987,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListConnectedSiteTagsResponse: @@ -14049,6 +19002,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListConnectedSiteTags._get_http_options() ) + request, metadata = self._interceptor.pre_list_connected_site_tags( request, metadata ) @@ -14065,6 +19019,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.ListConnectedSiteTags", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListConnectedSiteTags", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._ListConnectedSiteTags._get_response( @@ -14088,7 +19069,31 @@ def __call__( pb_resp = analytics_admin.ListConnectedSiteTagsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_connected_site_tags(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.ListConnectedSiteTagsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_connected_site_tags", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListConnectedSiteTags", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListConversionEvents( @@ -14126,7 +19131,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListConversionEventsResponse: r"""Call the list conversion events method over HTTP. @@ -14137,8 +19142,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListConversionEventsResponse: @@ -14150,6 +19157,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListConversionEvents._get_http_options() ) + request, metadata = self._interceptor.pre_list_conversion_events( request, metadata ) @@ -14162,6 +19170,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.ListConversionEvents", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListConversionEvents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._ListConversionEvents._get_response( @@ -14184,7 +19219,31 @@ def __call__( pb_resp = analytics_admin.ListConversionEventsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_conversion_events(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.ListConversionEventsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_conversion_events", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListConversionEvents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCustomDimensions( @@ -14222,7 +19281,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListCustomDimensionsResponse: r"""Call the list custom dimensions method over HTTP. @@ -14233,8 +19292,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListCustomDimensionsResponse: @@ -14246,6 +19307,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListCustomDimensions._get_http_options() ) + request, metadata = self._interceptor.pre_list_custom_dimensions( request, metadata ) @@ -14258,6 +19320,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.ListCustomDimensions", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListCustomDimensions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._ListCustomDimensions._get_response( @@ -14280,7 +19369,31 @@ def __call__( pb_resp = analytics_admin.ListCustomDimensionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_custom_dimensions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.ListCustomDimensionsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_custom_dimensions", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListCustomDimensions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCustomMetrics( @@ -14318,7 +19431,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListCustomMetricsResponse: r"""Call the list custom metrics method over HTTP. @@ -14329,8 +19442,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListCustomMetricsResponse: @@ -14342,6 +19457,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListCustomMetrics._get_http_options() ) + request, metadata = self._interceptor.pre_list_custom_metrics( request, metadata ) @@ -14354,6 +19470,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.ListCustomMetrics", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListCustomMetrics", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._ListCustomMetrics._get_response( @@ -14376,7 +19519,31 @@ def __call__( pb_resp = analytics_admin.ListCustomMetricsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_custom_metrics(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.ListCustomMetricsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_custom_metrics", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListCustomMetrics", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDataStreams( @@ -14414,7 +19581,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListDataStreamsResponse: r"""Call the list data streams method over HTTP. @@ -14425,8 +19592,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListDataStreamsResponse: @@ -14438,6 +19607,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListDataStreams._get_http_options() ) + request, metadata = self._interceptor.pre_list_data_streams( request, metadata ) @@ -14450,6 +19620,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.ListDataStreams", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListDataStreams", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._ListDataStreams._get_response( @@ -14472,7 +19669,31 @@ def __call__( pb_resp = analytics_admin.ListDataStreamsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_data_streams(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = analytics_admin.ListDataStreamsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_data_streams", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListDataStreams", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDisplayVideo360AdvertiserLinkProposals( @@ -14512,7 +19733,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse: r"""Call the list display video360 advertiser link proposals method over HTTP. @@ -14525,8 +19746,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse: @@ -14539,6 +19762,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListDisplayVideo360AdvertiserLinkProposals._get_http_options() ) + ( request, metadata, @@ -14554,6 +19778,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.ListDisplayVideo360AdvertiserLinkProposals", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListDisplayVideo360AdvertiserLinkProposals", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._ListDisplayVideo360AdvertiserLinkProposals._get_response( self._host, @@ -14578,11 +19829,35 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = ( self._interceptor.post_list_display_video360_advertiser_link_proposals( resp ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_display_video360_advertiser_link_proposals", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListDisplayVideo360AdvertiserLinkProposals", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDisplayVideo360AdvertiserLinks( @@ -14622,7 +19897,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListDisplayVideo360AdvertiserLinksResponse: r"""Call the list display video360 advertiser links method over HTTP. @@ -14634,8 +19909,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListDisplayVideo360AdvertiserLinksResponse: @@ -14647,6 +19924,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListDisplayVideo360AdvertiserLinks._get_http_options() ) + ( request, metadata, @@ -14662,6 +19940,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.ListDisplayVideo360AdvertiserLinks", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListDisplayVideo360AdvertiserLinks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._ListDisplayVideo360AdvertiserLinks._get_response( self._host, @@ -14684,7 +19989,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_display_video360_advertiser_links(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = analytics_admin.ListDisplayVideo360AdvertiserLinksResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_display_video360_advertiser_links", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListDisplayVideo360AdvertiserLinks", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListEventCreateRules( @@ -14722,7 +20051,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListEventCreateRulesResponse: r"""Call the list event create rules method over HTTP. @@ -14733,8 +20062,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListEventCreateRulesResponse: @@ -14746,6 +20077,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListEventCreateRules._get_http_options() ) + request, metadata = self._interceptor.pre_list_event_create_rules( request, metadata ) @@ -14758,6 +20090,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.ListEventCreateRules", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListEventCreateRules", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._ListEventCreateRules._get_response( @@ -14780,7 +20139,31 @@ def __call__( pb_resp = analytics_admin.ListEventCreateRulesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_event_create_rules(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.ListEventCreateRulesResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_event_create_rules", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListEventCreateRules", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListEventEditRules( @@ -14818,7 +20201,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListEventEditRulesResponse: r"""Call the list event edit rules method over HTTP. @@ -14829,8 +20212,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListEventEditRulesResponse: @@ -14842,6 +20227,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListEventEditRules._get_http_options() ) + request, metadata = self._interceptor.pre_list_event_edit_rules( request, metadata ) @@ -14854,6 +20240,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.ListEventEditRules", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListEventEditRules", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._ListEventEditRules._get_response( @@ -14876,7 +20289,31 @@ def __call__( pb_resp = analytics_admin.ListEventEditRulesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_event_edit_rules(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.ListEventEditRulesResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_event_edit_rules", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListEventEditRules", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListExpandedDataSets( @@ -14914,7 +20351,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListExpandedDataSetsResponse: r"""Call the list expanded data sets method over HTTP. @@ -14925,8 +20362,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListExpandedDataSetsResponse: @@ -14938,6 +20377,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListExpandedDataSets._get_http_options() ) + request, metadata = self._interceptor.pre_list_expanded_data_sets( request, metadata ) @@ -14950,6 +20390,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.ListExpandedDataSets", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListExpandedDataSets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._ListExpandedDataSets._get_response( @@ -14972,7 +20439,31 @@ def __call__( pb_resp = analytics_admin.ListExpandedDataSetsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_expanded_data_sets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.ListExpandedDataSetsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_expanded_data_sets", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListExpandedDataSets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListFirebaseLinks( @@ -15010,7 +20501,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListFirebaseLinksResponse: r"""Call the list firebase links method over HTTP. @@ -15021,8 +20512,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListFirebaseLinksResponse: @@ -15034,6 +20527,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListFirebaseLinks._get_http_options() ) + request, metadata = self._interceptor.pre_list_firebase_links( request, metadata ) @@ -15046,6 +20540,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.ListFirebaseLinks", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListFirebaseLinks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._ListFirebaseLinks._get_response( @@ -15068,7 +20589,31 @@ def __call__( pb_resp = analytics_admin.ListFirebaseLinksResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_firebase_links(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.ListFirebaseLinksResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_firebase_links", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListFirebaseLinks", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListGoogleAdsLinks( @@ -15106,7 +20651,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListGoogleAdsLinksResponse: r"""Call the list google ads links method over HTTP. @@ -15117,8 +20662,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListGoogleAdsLinksResponse: @@ -15130,6 +20677,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListGoogleAdsLinks._get_http_options() ) + request, metadata = self._interceptor.pre_list_google_ads_links( request, metadata ) @@ -15142,6 +20690,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.ListGoogleAdsLinks", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListGoogleAdsLinks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._ListGoogleAdsLinks._get_response( @@ -15164,7 +20739,31 @@ def __call__( pb_resp = analytics_admin.ListGoogleAdsLinksResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_google_ads_links(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.ListGoogleAdsLinksResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_google_ads_links", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListGoogleAdsLinks", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListKeyEvents( @@ -15202,7 +20801,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListKeyEventsResponse: r"""Call the list key events method over HTTP. @@ -15212,8 +20811,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListKeyEventsResponse: @@ -15225,6 +20826,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListKeyEvents._get_http_options() ) + request, metadata = self._interceptor.pre_list_key_events(request, metadata) transcoded_request = _BaseAnalyticsAdminServiceRestTransport._BaseListKeyEvents._get_transcoded_request( http_options, request @@ -15235,6 +20837,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.ListKeyEvents", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListKeyEvents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._ListKeyEvents._get_response( self._host, @@ -15255,7 +20884,31 @@ def __call__( pb_resp = analytics_admin.ListKeyEventsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_key_events(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = analytics_admin.ListKeyEventsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_key_events", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListKeyEvents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListMeasurementProtocolSecrets( @@ -15295,7 +20948,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListMeasurementProtocolSecretsResponse: r"""Call the list measurement protocol secrets method over HTTP. @@ -15307,8 +20960,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListMeasurementProtocolSecretsResponse: @@ -15320,6 +20975,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListMeasurementProtocolSecrets._get_http_options() ) + request, metadata = self._interceptor.pre_list_measurement_protocol_secrets( request, metadata ) @@ -15332,6 +20988,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.ListMeasurementProtocolSecrets", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListMeasurementProtocolSecrets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._ListMeasurementProtocolSecrets._get_response( self._host, @@ -15352,7 +21035,33 @@ def __call__( pb_resp = analytics_admin.ListMeasurementProtocolSecretsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_measurement_protocol_secrets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.ListMeasurementProtocolSecretsResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_measurement_protocol_secrets", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListMeasurementProtocolSecrets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListProperties( @@ -15390,7 +21099,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListPropertiesResponse: r"""Call the list properties method over HTTP. @@ -15401,8 +21110,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListPropertiesResponse: @@ -15414,6 +21125,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListProperties._get_http_options() ) + request, metadata = self._interceptor.pre_list_properties(request, metadata) transcoded_request = _BaseAnalyticsAdminServiceRestTransport._BaseListProperties._get_transcoded_request( http_options, request @@ -15424,6 +21136,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.ListProperties", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListProperties", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._ListProperties._get_response( self._host, @@ -15444,7 +21183,31 @@ def __call__( pb_resp = analytics_admin.ListPropertiesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_properties(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = analytics_admin.ListPropertiesResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_properties", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListProperties", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListRollupPropertySourceLinks( @@ -15484,7 +21247,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListRollupPropertySourceLinksResponse: r"""Call the list rollup property source links method over HTTP. @@ -15496,8 +21259,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListRollupPropertySourceLinksResponse: @@ -15509,6 +21274,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListRollupPropertySourceLinks._get_http_options() ) + request, metadata = self._interceptor.pre_list_rollup_property_source_links( request, metadata ) @@ -15521,6 +21287,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.ListRollupPropertySourceLinks", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListRollupPropertySourceLinks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._ListRollupPropertySourceLinks._get_response( self._host, @@ -15541,7 +21334,33 @@ def __call__( pb_resp = analytics_admin.ListRollupPropertySourceLinksResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_rollup_property_source_links(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.ListRollupPropertySourceLinksResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_rollup_property_source_links", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListRollupPropertySourceLinks", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSearchAds360Links( @@ -15579,7 +21398,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListSearchAds360LinksResponse: r"""Call the list search ads360 links method over HTTP. @@ -15590,8 +21409,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListSearchAds360LinksResponse: @@ -15603,6 +21424,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListSearchAds360Links._get_http_options() ) + request, metadata = self._interceptor.pre_list_search_ads360_links( request, metadata ) @@ -15615,6 +21437,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.ListSearchAds360Links", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListSearchAds360Links", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._ListSearchAds360Links._get_response( @@ -15637,7 +21486,31 @@ def __call__( pb_resp = analytics_admin.ListSearchAds360LinksResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_search_ads360_links(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.ListSearchAds360LinksResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_search_ads360_links", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListSearchAds360Links", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSKAdNetworkConversionValueSchemas( @@ -15677,7 +21550,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListSKAdNetworkConversionValueSchemasResponse: r"""Call the list sk ad network conversion value schemas method over HTTP. @@ -15690,8 +21563,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListSKAdNetworkConversionValueSchemasResponse: @@ -15704,6 +21579,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListSKAdNetworkConversionValueSchemas._get_http_options() ) + ( request, metadata, @@ -15719,6 +21595,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.ListSKAdNetworkConversionValueSchemas", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListSKAdNetworkConversionValueSchemas", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._ListSKAdNetworkConversionValueSchemas._get_response( self._host, @@ -15741,9 +21644,33 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_sk_ad_network_conversion_value_schemas( resp ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = analytics_admin.ListSKAdNetworkConversionValueSchemasResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_sk_ad_network_conversion_value_schemas", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListSKAdNetworkConversionValueSchemas", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSubpropertyEventFilters( @@ -15783,7 +21710,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListSubpropertyEventFiltersResponse: r"""Call the list subproperty event filters method over HTTP. @@ -15795,8 +21722,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListSubpropertyEventFiltersResponse: @@ -15808,6 +21737,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListSubpropertyEventFilters._get_http_options() ) + request, metadata = self._interceptor.pre_list_subproperty_event_filters( request, metadata ) @@ -15820,6 +21750,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.ListSubpropertyEventFilters", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListSubpropertyEventFilters", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._ListSubpropertyEventFilters._get_response( self._host, @@ -15840,7 +21797,33 @@ def __call__( pb_resp = analytics_admin.ListSubpropertyEventFiltersResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_subproperty_event_filters(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.ListSubpropertyEventFiltersResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.list_subproperty_event_filters", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ListSubpropertyEventFilters", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ProvisionAccountTicket( @@ -15879,7 +21862,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ProvisionAccountTicketResponse: r"""Call the provision account ticket method over HTTP. @@ -15890,8 +21873,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ProvisionAccountTicketResponse: @@ -15903,6 +21888,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseProvisionAccountTicket._get_http_options() ) + request, metadata = self._interceptor.pre_provision_account_ticket( request, metadata ) @@ -15919,6 +21905,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.ProvisionAccountTicket", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ProvisionAccountTicket", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._ProvisionAccountTicket._get_response( self._host, @@ -15940,7 +21953,31 @@ def __call__( pb_resp = analytics_admin.ProvisionAccountTicketResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_provision_account_ticket(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.ProvisionAccountTicketResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.provision_account_ticket", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ProvisionAccountTicket", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ProvisionSubproperty( @@ -15979,7 +22016,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ProvisionSubpropertyResponse: r"""Call the provision subproperty method over HTTP. @@ -15990,8 +22027,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ProvisionSubpropertyResponse: @@ -16003,6 +22042,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseProvisionSubproperty._get_http_options() ) + request, metadata = self._interceptor.pre_provision_subproperty( request, metadata ) @@ -16019,6 +22059,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.ProvisionSubproperty", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ProvisionSubproperty", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._ProvisionSubproperty._get_response( @@ -16042,7 +22109,31 @@ def __call__( pb_resp = analytics_admin.ProvisionSubpropertyResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_provision_subproperty(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.ProvisionSubpropertyResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.provision_subproperty", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ProvisionSubproperty", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ReorderEventEditRules( @@ -16081,7 +22172,7 @@ 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 reorder event edit rules method over HTTP. @@ -16092,13 +22183,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 = ( _BaseAnalyticsAdminServiceRestTransport._BaseReorderEventEditRules._get_http_options() ) + request, metadata = self._interceptor.pre_reorder_event_edit_rules( request, metadata ) @@ -16115,6 +22209,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.ReorderEventEditRules", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "ReorderEventEditRules", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._ReorderEventEditRules._get_response( @@ -16169,7 +22290,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.RunAccessReportResponse: r"""Call the run access report method over HTTP. @@ -16180,8 +22301,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.RunAccessReportResponse: @@ -16193,6 +22316,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseRunAccessReport._get_http_options() ) + request, metadata = self._interceptor.pre_run_access_report( request, metadata ) @@ -16209,6 +22333,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.RunAccessReport", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "RunAccessReport", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._RunAccessReport._get_response( @@ -16232,7 +22383,31 @@ def __call__( pb_resp = analytics_admin.RunAccessReportResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_run_access_report(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = analytics_admin.RunAccessReportResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.run_access_report", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "RunAccessReport", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchChangeHistoryEvents( @@ -16271,7 +22446,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.SearchChangeHistoryEventsResponse: r"""Call the search change history events method over HTTP. @@ -16283,8 +22458,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.SearchChangeHistoryEventsResponse: @@ -16296,6 +22473,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseSearchChangeHistoryEvents._get_http_options() ) + request, metadata = self._interceptor.pre_search_change_history_events( request, metadata ) @@ -16312,6 +22490,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.SearchChangeHistoryEvents", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "SearchChangeHistoryEvents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._SearchChangeHistoryEvents._get_response( self._host, @@ -16333,7 +22538,33 @@ def __call__( pb_resp = analytics_admin.SearchChangeHistoryEventsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_change_history_events(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.SearchChangeHistoryEventsResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.search_change_history_events", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "SearchChangeHistoryEvents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetAutomatedGa4ConfigurationOptOut( @@ -16374,7 +22605,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse: r"""Call the set automated ga4 configuration opt out method over HTTP. @@ -16387,8 +22618,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse: @@ -16401,6 +22634,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseSetAutomatedGa4ConfigurationOptOut._get_http_options() ) + ( request, metadata, @@ -16420,6 +22654,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.SetAutomatedGa4ConfigurationOptOut", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "SetAutomatedGa4ConfigurationOptOut", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._SetAutomatedGa4ConfigurationOptOut._get_response( self._host, @@ -16443,7 +22704,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_automated_ga4_configuration_opt_out(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.set_automated_ga4_configuration_opt_out", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "SetAutomatedGa4ConfigurationOptOut", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateAccessBinding( @@ -16482,7 +22767,7 @@ 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.AccessBinding: r"""Call the update access binding method over HTTP. @@ -16493,8 +22778,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.AccessBinding: @@ -16506,6 +22793,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseUpdateAccessBinding._get_http_options() ) + request, metadata = self._interceptor.pre_update_access_binding( request, metadata ) @@ -16522,6 +22810,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.UpdateAccessBinding", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateAccessBinding", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._UpdateAccessBinding._get_response( @@ -16545,7 +22860,29 @@ def __call__( pb_resp = resources.AccessBinding.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_access_binding(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.AccessBinding.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.update_access_binding", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateAccessBinding", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateAccount( @@ -16584,7 +22921,7 @@ 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.Account: r"""Call the update account method over HTTP. @@ -16595,8 +22932,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.Account: @@ -16608,6 +22947,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseUpdateAccount._get_http_options() ) + request, metadata = self._interceptor.pre_update_account(request, metadata) transcoded_request = _BaseAnalyticsAdminServiceRestTransport._BaseUpdateAccount._get_transcoded_request( http_options, request @@ -16622,6 +22962,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.UpdateAccount", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateAccount", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._UpdateAccount._get_response( self._host, @@ -16643,7 +23010,29 @@ def __call__( pb_resp = resources.Account.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_account(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Account.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.update_account", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateAccount", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateAttributionSettings( @@ -16682,7 +23071,7 @@ 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.AttributionSettings: r"""Call the update attribution settings method over HTTP. @@ -16694,8 +23083,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.AttributionSettings: @@ -16708,6 +23099,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseUpdateAttributionSettings._get_http_options() ) + request, metadata = self._interceptor.pre_update_attribution_settings( request, metadata ) @@ -16724,6 +23116,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.UpdateAttributionSettings", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateAttributionSettings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._UpdateAttributionSettings._get_response( self._host, @@ -16745,7 +23164,29 @@ def __call__( pb_resp = resources.AttributionSettings.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_attribution_settings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.AttributionSettings.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.update_attribution_settings", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateAttributionSettings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateAudience( @@ -16784,7 +23225,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gaa_audience.Audience: r"""Call the update audience method over HTTP. @@ -16795,8 +23236,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gaa_audience.Audience: @@ -16808,6 +23251,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseUpdateAudience._get_http_options() ) + request, metadata = self._interceptor.pre_update_audience(request, metadata) transcoded_request = _BaseAnalyticsAdminServiceRestTransport._BaseUpdateAudience._get_transcoded_request( http_options, request @@ -16822,6 +23266,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.UpdateAudience", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateAudience", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._UpdateAudience._get_response( self._host, @@ -16843,7 +23314,29 @@ def __call__( pb_resp = gaa_audience.Audience.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_audience(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gaa_audience.Audience.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.update_audience", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateAudience", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateBigQueryLink( @@ -16882,7 +23375,7 @@ 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.BigQueryLink: r"""Call the update big query link method over HTTP. @@ -16893,8 +23386,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.BigQueryLink: @@ -16906,6 +23401,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseUpdateBigQueryLink._get_http_options() ) + request, metadata = self._interceptor.pre_update_big_query_link( request, metadata ) @@ -16922,6 +23418,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.UpdateBigQueryLink", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateBigQueryLink", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._UpdateBigQueryLink._get_response( @@ -16945,7 +23468,29 @@ def __call__( pb_resp = resources.BigQueryLink.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_big_query_link(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.BigQueryLink.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.update_big_query_link", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateBigQueryLink", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCalculatedMetric( @@ -16984,7 +23529,7 @@ 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.CalculatedMetric: r"""Call the update calculated metric method over HTTP. @@ -16995,8 +23540,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.CalculatedMetric: @@ -17006,6 +23553,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseUpdateCalculatedMetric._get_http_options() ) + request, metadata = self._interceptor.pre_update_calculated_metric( request, metadata ) @@ -17022,6 +23570,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.UpdateCalculatedMetric", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateCalculatedMetric", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._UpdateCalculatedMetric._get_response( self._host, @@ -17043,7 +23618,29 @@ def __call__( pb_resp = resources.CalculatedMetric.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_calculated_metric(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.CalculatedMetric.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.update_calculated_metric", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateCalculatedMetric", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateChannelGroup( @@ -17082,7 +23679,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gaa_channel_group.ChannelGroup: r"""Call the update channel group method over HTTP. @@ -17093,8 +23690,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gaa_channel_group.ChannelGroup: @@ -17106,6 +23705,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseUpdateChannelGroup._get_http_options() ) + request, metadata = self._interceptor.pre_update_channel_group( request, metadata ) @@ -17122,6 +23722,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.UpdateChannelGroup", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateChannelGroup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._UpdateChannelGroup._get_response( @@ -17145,7 +23772,29 @@ def __call__( pb_resp = gaa_channel_group.ChannelGroup.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_channel_group(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gaa_channel_group.ChannelGroup.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.update_channel_group", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateChannelGroup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateConversionEvent( @@ -17184,7 +23833,7 @@ 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.ConversionEvent: r"""Call the update conversion event method over HTTP. @@ -17195,8 +23844,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ConversionEvent: @@ -17208,6 +23859,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseUpdateConversionEvent._get_http_options() ) + request, metadata = self._interceptor.pre_update_conversion_event( request, metadata ) @@ -17224,6 +23876,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.UpdateConversionEvent", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateConversionEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._UpdateConversionEvent._get_response( @@ -17247,7 +23926,29 @@ def __call__( pb_resp = resources.ConversionEvent.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_conversion_event(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.ConversionEvent.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.update_conversion_event", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateConversionEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCustomDimension( @@ -17286,7 +23987,7 @@ 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.CustomDimension: r"""Call the update custom dimension method over HTTP. @@ -17297,8 +23998,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.CustomDimension: @@ -17308,6 +24011,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseUpdateCustomDimension._get_http_options() ) + request, metadata = self._interceptor.pre_update_custom_dimension( request, metadata ) @@ -17324,6 +24028,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.UpdateCustomDimension", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateCustomDimension", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._UpdateCustomDimension._get_response( @@ -17347,7 +24078,29 @@ def __call__( pb_resp = resources.CustomDimension.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_custom_dimension(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.CustomDimension.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.update_custom_dimension", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateCustomDimension", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCustomMetric( @@ -17386,7 +24139,7 @@ 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.CustomMetric: r"""Call the update custom metric method over HTTP. @@ -17397,8 +24150,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.CustomMetric: @@ -17408,6 +24163,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseUpdateCustomMetric._get_http_options() ) + request, metadata = self._interceptor.pre_update_custom_metric( request, metadata ) @@ -17424,6 +24180,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.UpdateCustomMetric", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateCustomMetric", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._UpdateCustomMetric._get_response( @@ -17447,7 +24230,29 @@ def __call__( pb_resp = resources.CustomMetric.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_custom_metric(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.CustomMetric.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.update_custom_metric", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateCustomMetric", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateDataRedactionSettings( @@ -17488,7 +24293,7 @@ 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.DataRedactionSettings: r"""Call the update data redaction settings method over HTTP. @@ -17500,8 +24305,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.DataRedactionSettings: @@ -17514,6 +24321,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseUpdateDataRedactionSettings._get_http_options() ) + request, metadata = self._interceptor.pre_update_data_redaction_settings( request, metadata ) @@ -17530,6 +24338,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.UpdateDataRedactionSettings", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateDataRedactionSettings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._UpdateDataRedactionSettings._get_response( self._host, @@ -17551,7 +24386,29 @@ def __call__( pb_resp = resources.DataRedactionSettings.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_data_redaction_settings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.DataRedactionSettings.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.update_data_redaction_settings", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateDataRedactionSettings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateDataRetentionSettings( @@ -17592,7 +24449,7 @@ 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.DataRetentionSettings: r"""Call the update data retention settings method over HTTP. @@ -17604,8 +24461,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.DataRetentionSettings: @@ -17617,6 +24476,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseUpdateDataRetentionSettings._get_http_options() ) + request, metadata = self._interceptor.pre_update_data_retention_settings( request, metadata ) @@ -17633,6 +24493,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.UpdateDataRetentionSettings", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateDataRetentionSettings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._UpdateDataRetentionSettings._get_response( self._host, @@ -17654,7 +24541,29 @@ def __call__( pb_resp = resources.DataRetentionSettings.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_data_retention_settings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.DataRetentionSettings.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.update_data_retention_settings", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateDataRetentionSettings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateDataStream( @@ -17693,7 +24602,7 @@ 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.DataStream: r"""Call the update data stream method over HTTP. @@ -17704,8 +24613,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.DataStream: @@ -17717,6 +24628,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseUpdateDataStream._get_http_options() ) + request, metadata = self._interceptor.pre_update_data_stream( request, metadata ) @@ -17733,6 +24645,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.UpdateDataStream", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateDataStream", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._UpdateDataStream._get_response( @@ -17756,7 +24695,29 @@ def __call__( pb_resp = resources.DataStream.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_data_stream(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.DataStream.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.update_data_stream", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateDataStream", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateDisplayVideo360AdvertiserLink( @@ -17797,7 +24758,7 @@ 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.DisplayVideo360AdvertiserLink: r"""Call the update display video360 advertiser link method over HTTP. @@ -17809,8 +24770,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.DisplayVideo360AdvertiserLink: @@ -17822,6 +24785,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseUpdateDisplayVideo360AdvertiserLink._get_http_options() ) + ( request, metadata, @@ -17841,6 +24805,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.UpdateDisplayVideo360AdvertiserLink", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateDisplayVideo360AdvertiserLink", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._UpdateDisplayVideo360AdvertiserLink._get_response( self._host, @@ -17862,7 +24853,31 @@ def __call__( pb_resp = resources.DisplayVideo360AdvertiserLink.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_display_video360_advertiser_link(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.DisplayVideo360AdvertiserLink.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.update_display_video360_advertiser_link", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateDisplayVideo360AdvertiserLink", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateEnhancedMeasurementSettings( @@ -17903,7 +24918,7 @@ 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.EnhancedMeasurementSettings: r"""Call the update enhanced measurement settings method over HTTP. @@ -17915,8 +24930,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.EnhancedMeasurementSettings: @@ -17930,6 +24947,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseUpdateEnhancedMeasurementSettings._get_http_options() ) + ( request, metadata, @@ -17949,6 +24967,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.UpdateEnhancedMeasurementSettings", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateEnhancedMeasurementSettings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._UpdateEnhancedMeasurementSettings._get_response( self._host, @@ -17970,7 +25015,31 @@ def __call__( pb_resp = resources.EnhancedMeasurementSettings.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_enhanced_measurement_settings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.EnhancedMeasurementSettings.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.update_enhanced_measurement_settings", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateEnhancedMeasurementSettings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateEventCreateRule( @@ -18009,7 +25078,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> event_create_and_edit.EventCreateRule: r"""Call the update event create rule method over HTTP. @@ -18020,8 +25089,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.event_create_and_edit.EventCreateRule: @@ -18045,6 +25116,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseUpdateEventCreateRule._get_http_options() ) + request, metadata = self._interceptor.pre_update_event_create_rule( request, metadata ) @@ -18061,6 +25133,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.UpdateEventCreateRule", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateEventCreateRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._UpdateEventCreateRule._get_response( @@ -18084,7 +25183,31 @@ def __call__( pb_resp = event_create_and_edit.EventCreateRule.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_event_create_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = event_create_and_edit.EventCreateRule.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.update_event_create_rule", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateEventCreateRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateEventEditRule( @@ -18123,7 +25246,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> event_create_and_edit.EventEditRule: r"""Call the update event edit rule method over HTTP. @@ -18134,8 +25257,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.event_create_and_edit.EventEditRule: @@ -18159,6 +25284,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseUpdateEventEditRule._get_http_options() ) + request, metadata = self._interceptor.pre_update_event_edit_rule( request, metadata ) @@ -18175,6 +25301,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.UpdateEventEditRule", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateEventEditRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._UpdateEventEditRule._get_response( @@ -18198,7 +25351,31 @@ def __call__( pb_resp = event_create_and_edit.EventEditRule.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_event_edit_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = event_create_and_edit.EventEditRule.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.update_event_edit_rule", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateEventEditRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateExpandedDataSet( @@ -18237,7 +25414,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gaa_expanded_data_set.ExpandedDataSet: r"""Call the update expanded data set method over HTTP. @@ -18248,8 +25425,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gaa_expanded_data_set.ExpandedDataSet: @@ -18261,6 +25440,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseUpdateExpandedDataSet._get_http_options() ) + request, metadata = self._interceptor.pre_update_expanded_data_set( request, metadata ) @@ -18277,6 +25457,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.UpdateExpandedDataSet", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateExpandedDataSet", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._UpdateExpandedDataSet._get_response( @@ -18300,7 +25507,31 @@ def __call__( pb_resp = gaa_expanded_data_set.ExpandedDataSet.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_expanded_data_set(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gaa_expanded_data_set.ExpandedDataSet.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.update_expanded_data_set", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateExpandedDataSet", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateGoogleAdsLink( @@ -18339,7 +25570,7 @@ 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.GoogleAdsLink: r"""Call the update google ads link method over HTTP. @@ -18350,8 +25581,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.GoogleAdsLink: @@ -18363,6 +25596,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseUpdateGoogleAdsLink._get_http_options() ) + request, metadata = self._interceptor.pre_update_google_ads_link( request, metadata ) @@ -18379,6 +25613,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.UpdateGoogleAdsLink", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateGoogleAdsLink", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._UpdateGoogleAdsLink._get_response( @@ -18402,7 +25663,29 @@ def __call__( pb_resp = resources.GoogleAdsLink.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_google_ads_link(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.GoogleAdsLink.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.update_google_ads_link", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateGoogleAdsLink", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateGoogleSignalsSettings( @@ -18443,7 +25726,7 @@ 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.GoogleSignalsSettings: r"""Call the update google signals settings method over HTTP. @@ -18455,8 +25738,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.GoogleSignalsSettings: @@ -18468,6 +25753,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseUpdateGoogleSignalsSettings._get_http_options() ) + request, metadata = self._interceptor.pre_update_google_signals_settings( request, metadata ) @@ -18484,6 +25770,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.UpdateGoogleSignalsSettings", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateGoogleSignalsSettings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._UpdateGoogleSignalsSettings._get_response( self._host, @@ -18505,7 +25818,29 @@ def __call__( pb_resp = resources.GoogleSignalsSettings.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_google_signals_settings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.GoogleSignalsSettings.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.update_google_signals_settings", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateGoogleSignalsSettings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateKeyEvent( @@ -18544,7 +25879,7 @@ 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.KeyEvent: r"""Call the update key event method over HTTP. @@ -18555,8 +25890,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.KeyEvent: @@ -18568,6 +25905,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseUpdateKeyEvent._get_http_options() ) + request, metadata = self._interceptor.pre_update_key_event( request, metadata ) @@ -18584,6 +25922,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.UpdateKeyEvent", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateKeyEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._UpdateKeyEvent._get_response( self._host, @@ -18605,7 +25970,29 @@ def __call__( pb_resp = resources.KeyEvent.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_key_event(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.KeyEvent.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.update_key_event", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateKeyEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateMeasurementProtocolSecret( @@ -18646,7 +26033,7 @@ 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.MeasurementProtocolSecret: r"""Call the update measurement protocol secret method over HTTP. @@ -18658,8 +26045,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.MeasurementProtocolSecret: @@ -18671,6 +26060,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseUpdateMeasurementProtocolSecret._get_http_options() ) + ( request, metadata, @@ -18690,6 +26080,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.UpdateMeasurementProtocolSecret", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateMeasurementProtocolSecret", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._UpdateMeasurementProtocolSecret._get_response( self._host, @@ -18711,7 +26128,31 @@ def __call__( pb_resp = resources.MeasurementProtocolSecret.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_measurement_protocol_secret(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.MeasurementProtocolSecret.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.update_measurement_protocol_secret", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateMeasurementProtocolSecret", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateProperty( @@ -18750,7 +26191,7 @@ 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.Property: r"""Call the update property method over HTTP. @@ -18761,8 +26202,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.Property: @@ -18774,6 +26217,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseUpdateProperty._get_http_options() ) + request, metadata = self._interceptor.pre_update_property(request, metadata) transcoded_request = _BaseAnalyticsAdminServiceRestTransport._BaseUpdateProperty._get_transcoded_request( http_options, request @@ -18788,6 +26232,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.UpdateProperty", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateProperty", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._UpdateProperty._get_response( self._host, @@ -18809,7 +26280,29 @@ def __call__( pb_resp = resources.Property.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_property(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Property.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.update_property", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateProperty", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSearchAds360Link( @@ -18848,7 +26341,7 @@ 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.SearchAds360Link: r"""Call the update search ads360 link method over HTTP. @@ -18859,8 +26352,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.SearchAds360Link: @@ -18872,6 +26367,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseUpdateSearchAds360Link._get_http_options() ) + request, metadata = self._interceptor.pre_update_search_ads360_link( request, metadata ) @@ -18888,6 +26384,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.UpdateSearchAds360Link", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateSearchAds360Link", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._UpdateSearchAds360Link._get_response( self._host, @@ -18909,7 +26432,29 @@ def __call__( pb_resp = resources.SearchAds360Link.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_search_ads360_link(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.SearchAds360Link.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.update_search_ads360_link", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateSearchAds360Link", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSKAdNetworkConversionValueSchema( @@ -18950,7 +26495,7 @@ 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.SKAdNetworkConversionValueSchema: r"""Call the update sk ad network conversion value schema method over HTTP. @@ -18963,8 +26508,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.SKAdNetworkConversionValueSchema: @@ -18976,6 +26523,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseUpdateSKAdNetworkConversionValueSchema._get_http_options() ) + ( request, metadata, @@ -18995,6 +26543,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.UpdateSKAdNetworkConversionValueSchema", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateSKAdNetworkConversionValueSchema", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._UpdateSKAdNetworkConversionValueSchema._get_response( self._host, @@ -19016,9 +26591,33 @@ def __call__( pb_resp = resources.SKAdNetworkConversionValueSchema.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_sk_ad_network_conversion_value_schema( resp ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + resources.SKAdNetworkConversionValueSchema.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.update_sk_ad_network_conversion_value_schema", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateSKAdNetworkConversionValueSchema", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSubpropertyEventFilter( @@ -19059,7 +26658,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gaa_subproperty_event_filter.SubpropertyEventFilter: r"""Call the update subproperty event filter method over HTTP. @@ -19071,8 +26670,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gaa_subproperty_event_filter.SubpropertyEventFilter: @@ -19084,6 +26685,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseUpdateSubpropertyEventFilter._get_http_options() ) + request, metadata = self._interceptor.pre_update_subproperty_event_filter( request, metadata ) @@ -19100,6 +26702,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.UpdateSubpropertyEventFilter", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateSubpropertyEventFilter", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._UpdateSubpropertyEventFilter._get_response( self._host, @@ -19121,7 +26750,33 @@ def __call__( pb_resp = gaa_subproperty_event_filter.SubpropertyEventFilter.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_subproperty_event_filter(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + gaa_subproperty_event_filter.SubpropertyEventFilter.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1alpha.AnalyticsAdminServiceClient.update_subproperty_event_filter", + extra={ + "serviceName": "google.analytics.admin.v1alpha.AnalyticsAdminService", + "rpcName": "UpdateSubpropertyEventFilter", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-analytics-admin/google/analytics/admin_v1beta/gapic_version.py b/packages/google-analytics-admin/google/analytics/admin_v1beta/gapic_version.py index ea568fc1a5a7..558c8aab67c5 100644 --- a/packages/google-analytics-admin/google/analytics/admin_v1beta/gapic_version.py +++ b/packages/google-analytics-admin/google/analytics/admin_v1beta/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.23.2" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-analytics-admin/google/analytics/admin_v1beta/services/analytics_admin_service/async_client.py b/packages/google-analytics-admin/google/analytics/admin_v1beta/services/analytics_admin_service/async_client.py index a86919c6511d..107b8f72bce8 100644 --- a/packages/google-analytics-admin/google/analytics/admin_v1beta/services/analytics_admin_service/async_client.py +++ b/packages/google-analytics-admin/google/analytics/admin_v1beta/services/analytics_admin_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, AnalyticsAdminServiceTransport from .transports.grpc_asyncio import AnalyticsAdminServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class AnalyticsAdminServiceAsyncClient: """Service Interface for the Analytics Admin API (GA4).""" @@ -333,6 +343,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.analytics.admin_v1beta.AnalyticsAdminServiceAsyncClient`.", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "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.analytics.admin.v1beta.AnalyticsAdminService", + "credentialsType": None, + }, + ) + async def get_account( self, request: Optional[Union[analytics_admin.GetAccountRequest, dict]] = None, @@ -340,7 +372,7 @@ async def get_account( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Account: r"""Lookup for a single Account. @@ -384,8 +416,10 @@ async def sample_get_account(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.Account: @@ -445,7 +479,7 @@ async def list_accounts( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAccountsAsyncPager: r"""Returns all accounts accessible by the caller. @@ -486,8 +520,10 @@ async def sample_list_accounts(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListAccountsAsyncPager: @@ -542,7 +578,7 @@ async def delete_account( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Marks target Account as soft-deleted (ie: "trashed") and returns it. @@ -596,8 +632,10 @@ async def sample_delete_account(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -650,7 +688,7 @@ async def update_account( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Account: r"""Updates an account. @@ -707,8 +745,10 @@ async def sample_update_account(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.Account: @@ -774,7 +814,7 @@ async def provision_account_ticket( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ProvisionAccountTicketResponse: r"""Requests a ticket for creating an account. @@ -810,8 +850,10 @@ async def sample_provision_account_ticket(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.ProvisionAccountTicketResponse: @@ -853,7 +895,7 @@ async def list_account_summaries( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAccountSummariesAsyncPager: r"""Returns summaries of all accounts accessible by the caller. @@ -891,8 +933,10 @@ async def sample_list_account_summaries(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListAccountSummariesAsyncPager: @@ -947,7 +991,7 @@ async def get_property( name: Optional[str] = None, retry: OptionalRetry = 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.Property: r"""Lookup for a single "GA4" Property. @@ -990,8 +1034,10 @@ async def sample_get_property(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.Property: @@ -1051,7 +1097,7 @@ async def list_properties( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPropertiesAsyncPager: r"""Returns child Properties under the specified parent Account. @@ -1095,8 +1141,10 @@ async def sample_list_properties(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListPropertiesAsyncPager: @@ -1151,7 +1199,7 @@ async def create_property( property: Optional[resources.Property] = None, retry: OptionalRetry = 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.Property: r"""Creates an "GA4" property with the specified location and attributes. @@ -1201,8 +1249,10 @@ async def sample_create_property(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.Property: @@ -1257,7 +1307,7 @@ async def delete_property( name: Optional[str] = None, retry: OptionalRetry = 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.Property: r"""Marks target Property as soft-deleted (ie: "trashed") and returns it. @@ -1315,8 +1365,10 @@ async def sample_delete_property(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.Property: @@ -1378,7 +1430,7 @@ async def update_property( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Property: r"""Updates a property. @@ -1437,8 +1489,10 @@ async def sample_update_property(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.Property: @@ -1506,7 +1560,7 @@ async def create_firebase_link( firebase_link: Optional[resources.FirebaseLink] = None, retry: OptionalRetry = 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.FirebaseLink: r"""Creates a FirebaseLink. @@ -1560,8 +1614,10 @@ async def sample_create_firebase_link(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.FirebaseLink: @@ -1626,7 +1682,7 @@ async def delete_firebase_link( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 FirebaseLink on a property @@ -1669,8 +1725,10 @@ async def sample_delete_firebase_link(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -1722,7 +1780,7 @@ async def list_firebase_links( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListFirebaseLinksAsyncPager: r"""Lists FirebaseLinks on a property. Properties can have at most one FirebaseLink. @@ -1769,8 +1827,10 @@ async def sample_list_firebase_links(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListFirebaseLinksAsyncPager: @@ -1848,7 +1908,7 @@ async def create_google_ads_link( google_ads_link: Optional[resources.GoogleAdsLink] = None, retry: OptionalRetry = 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.GoogleAdsLink: r"""Creates a GoogleAdsLink. @@ -1899,8 +1959,10 @@ async def sample_create_google_ads_link(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.GoogleAdsLink: @@ -1966,7 +2028,7 @@ async def update_google_ads_link( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.GoogleAdsLink: r"""Updates a GoogleAdsLink on a property @@ -2017,8 +2079,10 @@ async def sample_update_google_ads_link(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.GoogleAdsLink: @@ -2085,7 +2149,7 @@ async def delete_google_ads_link( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 GoogleAdsLink on a property @@ -2126,8 +2190,10 @@ async def sample_delete_google_ads_link(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -2181,7 +2247,7 @@ async def list_google_ads_links( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListGoogleAdsLinksAsyncPager: r"""Lists GoogleAdsLinks on a property. @@ -2226,8 +2292,10 @@ async def sample_list_google_ads_links(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListGoogleAdsLinksAsyncPager: @@ -2304,7 +2372,7 @@ async def get_data_sharing_settings( name: Optional[str] = None, retry: OptionalRetry = 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.DataSharingSettings: r"""Get data sharing settings on an account. Data sharing settings are singletons. @@ -2351,8 +2419,10 @@ async def sample_get_data_sharing_settings(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.DataSharingSettings: @@ -2416,7 +2486,7 @@ async def get_measurement_protocol_secret( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.MeasurementProtocolSecret: r"""Lookup for a single "GA4" MeasurementProtocolSecret. @@ -2462,8 +2532,10 @@ async def sample_get_measurement_protocol_secret(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.MeasurementProtocolSecret: @@ -2526,7 +2598,7 @@ async def list_measurement_protocol_secrets( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListMeasurementProtocolSecretsAsyncPager: r"""Returns child MeasurementProtocolSecrets under the specified parent Property. @@ -2574,8 +2646,10 @@ async def sample_list_measurement_protocol_secrets(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListMeasurementProtocolSecretsAsyncPager: @@ -2657,7 +2731,7 @@ async def create_measurement_protocol_secret( ] = None, retry: OptionalRetry = 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.MeasurementProtocolSecret: r"""Creates a measurement protocol secret. @@ -2713,8 +2787,10 @@ async def sample_create_measurement_protocol_secret(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.MeasurementProtocolSecret: @@ -2781,7 +2857,7 @@ async def delete_measurement_protocol_secret( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes target MeasurementProtocolSecret. @@ -2825,8 +2901,10 @@ async def sample_delete_measurement_protocol_secret(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2885,7 +2963,7 @@ async def update_measurement_protocol_secret( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.MeasurementProtocolSecret: r"""Updates a measurement protocol secret. @@ -2940,8 +3018,10 @@ async def sample_update_measurement_protocol_secret(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.MeasurementProtocolSecret: @@ -3014,7 +3094,7 @@ async def acknowledge_user_data_collection( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.AcknowledgeUserDataCollectionResponse: r"""Acknowledges the terms of user data collection for the specified property. @@ -3056,8 +3136,10 @@ async def sample_acknowledge_user_data_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.analytics.admin_v1beta.types.AcknowledgeUserDataCollectionResponse: @@ -3107,7 +3189,7 @@ async def search_change_history_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]]] = (), ) -> pagers.SearchChangeHistoryEventsAsyncPager: r"""Searches through all changes to an account or its children given the specified set of filters. @@ -3146,8 +3228,10 @@ async def sample_search_change_history_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.analytics.admin_v1beta.services.analytics_admin_service.pagers.SearchChangeHistoryEventsAsyncPager: @@ -3211,7 +3295,7 @@ async def create_conversion_event( conversion_event: Optional[resources.ConversionEvent] = None, retry: OptionalRetry = 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.ConversionEvent: r"""Deprecated: Use ``CreateKeyEvent`` instead. Creates a conversion event with the specified attributes. @@ -3265,8 +3349,10 @@ async def sample_create_conversion_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.analytics.admin_v1beta.types.ConversionEvent: @@ -3337,7 +3423,7 @@ async def update_conversion_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]]] = (), ) -> resources.ConversionEvent: r"""Deprecated: Use ``UpdateKeyEvent`` instead. Updates a conversion event with the specified attributes. @@ -3391,8 +3477,10 @@ async def sample_update_conversion_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.analytics.admin_v1beta.types.ConversionEvent: @@ -3464,7 +3552,7 @@ async def get_conversion_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.ConversionEvent: r"""Deprecated: Use ``GetKeyEvent`` instead. Retrieve a single conversion event. @@ -3511,8 +3599,10 @@ async def sample_get_conversion_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.analytics.admin_v1beta.types.ConversionEvent: @@ -3580,7 +3670,7 @@ async def delete_conversion_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"""Deprecated: Use ``DeleteKeyEvent`` instead. Deletes a conversion event in a property. @@ -3624,8 +3714,10 @@ async def sample_delete_conversion_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`. """ warnings.warn( "AnalyticsAdminServiceAsyncClient.delete_conversion_event is deprecated", @@ -3684,7 +3776,7 @@ async def list_conversion_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.ListConversionEventsAsyncPager: r"""Deprecated: Use ``ListKeyEvents`` instead. Returns a list of conversion events in the specified parent property. @@ -3733,8 +3825,10 @@ async def sample_list_conversion_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.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListConversionEventsAsyncPager: @@ -3815,7 +3909,7 @@ async def create_key_event( key_event: Optional[resources.KeyEvent] = None, retry: OptionalRetry = 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.KeyEvent: r"""Creates a Key Event. @@ -3869,8 +3963,10 @@ async def sample_create_key_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.analytics.admin_v1beta.types.KeyEvent: @@ -3934,7 +4030,7 @@ async def update_key_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]]] = (), ) -> resources.KeyEvent: r"""Updates a Key Event. @@ -3991,8 +4087,10 @@ async def sample_update_key_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.analytics.admin_v1beta.types.KeyEvent: @@ -4057,7 +4155,7 @@ async def get_key_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.KeyEvent: r"""Retrieve a single Key Event. @@ -4102,8 +4200,10 @@ async def sample_get_key_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.analytics.admin_v1beta.types.KeyEvent: @@ -4164,7 +4264,7 @@ async def delete_key_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 a Key Event. @@ -4206,8 +4306,10 @@ async def sample_delete_key_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 @@ -4259,7 +4361,7 @@ async def list_key_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.ListKeyEventsAsyncPager: r"""Returns a list of Key Events in the specified parent property. Returns an empty list if no Key Events are @@ -4306,8 +4408,10 @@ async def sample_list_key_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.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListKeyEventsAsyncPager: @@ -4385,7 +4489,7 @@ async def create_custom_dimension( custom_dimension: Optional[resources.CustomDimension] = None, retry: OptionalRetry = 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.CustomDimension: r"""Creates a CustomDimension. @@ -4442,8 +4546,10 @@ async def sample_create_custom_dimension(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.CustomDimension: @@ -4507,7 +4613,7 @@ async def update_custom_dimension( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.CustomDimension: r"""Updates a CustomDimension on a property. @@ -4557,8 +4663,10 @@ async def sample_update_custom_dimension(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.CustomDimension: @@ -4623,7 +4731,7 @@ async def list_custom_dimensions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCustomDimensionsAsyncPager: r"""Lists CustomDimensions on a property. @@ -4668,8 +4776,10 @@ async def sample_list_custom_dimensions(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListCustomDimensionsAsyncPager: @@ -4746,7 +4856,7 @@ async def archive_custom_dimension( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Archives a CustomDimension on a property. @@ -4789,8 +4899,10 @@ async def sample_archive_custom_dimension(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -4844,7 +4956,7 @@ async def get_custom_dimension( name: Optional[str] = None, retry: OptionalRetry = 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.CustomDimension: r"""Lookup for a single CustomDimension. @@ -4889,8 +5001,10 @@ async def sample_get_custom_dimension(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.CustomDimension: @@ -4952,7 +5066,7 @@ async def create_custom_metric( custom_metric: Optional[resources.CustomMetric] = None, retry: OptionalRetry = 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.CustomMetric: r"""Creates a CustomMetric. @@ -5008,8 +5122,10 @@ async def sample_create_custom_metric(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.CustomMetric: @@ -5073,7 +5189,7 @@ async def update_custom_metric( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.CustomMetric: r"""Updates a CustomMetric on a property. @@ -5123,8 +5239,10 @@ async def sample_update_custom_metric(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.CustomMetric: @@ -5187,7 +5305,7 @@ async def list_custom_metrics( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCustomMetricsAsyncPager: r"""Lists CustomMetrics on a property. @@ -5232,8 +5350,10 @@ async def sample_list_custom_metrics(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListCustomMetricsAsyncPager: @@ -5310,7 +5430,7 @@ async def archive_custom_metric( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Archives a CustomMetric on a property. @@ -5352,8 +5472,10 @@ async def sample_archive_custom_metric(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -5405,7 +5527,7 @@ async def get_custom_metric( name: Optional[str] = None, retry: OptionalRetry = 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.CustomMetric: r"""Lookup for a single CustomMetric. @@ -5450,8 +5572,10 @@ async def sample_get_custom_metric(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.CustomMetric: @@ -5512,7 +5636,7 @@ async def get_data_retention_settings( name: Optional[str] = None, retry: OptionalRetry = 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.DataRetentionSettings: r"""Returns the singleton data retention settings for this property. @@ -5561,8 +5685,10 @@ async def sample_get_data_retention_settings(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.DataRetentionSettings: @@ -5626,7 +5752,7 @@ async def update_data_retention_settings( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.DataRetentionSettings: r"""Updates the singleton data retention settings for this property. @@ -5680,8 +5806,10 @@ async def sample_update_data_retention_settings(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.DataRetentionSettings: @@ -5752,7 +5880,7 @@ async def create_data_stream( data_stream: Optional[resources.DataStream] = None, retry: OptionalRetry = 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.DataStream: r"""Creates a DataStream. @@ -5805,8 +5933,10 @@ async def sample_create_data_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.analytics.admin_v1beta.types.DataStream: @@ -5869,7 +5999,7 @@ async def delete_data_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]]] = (), ) -> None: r"""Deletes a DataStream on a property. @@ -5911,8 +6041,10 @@ async def sample_delete_data_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -5965,7 +6097,7 @@ async def update_data_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]]] = (), ) -> resources.DataStream: r"""Updates a DataStream on a property. @@ -6015,8 +6147,10 @@ async def sample_update_data_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.analytics.admin_v1beta.types.DataStream: @@ -6081,7 +6215,7 @@ async def list_data_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.ListDataStreamsAsyncPager: r"""Lists DataStreams on a property. @@ -6126,8 +6260,10 @@ async def sample_list_data_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.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListDataStreamsAsyncPager: @@ -6202,7 +6338,7 @@ async def get_data_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]]] = (), ) -> resources.DataStream: r"""Lookup for a single DataStream. @@ -6247,8 +6383,10 @@ async def sample_get_data_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.analytics.admin_v1beta.types.DataStream: @@ -6308,7 +6446,7 @@ async def run_access_report( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.RunAccessReportResponse: r"""Returns a customized report of data access records. The report provides records of each time a user reads Google Analytics @@ -6359,8 +6497,10 @@ async def sample_run_access_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.analytics.admin_v1beta.types.RunAccessReportResponse: diff --git a/packages/google-analytics-admin/google/analytics/admin_v1beta/services/analytics_admin_service/client.py b/packages/google-analytics-admin/google/analytics/admin_v1beta/services/analytics_admin_service/client.py index 990b9511e610..3a4869c9106b 100644 --- a/packages/google-analytics-admin/google/analytics/admin_v1beta/services/analytics_admin_service/client.py +++ b/packages/google-analytics-admin/google/analytics/admin_v1beta/services/analytics_admin_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore from google.protobuf import wrappers_pb2 # type: ignore @@ -818,6 +828,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( @@ -884,6 +898,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.analytics.admin_v1beta.AnalyticsAdminServiceClient`.", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "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.analytics.admin.v1beta.AnalyticsAdminService", + "credentialsType": None, + }, + ) + def get_account( self, request: Optional[Union[analytics_admin.GetAccountRequest, dict]] = None, @@ -891,7 +928,7 @@ def get_account( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Account: r"""Lookup for a single Account. @@ -935,8 +972,10 @@ def sample_get_account(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.Account: @@ -993,7 +1032,7 @@ def list_accounts( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAccountsPager: r"""Returns all accounts accessible by the caller. @@ -1034,8 +1073,10 @@ def sample_list_accounts(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListAccountsPager: @@ -1088,7 +1129,7 @@ def delete_account( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Marks target Account as soft-deleted (ie: "trashed") and returns it. @@ -1142,8 +1183,10 @@ def sample_delete_account(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1193,7 +1236,7 @@ def update_account( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Account: r"""Updates an account. @@ -1250,8 +1293,10 @@ def sample_update_account(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.Account: @@ -1314,7 +1359,7 @@ def provision_account_ticket( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ProvisionAccountTicketResponse: r"""Requests a ticket for creating an account. @@ -1350,8 +1395,10 @@ def sample_provision_account_ticket(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.ProvisionAccountTicketResponse: @@ -1391,7 +1438,7 @@ def list_account_summaries( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAccountSummariesPager: r"""Returns summaries of all accounts accessible by the caller. @@ -1429,8 +1476,10 @@ def sample_list_account_summaries(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListAccountSummariesPager: @@ -1483,7 +1532,7 @@ def get_property( name: Optional[str] = None, retry: OptionalRetry = 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.Property: r"""Lookup for a single "GA4" Property. @@ -1526,8 +1575,10 @@ def sample_get_property(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.Property: @@ -1584,7 +1635,7 @@ def list_properties( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPropertiesPager: r"""Returns child Properties under the specified parent Account. @@ -1628,8 +1679,10 @@ def sample_list_properties(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListPropertiesPager: @@ -1682,7 +1735,7 @@ def create_property( property: Optional[resources.Property] = None, retry: OptionalRetry = 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.Property: r"""Creates an "GA4" property with the specified location and attributes. @@ -1732,8 +1785,10 @@ def sample_create_property(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.Property: @@ -1785,7 +1840,7 @@ def delete_property( name: Optional[str] = None, retry: OptionalRetry = 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.Property: r"""Marks target Property as soft-deleted (ie: "trashed") and returns it. @@ -1843,8 +1898,10 @@ def sample_delete_property(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.Property: @@ -1903,7 +1960,7 @@ def update_property( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Property: r"""Updates a property. @@ -1962,8 +2019,10 @@ def sample_update_property(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.Property: @@ -2028,7 +2087,7 @@ def create_firebase_link( firebase_link: Optional[resources.FirebaseLink] = None, retry: OptionalRetry = 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.FirebaseLink: r"""Creates a FirebaseLink. @@ -2082,8 +2141,10 @@ def sample_create_firebase_link(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.FirebaseLink: @@ -2145,7 +2206,7 @@ def delete_firebase_link( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 FirebaseLink on a property @@ -2188,8 +2249,10 @@ def sample_delete_firebase_link(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -2238,7 +2301,7 @@ def list_firebase_links( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListFirebaseLinksPager: r"""Lists FirebaseLinks on a property. Properties can have at most one FirebaseLink. @@ -2285,8 +2348,10 @@ def sample_list_firebase_links(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListFirebaseLinksPager: @@ -2361,7 +2426,7 @@ def create_google_ads_link( google_ads_link: Optional[resources.GoogleAdsLink] = None, retry: OptionalRetry = 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.GoogleAdsLink: r"""Creates a GoogleAdsLink. @@ -2412,8 +2477,10 @@ def sample_create_google_ads_link(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.GoogleAdsLink: @@ -2476,7 +2543,7 @@ def update_google_ads_link( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.GoogleAdsLink: r"""Updates a GoogleAdsLink on a property @@ -2527,8 +2594,10 @@ def sample_update_google_ads_link(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.GoogleAdsLink: @@ -2592,7 +2661,7 @@ def delete_google_ads_link( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 GoogleAdsLink on a property @@ -2633,8 +2702,10 @@ def sample_delete_google_ads_link(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -2685,7 +2756,7 @@ def list_google_ads_links( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListGoogleAdsLinksPager: r"""Lists GoogleAdsLinks on a property. @@ -2730,8 +2801,10 @@ def sample_list_google_ads_links(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListGoogleAdsLinksPager: @@ -2805,7 +2878,7 @@ def get_data_sharing_settings( name: Optional[str] = None, retry: OptionalRetry = 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.DataSharingSettings: r"""Get data sharing settings on an account. Data sharing settings are singletons. @@ -2852,8 +2925,10 @@ def sample_get_data_sharing_settings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.DataSharingSettings: @@ -2916,7 +2991,7 @@ def get_measurement_protocol_secret( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.MeasurementProtocolSecret: r"""Lookup for a single "GA4" MeasurementProtocolSecret. @@ -2962,8 +3037,10 @@ def sample_get_measurement_protocol_secret(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.MeasurementProtocolSecret: @@ -3025,7 +3102,7 @@ def list_measurement_protocol_secrets( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListMeasurementProtocolSecretsPager: r"""Returns child MeasurementProtocolSecrets under the specified parent Property. @@ -3073,8 +3150,10 @@ def sample_list_measurement_protocol_secrets(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListMeasurementProtocolSecretsPager: @@ -3155,7 +3234,7 @@ def create_measurement_protocol_secret( ] = None, retry: OptionalRetry = 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.MeasurementProtocolSecret: r"""Creates a measurement protocol secret. @@ -3211,8 +3290,10 @@ def sample_create_measurement_protocol_secret(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.MeasurementProtocolSecret: @@ -3278,7 +3359,7 @@ def delete_measurement_protocol_secret( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes target MeasurementProtocolSecret. @@ -3322,8 +3403,10 @@ def sample_delete_measurement_protocol_secret(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -3381,7 +3464,7 @@ def update_measurement_protocol_secret( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.MeasurementProtocolSecret: r"""Updates a measurement protocol secret. @@ -3436,8 +3519,10 @@ def sample_update_measurement_protocol_secret(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.MeasurementProtocolSecret: @@ -3509,7 +3594,7 @@ def acknowledge_user_data_collection( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.AcknowledgeUserDataCollectionResponse: r"""Acknowledges the terms of user data collection for the specified property. @@ -3551,8 +3636,10 @@ def sample_acknowledge_user_data_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.analytics.admin_v1beta.types.AcknowledgeUserDataCollectionResponse: @@ -3602,7 +3689,7 @@ def search_change_history_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]]] = (), ) -> pagers.SearchChangeHistoryEventsPager: r"""Searches through all changes to an account or its children given the specified set of filters. @@ -3641,8 +3728,10 @@ def sample_search_change_history_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.analytics.admin_v1beta.services.analytics_admin_service.pagers.SearchChangeHistoryEventsPager: @@ -3706,7 +3795,7 @@ def create_conversion_event( conversion_event: Optional[resources.ConversionEvent] = None, retry: OptionalRetry = 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.ConversionEvent: r"""Deprecated: Use ``CreateKeyEvent`` instead. Creates a conversion event with the specified attributes. @@ -3760,8 +3849,10 @@ def sample_create_conversion_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.analytics.admin_v1beta.types.ConversionEvent: @@ -3829,7 +3920,7 @@ def update_conversion_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]]] = (), ) -> resources.ConversionEvent: r"""Deprecated: Use ``UpdateKeyEvent`` instead. Updates a conversion event with the specified attributes. @@ -3883,8 +3974,10 @@ def sample_update_conversion_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.analytics.admin_v1beta.types.ConversionEvent: @@ -3953,7 +4046,7 @@ def get_conversion_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.ConversionEvent: r"""Deprecated: Use ``GetKeyEvent`` instead. Retrieve a single conversion event. @@ -4000,8 +4093,10 @@ def sample_get_conversion_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.analytics.admin_v1beta.types.ConversionEvent: @@ -4066,7 +4161,7 @@ def delete_conversion_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"""Deprecated: Use ``DeleteKeyEvent`` instead. Deletes a conversion event in a property. @@ -4110,8 +4205,10 @@ def sample_delete_conversion_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`. """ warnings.warn( "AnalyticsAdminServiceClient.delete_conversion_event is deprecated", @@ -4167,7 +4264,7 @@ def list_conversion_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.ListConversionEventsPager: r"""Deprecated: Use ``ListKeyEvents`` instead. Returns a list of conversion events in the specified parent property. @@ -4216,8 +4313,10 @@ def sample_list_conversion_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.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListConversionEventsPager: @@ -4295,7 +4394,7 @@ def create_key_event( key_event: Optional[resources.KeyEvent] = None, retry: OptionalRetry = 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.KeyEvent: r"""Creates a Key Event. @@ -4349,8 +4448,10 @@ def sample_create_key_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.analytics.admin_v1beta.types.KeyEvent: @@ -4411,7 +4512,7 @@ def update_key_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]]] = (), ) -> resources.KeyEvent: r"""Updates a Key Event. @@ -4468,8 +4569,10 @@ def sample_update_key_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.analytics.admin_v1beta.types.KeyEvent: @@ -4531,7 +4634,7 @@ def get_key_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.KeyEvent: r"""Retrieve a single Key Event. @@ -4576,8 +4679,10 @@ def sample_get_key_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.analytics.admin_v1beta.types.KeyEvent: @@ -4635,7 +4740,7 @@ def delete_key_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 a Key Event. @@ -4677,8 +4782,10 @@ def sample_delete_key_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 @@ -4727,7 +4834,7 @@ def list_key_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.ListKeyEventsPager: r"""Returns a list of Key Events in the specified parent property. Returns an empty list if no Key Events are @@ -4774,8 +4881,10 @@ def sample_list_key_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.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListKeyEventsPager: @@ -4850,7 +4959,7 @@ def create_custom_dimension( custom_dimension: Optional[resources.CustomDimension] = None, retry: OptionalRetry = 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.CustomDimension: r"""Creates a CustomDimension. @@ -4907,8 +5016,10 @@ def sample_create_custom_dimension(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.CustomDimension: @@ -4969,7 +5080,7 @@ def update_custom_dimension( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.CustomDimension: r"""Updates a CustomDimension on a property. @@ -5019,8 +5130,10 @@ def sample_update_custom_dimension(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.CustomDimension: @@ -5082,7 +5195,7 @@ def list_custom_dimensions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCustomDimensionsPager: r"""Lists CustomDimensions on a property. @@ -5127,8 +5240,10 @@ def sample_list_custom_dimensions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListCustomDimensionsPager: @@ -5202,7 +5317,7 @@ def archive_custom_dimension( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Archives a CustomDimension on a property. @@ -5245,8 +5360,10 @@ def sample_archive_custom_dimension(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -5297,7 +5414,7 @@ def get_custom_dimension( name: Optional[str] = None, retry: OptionalRetry = 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.CustomDimension: r"""Lookup for a single CustomDimension. @@ -5342,8 +5459,10 @@ def sample_get_custom_dimension(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.CustomDimension: @@ -5402,7 +5521,7 @@ def create_custom_metric( custom_metric: Optional[resources.CustomMetric] = None, retry: OptionalRetry = 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.CustomMetric: r"""Creates a CustomMetric. @@ -5458,8 +5577,10 @@ def sample_create_custom_metric(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.CustomMetric: @@ -5520,7 +5641,7 @@ def update_custom_metric( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.CustomMetric: r"""Updates a CustomMetric on a property. @@ -5570,8 +5691,10 @@ def sample_update_custom_metric(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.CustomMetric: @@ -5631,7 +5754,7 @@ def list_custom_metrics( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCustomMetricsPager: r"""Lists CustomMetrics on a property. @@ -5676,8 +5799,10 @@ def sample_list_custom_metrics(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListCustomMetricsPager: @@ -5751,7 +5876,7 @@ def archive_custom_metric( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Archives a CustomMetric on a property. @@ -5793,8 +5918,10 @@ def sample_archive_custom_metric(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -5843,7 +5970,7 @@ def get_custom_metric( name: Optional[str] = None, retry: OptionalRetry = 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.CustomMetric: r"""Lookup for a single CustomMetric. @@ -5888,8 +6015,10 @@ def sample_get_custom_metric(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.CustomMetric: @@ -5947,7 +6076,7 @@ def get_data_retention_settings( name: Optional[str] = None, retry: OptionalRetry = 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.DataRetentionSettings: r"""Returns the singleton data retention settings for this property. @@ -5996,8 +6125,10 @@ def sample_get_data_retention_settings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.DataRetentionSettings: @@ -6060,7 +6191,7 @@ def update_data_retention_settings( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.DataRetentionSettings: r"""Updates the singleton data retention settings for this property. @@ -6114,8 +6245,10 @@ def sample_update_data_retention_settings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.admin_v1beta.types.DataRetentionSettings: @@ -6185,7 +6318,7 @@ def create_data_stream( data_stream: Optional[resources.DataStream] = None, retry: OptionalRetry = 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.DataStream: r"""Creates a DataStream. @@ -6238,8 +6371,10 @@ def sample_create_data_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.analytics.admin_v1beta.types.DataStream: @@ -6299,7 +6434,7 @@ def delete_data_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]]] = (), ) -> None: r"""Deletes a DataStream on a property. @@ -6341,8 +6476,10 @@ def sample_delete_data_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -6392,7 +6529,7 @@ def update_data_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]]] = (), ) -> resources.DataStream: r"""Updates a DataStream on a property. @@ -6442,8 +6579,10 @@ def sample_update_data_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.analytics.admin_v1beta.types.DataStream: @@ -6505,7 +6644,7 @@ def list_data_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.ListDataStreamsPager: r"""Lists DataStreams on a property. @@ -6550,8 +6689,10 @@ def sample_list_data_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.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListDataStreamsPager: @@ -6623,7 +6764,7 @@ def get_data_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]]] = (), ) -> resources.DataStream: r"""Lookup for a single DataStream. @@ -6668,8 +6809,10 @@ def sample_get_data_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.analytics.admin_v1beta.types.DataStream: @@ -6726,7 +6869,7 @@ def run_access_report( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.RunAccessReportResponse: r"""Returns a customized report of data access records. The report provides records of each time a user reads Google Analytics @@ -6777,8 +6920,10 @@ def sample_run_access_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.analytics.admin_v1beta.types.RunAccessReportResponse: diff --git a/packages/google-analytics-admin/google/analytics/admin_v1beta/services/analytics_admin_service/pagers.py b/packages/google-analytics-admin/google/analytics/admin_v1beta/services/analytics_admin_service/pagers.py index 96b3c9c0e2c3..2c258debee24 100644 --- a/packages/google-analytics-admin/google/analytics/admin_v1beta/services/analytics_admin_service/pagers.py +++ b/packages/google-analytics-admin/google/analytics/admin_v1beta/services/analytics_admin_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 = analytics_admin.ListAccountsRequest(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 = analytics_admin.ListAccountsRequest(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 = analytics_admin.ListAccountSummariesRequest(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 = analytics_admin.ListAccountSummariesRequest(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 = analytics_admin.ListPropertiesRequest(request) @@ -447,7 +457,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -461,8 +471,10 @@ def __init__( retry (google.api_core.retry.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = analytics_admin.ListPropertiesRequest(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 = analytics_admin.ListFirebaseLinksRequest(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 = analytics_admin.ListFirebaseLinksRequest(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 = analytics_admin.ListGoogleAdsLinksRequest(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 = analytics_admin.ListGoogleAdsLinksRequest(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 = analytics_admin.ListMeasurementProtocolSecretsRequest(request) @@ -905,7 +927,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. @@ -919,8 +941,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 = analytics_admin.ListMeasurementProtocolSecretsRequest(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 = analytics_admin.SearchChangeHistoryEventsRequest(request) @@ -1061,7 +1087,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. @@ -1075,8 +1101,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 = analytics_admin.SearchChangeHistoryEventsRequest(request) @@ -1141,7 +1169,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1155,8 +1183,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = analytics_admin.ListConversionEventsRequest(request) @@ -1215,7 +1245,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. @@ -1229,8 +1259,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 = analytics_admin.ListConversionEventsRequest(request) @@ -1295,7 +1327,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1309,8 +1341,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = analytics_admin.ListKeyEventsRequest(request) @@ -1369,7 +1403,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. @@ -1383,8 +1417,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 = analytics_admin.ListKeyEventsRequest(request) @@ -1447,7 +1483,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1461,8 +1497,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = analytics_admin.ListCustomDimensionsRequest(request) @@ -1521,7 +1559,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. @@ -1535,8 +1573,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 = analytics_admin.ListCustomDimensionsRequest(request) @@ -1601,7 +1641,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1615,8 +1655,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = analytics_admin.ListCustomMetricsRequest(request) @@ -1675,7 +1717,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. @@ -1689,8 +1731,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 = analytics_admin.ListCustomMetricsRequest(request) @@ -1753,7 +1797,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1767,8 +1811,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = analytics_admin.ListDataStreamsRequest(request) @@ -1827,7 +1873,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. @@ -1841,8 +1887,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 = analytics_admin.ListDataStreamsRequest(request) diff --git a/packages/google-analytics-admin/google/analytics/admin_v1beta/services/analytics_admin_service/transports/grpc.py b/packages/google-analytics-admin/google/analytics/admin_v1beta/services/analytics_admin_service/transports/grpc.py index 01197530dc04..e9a092d465a2 100644 --- a/packages/google-analytics-admin/google/analytics/admin_v1beta/services/analytics_admin_service/transports/grpc.py +++ b/packages/google-analytics-admin/google/analytics/admin_v1beta/services/analytics_admin_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.analytics.admin_v1beta.types import analytics_admin, resources from .base import DEFAULT_CLIENT_INFO, AnalyticsAdminServiceTransport +try: + from google.api_core import client_logging # 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.analytics.admin.v1beta.AnalyticsAdminService", + "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.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AnalyticsAdminServiceGrpcTransport(AnalyticsAdminServiceTransport): """gRPC backend transport for AnalyticsAdminService. @@ -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 @@ -254,7 +340,7 @@ def get_account( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_account" not in self._stubs: - self._stubs["get_account"] = self.grpc_channel.unary_unary( + self._stubs["get_account"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/GetAccount", request_serializer=analytics_admin.GetAccountRequest.serialize, response_deserializer=resources.Account.deserialize, @@ -287,7 +373,7 @@ def list_accounts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_accounts" not in self._stubs: - self._stubs["list_accounts"] = self.grpc_channel.unary_unary( + self._stubs["list_accounts"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/ListAccounts", request_serializer=analytics_admin.ListAccountsRequest.serialize, response_deserializer=analytics_admin.ListAccountsResponse.deserialize, @@ -325,7 +411,7 @@ def delete_account( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_account" not in self._stubs: - self._stubs["delete_account"] = self.grpc_channel.unary_unary( + self._stubs["delete_account"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/DeleteAccount", request_serializer=analytics_admin.DeleteAccountRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -351,7 +437,7 @@ def update_account( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_account" not in self._stubs: - self._stubs["update_account"] = self.grpc_channel.unary_unary( + self._stubs["update_account"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/UpdateAccount", request_serializer=analytics_admin.UpdateAccountRequest.serialize, response_deserializer=resources.Account.deserialize, @@ -380,7 +466,7 @@ def provision_account_ticket( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "provision_account_ticket" not in self._stubs: - self._stubs["provision_account_ticket"] = self.grpc_channel.unary_unary( + self._stubs["provision_account_ticket"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/ProvisionAccountTicket", request_serializer=analytics_admin.ProvisionAccountTicketRequest.serialize, response_deserializer=analytics_admin.ProvisionAccountTicketResponse.deserialize, @@ -410,7 +496,7 @@ def list_account_summaries( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_account_summaries" not in self._stubs: - self._stubs["list_account_summaries"] = self.grpc_channel.unary_unary( + self._stubs["list_account_summaries"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/ListAccountSummaries", request_serializer=analytics_admin.ListAccountSummariesRequest.serialize, response_deserializer=analytics_admin.ListAccountSummariesResponse.deserialize, @@ -436,7 +522,7 @@ def get_property( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_property" not in self._stubs: - self._stubs["get_property"] = self.grpc_channel.unary_unary( + self._stubs["get_property"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/GetProperty", request_serializer=analytics_admin.GetPropertyRequest.serialize, response_deserializer=resources.Property.deserialize, @@ -470,7 +556,7 @@ def list_properties( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_properties" not in self._stubs: - self._stubs["list_properties"] = self.grpc_channel.unary_unary( + self._stubs["list_properties"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/ListProperties", request_serializer=analytics_admin.ListPropertiesRequest.serialize, response_deserializer=analytics_admin.ListPropertiesResponse.deserialize, @@ -497,7 +583,7 @@ def create_property( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_property" not in self._stubs: - self._stubs["create_property"] = self.grpc_channel.unary_unary( + self._stubs["create_property"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/CreateProperty", request_serializer=analytics_admin.CreatePropertyRequest.serialize, response_deserializer=resources.Property.deserialize, @@ -536,7 +622,7 @@ def delete_property( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_property" not in self._stubs: - self._stubs["delete_property"] = self.grpc_channel.unary_unary( + self._stubs["delete_property"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/DeleteProperty", request_serializer=analytics_admin.DeletePropertyRequest.serialize, response_deserializer=resources.Property.deserialize, @@ -562,7 +648,7 @@ def update_property( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_property" not in self._stubs: - self._stubs["update_property"] = self.grpc_channel.unary_unary( + self._stubs["update_property"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/UpdateProperty", request_serializer=analytics_admin.UpdatePropertyRequest.serialize, response_deserializer=resources.Property.deserialize, @@ -590,7 +676,7 @@ def create_firebase_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_firebase_link" not in self._stubs: - self._stubs["create_firebase_link"] = self.grpc_channel.unary_unary( + self._stubs["create_firebase_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/CreateFirebaseLink", request_serializer=analytics_admin.CreateFirebaseLinkRequest.serialize, response_deserializer=resources.FirebaseLink.deserialize, @@ -616,7 +702,7 @@ def delete_firebase_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_firebase_link" not in self._stubs: - self._stubs["delete_firebase_link"] = self.grpc_channel.unary_unary( + self._stubs["delete_firebase_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/DeleteFirebaseLink", request_serializer=analytics_admin.DeleteFirebaseLinkRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -646,7 +732,7 @@ def list_firebase_links( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_firebase_links" not in self._stubs: - self._stubs["list_firebase_links"] = self.grpc_channel.unary_unary( + self._stubs["list_firebase_links"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/ListFirebaseLinks", request_serializer=analytics_admin.ListFirebaseLinksRequest.serialize, response_deserializer=analytics_admin.ListFirebaseLinksResponse.deserialize, @@ -674,7 +760,7 @@ def create_google_ads_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_google_ads_link" not in self._stubs: - self._stubs["create_google_ads_link"] = self.grpc_channel.unary_unary( + self._stubs["create_google_ads_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/CreateGoogleAdsLink", request_serializer=analytics_admin.CreateGoogleAdsLinkRequest.serialize, response_deserializer=resources.GoogleAdsLink.deserialize, @@ -702,7 +788,7 @@ def update_google_ads_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_google_ads_link" not in self._stubs: - self._stubs["update_google_ads_link"] = self.grpc_channel.unary_unary( + self._stubs["update_google_ads_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/UpdateGoogleAdsLink", request_serializer=analytics_admin.UpdateGoogleAdsLinkRequest.serialize, response_deserializer=resources.GoogleAdsLink.deserialize, @@ -728,7 +814,7 @@ def delete_google_ads_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_google_ads_link" not in self._stubs: - self._stubs["delete_google_ads_link"] = self.grpc_channel.unary_unary( + self._stubs["delete_google_ads_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/DeleteGoogleAdsLink", request_serializer=analytics_admin.DeleteGoogleAdsLinkRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -757,7 +843,7 @@ def list_google_ads_links( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_google_ads_links" not in self._stubs: - self._stubs["list_google_ads_links"] = self.grpc_channel.unary_unary( + self._stubs["list_google_ads_links"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/ListGoogleAdsLinks", request_serializer=analytics_admin.ListGoogleAdsLinksRequest.serialize, response_deserializer=analytics_admin.ListGoogleAdsLinksResponse.deserialize, @@ -786,7 +872,7 @@ def get_data_sharing_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_data_sharing_settings" not in self._stubs: - self._stubs["get_data_sharing_settings"] = self.grpc_channel.unary_unary( + self._stubs["get_data_sharing_settings"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/GetDataSharingSettings", request_serializer=analytics_admin.GetDataSharingSettingsRequest.serialize, response_deserializer=resources.DataSharingSettings.deserialize, @@ -818,7 +904,7 @@ def get_measurement_protocol_secret( if "get_measurement_protocol_secret" not in self._stubs: self._stubs[ "get_measurement_protocol_secret" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/GetMeasurementProtocolSecret", request_serializer=analytics_admin.GetMeasurementProtocolSecretRequest.serialize, response_deserializer=resources.MeasurementProtocolSecret.deserialize, @@ -851,7 +937,7 @@ def list_measurement_protocol_secrets( if "list_measurement_protocol_secrets" not in self._stubs: self._stubs[ "list_measurement_protocol_secrets" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/ListMeasurementProtocolSecrets", request_serializer=analytics_admin.ListMeasurementProtocolSecretsRequest.serialize, response_deserializer=analytics_admin.ListMeasurementProtocolSecretsResponse.deserialize, @@ -883,7 +969,7 @@ def create_measurement_protocol_secret( if "create_measurement_protocol_secret" not in self._stubs: self._stubs[ "create_measurement_protocol_secret" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/CreateMeasurementProtocolSecret", request_serializer=analytics_admin.CreateMeasurementProtocolSecretRequest.serialize, response_deserializer=resources.MeasurementProtocolSecret.deserialize, @@ -914,7 +1000,7 @@ def delete_measurement_protocol_secret( if "delete_measurement_protocol_secret" not in self._stubs: self._stubs[ "delete_measurement_protocol_secret" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/DeleteMeasurementProtocolSecret", request_serializer=analytics_admin.DeleteMeasurementProtocolSecretRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -946,7 +1032,7 @@ def update_measurement_protocol_secret( if "update_measurement_protocol_secret" not in self._stubs: self._stubs[ "update_measurement_protocol_secret" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/UpdateMeasurementProtocolSecret", request_serializer=analytics_admin.UpdateMeasurementProtocolSecretRequest.serialize, response_deserializer=resources.MeasurementProtocolSecret.deserialize, @@ -982,7 +1068,7 @@ def acknowledge_user_data_collection( if "acknowledge_user_data_collection" not in self._stubs: self._stubs[ "acknowledge_user_data_collection" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/AcknowledgeUserDataCollection", request_serializer=analytics_admin.AcknowledgeUserDataCollectionRequest.serialize, response_deserializer=analytics_admin.AcknowledgeUserDataCollectionResponse.deserialize, @@ -1012,7 +1098,9 @@ def search_change_history_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_change_history_events" not in self._stubs: - self._stubs["search_change_history_events"] = self.grpc_channel.unary_unary( + self._stubs[ + "search_change_history_events" + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/SearchChangeHistoryEvents", request_serializer=analytics_admin.SearchChangeHistoryEventsRequest.serialize, response_deserializer=analytics_admin.SearchChangeHistoryEventsResponse.deserialize, @@ -1041,7 +1129,7 @@ def create_conversion_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_conversion_event" not in self._stubs: - self._stubs["create_conversion_event"] = self.grpc_channel.unary_unary( + self._stubs["create_conversion_event"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/CreateConversionEvent", request_serializer=analytics_admin.CreateConversionEventRequest.serialize, response_deserializer=resources.ConversionEvent.deserialize, @@ -1070,7 +1158,7 @@ def update_conversion_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_conversion_event" not in self._stubs: - self._stubs["update_conversion_event"] = self.grpc_channel.unary_unary( + self._stubs["update_conversion_event"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/UpdateConversionEvent", request_serializer=analytics_admin.UpdateConversionEventRequest.serialize, response_deserializer=resources.ConversionEvent.deserialize, @@ -1099,7 +1187,7 @@ def get_conversion_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_conversion_event" not in self._stubs: - self._stubs["get_conversion_event"] = self.grpc_channel.unary_unary( + self._stubs["get_conversion_event"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/GetConversionEvent", request_serializer=analytics_admin.GetConversionEventRequest.serialize, response_deserializer=resources.ConversionEvent.deserialize, @@ -1126,7 +1214,7 @@ def delete_conversion_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_conversion_event" not in self._stubs: - self._stubs["delete_conversion_event"] = self.grpc_channel.unary_unary( + self._stubs["delete_conversion_event"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/DeleteConversionEvent", request_serializer=analytics_admin.DeleteConversionEventRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1158,7 +1246,7 @@ def list_conversion_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_conversion_events" not in self._stubs: - self._stubs["list_conversion_events"] = self.grpc_channel.unary_unary( + self._stubs["list_conversion_events"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/ListConversionEvents", request_serializer=analytics_admin.ListConversionEventsRequest.serialize, response_deserializer=analytics_admin.ListConversionEventsResponse.deserialize, @@ -1184,7 +1272,7 @@ def create_key_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_key_event" not in self._stubs: - self._stubs["create_key_event"] = self.grpc_channel.unary_unary( + self._stubs["create_key_event"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/CreateKeyEvent", request_serializer=analytics_admin.CreateKeyEventRequest.serialize, response_deserializer=resources.KeyEvent.deserialize, @@ -1210,7 +1298,7 @@ def update_key_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_key_event" not in self._stubs: - self._stubs["update_key_event"] = self.grpc_channel.unary_unary( + self._stubs["update_key_event"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/UpdateKeyEvent", request_serializer=analytics_admin.UpdateKeyEventRequest.serialize, response_deserializer=resources.KeyEvent.deserialize, @@ -1236,7 +1324,7 @@ def get_key_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_key_event" not in self._stubs: - self._stubs["get_key_event"] = self.grpc_channel.unary_unary( + self._stubs["get_key_event"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/GetKeyEvent", request_serializer=analytics_admin.GetKeyEventRequest.serialize, response_deserializer=resources.KeyEvent.deserialize, @@ -1262,7 +1350,7 @@ def delete_key_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_key_event" not in self._stubs: - self._stubs["delete_key_event"] = self.grpc_channel.unary_unary( + self._stubs["delete_key_event"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/DeleteKeyEvent", request_serializer=analytics_admin.DeleteKeyEventRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1292,7 +1380,7 @@ def list_key_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_key_events" not in self._stubs: - self._stubs["list_key_events"] = self.grpc_channel.unary_unary( + self._stubs["list_key_events"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/ListKeyEvents", request_serializer=analytics_admin.ListKeyEventsRequest.serialize, response_deserializer=analytics_admin.ListKeyEventsResponse.deserialize, @@ -1320,7 +1408,7 @@ def create_custom_dimension( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_custom_dimension" not in self._stubs: - self._stubs["create_custom_dimension"] = self.grpc_channel.unary_unary( + self._stubs["create_custom_dimension"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/CreateCustomDimension", request_serializer=analytics_admin.CreateCustomDimensionRequest.serialize, response_deserializer=resources.CustomDimension.deserialize, @@ -1348,7 +1436,7 @@ def update_custom_dimension( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_custom_dimension" not in self._stubs: - self._stubs["update_custom_dimension"] = self.grpc_channel.unary_unary( + self._stubs["update_custom_dimension"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/UpdateCustomDimension", request_serializer=analytics_admin.UpdateCustomDimensionRequest.serialize, response_deserializer=resources.CustomDimension.deserialize, @@ -1377,7 +1465,7 @@ def list_custom_dimensions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_custom_dimensions" not in self._stubs: - self._stubs["list_custom_dimensions"] = self.grpc_channel.unary_unary( + self._stubs["list_custom_dimensions"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/ListCustomDimensions", request_serializer=analytics_admin.ListCustomDimensionsRequest.serialize, response_deserializer=analytics_admin.ListCustomDimensionsResponse.deserialize, @@ -1403,7 +1491,7 @@ def archive_custom_dimension( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "archive_custom_dimension" not in self._stubs: - self._stubs["archive_custom_dimension"] = self.grpc_channel.unary_unary( + self._stubs["archive_custom_dimension"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/ArchiveCustomDimension", request_serializer=analytics_admin.ArchiveCustomDimensionRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1431,7 +1519,7 @@ def get_custom_dimension( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_custom_dimension" not in self._stubs: - self._stubs["get_custom_dimension"] = self.grpc_channel.unary_unary( + self._stubs["get_custom_dimension"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/GetCustomDimension", request_serializer=analytics_admin.GetCustomDimensionRequest.serialize, response_deserializer=resources.CustomDimension.deserialize, @@ -1457,7 +1545,7 @@ def create_custom_metric( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_custom_metric" not in self._stubs: - self._stubs["create_custom_metric"] = self.grpc_channel.unary_unary( + self._stubs["create_custom_metric"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/CreateCustomMetric", request_serializer=analytics_admin.CreateCustomMetricRequest.serialize, response_deserializer=resources.CustomMetric.deserialize, @@ -1483,7 +1571,7 @@ def update_custom_metric( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_custom_metric" not in self._stubs: - self._stubs["update_custom_metric"] = self.grpc_channel.unary_unary( + self._stubs["update_custom_metric"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/UpdateCustomMetric", request_serializer=analytics_admin.UpdateCustomMetricRequest.serialize, response_deserializer=resources.CustomMetric.deserialize, @@ -1512,7 +1600,7 @@ def list_custom_metrics( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_custom_metrics" not in self._stubs: - self._stubs["list_custom_metrics"] = self.grpc_channel.unary_unary( + self._stubs["list_custom_metrics"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/ListCustomMetrics", request_serializer=analytics_admin.ListCustomMetricsRequest.serialize, response_deserializer=analytics_admin.ListCustomMetricsResponse.deserialize, @@ -1538,7 +1626,7 @@ def archive_custom_metric( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "archive_custom_metric" not in self._stubs: - self._stubs["archive_custom_metric"] = self.grpc_channel.unary_unary( + self._stubs["archive_custom_metric"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/ArchiveCustomMetric", request_serializer=analytics_admin.ArchiveCustomMetricRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1564,7 +1652,7 @@ def get_custom_metric( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_custom_metric" not in self._stubs: - self._stubs["get_custom_metric"] = self.grpc_channel.unary_unary( + self._stubs["get_custom_metric"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/GetCustomMetric", request_serializer=analytics_admin.GetCustomMetricRequest.serialize, response_deserializer=resources.CustomMetric.deserialize, @@ -1594,7 +1682,9 @@ def get_data_retention_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_data_retention_settings" not in self._stubs: - self._stubs["get_data_retention_settings"] = self.grpc_channel.unary_unary( + self._stubs[ + "get_data_retention_settings" + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/GetDataRetentionSettings", request_serializer=analytics_admin.GetDataRetentionSettingsRequest.serialize, response_deserializer=resources.DataRetentionSettings.deserialize, @@ -1626,7 +1716,7 @@ def update_data_retention_settings( if "update_data_retention_settings" not in self._stubs: self._stubs[ "update_data_retention_settings" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/UpdateDataRetentionSettings", request_serializer=analytics_admin.UpdateDataRetentionSettingsRequest.serialize, response_deserializer=resources.DataRetentionSettings.deserialize, @@ -1652,7 +1742,7 @@ def create_data_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_data_stream" not in self._stubs: - self._stubs["create_data_stream"] = self.grpc_channel.unary_unary( + self._stubs["create_data_stream"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/CreateDataStream", request_serializer=analytics_admin.CreateDataStreamRequest.serialize, response_deserializer=resources.DataStream.deserialize, @@ -1678,7 +1768,7 @@ def delete_data_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_data_stream" not in self._stubs: - self._stubs["delete_data_stream"] = self.grpc_channel.unary_unary( + self._stubs["delete_data_stream"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/DeleteDataStream", request_serializer=analytics_admin.DeleteDataStreamRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1704,7 +1794,7 @@ def update_data_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_data_stream" not in self._stubs: - self._stubs["update_data_stream"] = self.grpc_channel.unary_unary( + self._stubs["update_data_stream"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/UpdateDataStream", request_serializer=analytics_admin.UpdateDataStreamRequest.serialize, response_deserializer=resources.DataStream.deserialize, @@ -1733,7 +1823,7 @@ def list_data_streams( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_data_streams" not in self._stubs: - self._stubs["list_data_streams"] = self.grpc_channel.unary_unary( + self._stubs["list_data_streams"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/ListDataStreams", request_serializer=analytics_admin.ListDataStreamsRequest.serialize, response_deserializer=analytics_admin.ListDataStreamsResponse.deserialize, @@ -1759,7 +1849,7 @@ def get_data_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_data_stream" not in self._stubs: - self._stubs["get_data_stream"] = self.grpc_channel.unary_unary( + self._stubs["get_data_stream"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/GetDataStream", request_serializer=analytics_admin.GetDataStreamRequest.serialize, response_deserializer=resources.DataStream.deserialize, @@ -1803,7 +1893,7 @@ def run_access_report( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "run_access_report" not in self._stubs: - self._stubs["run_access_report"] = self.grpc_channel.unary_unary( + self._stubs["run_access_report"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/RunAccessReport", request_serializer=analytics_admin.RunAccessReportRequest.serialize, response_deserializer=analytics_admin.RunAccessReportResponse.deserialize, @@ -1811,7 +1901,7 @@ def run_access_report( return self._stubs["run_access_report"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-analytics-admin/google/analytics/admin_v1beta/services/analytics_admin_service/transports/grpc_asyncio.py b/packages/google-analytics-admin/google/analytics/admin_v1beta/services/analytics_admin_service/transports/grpc_asyncio.py index 7b4fa8105952..70f5f4969ec4 100644 --- a/packages/google-analytics-admin/google/analytics/admin_v1beta/services/analytics_admin_service/transports/grpc_asyncio.py +++ b/packages/google-analytics-admin/google/analytics/admin_v1beta/services/analytics_admin_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.analytics.admin_v1beta.types import analytics_admin, resources from .base import DEFAULT_CLIENT_INFO, AnalyticsAdminServiceTransport from .grpc import AnalyticsAdminServiceGrpcTransport +try: + from google.api_core import client_logging # 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.analytics.admin.v1beta.AnalyticsAdminService", + "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.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AnalyticsAdminServiceGrpcAsyncIOTransport(AnalyticsAdminServiceTransport): """gRPC AsyncIO backend transport for AnalyticsAdminService. @@ -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 @@ -262,7 +347,7 @@ def get_account( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_account" not in self._stubs: - self._stubs["get_account"] = self.grpc_channel.unary_unary( + self._stubs["get_account"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/GetAccount", request_serializer=analytics_admin.GetAccountRequest.serialize, response_deserializer=resources.Account.deserialize, @@ -296,7 +381,7 @@ def list_accounts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_accounts" not in self._stubs: - self._stubs["list_accounts"] = self.grpc_channel.unary_unary( + self._stubs["list_accounts"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/ListAccounts", request_serializer=analytics_admin.ListAccountsRequest.serialize, response_deserializer=analytics_admin.ListAccountsResponse.deserialize, @@ -334,7 +419,7 @@ def delete_account( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_account" not in self._stubs: - self._stubs["delete_account"] = self.grpc_channel.unary_unary( + self._stubs["delete_account"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/DeleteAccount", request_serializer=analytics_admin.DeleteAccountRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -360,7 +445,7 @@ def update_account( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_account" not in self._stubs: - self._stubs["update_account"] = self.grpc_channel.unary_unary( + self._stubs["update_account"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/UpdateAccount", request_serializer=analytics_admin.UpdateAccountRequest.serialize, response_deserializer=resources.Account.deserialize, @@ -389,7 +474,7 @@ def provision_account_ticket( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "provision_account_ticket" not in self._stubs: - self._stubs["provision_account_ticket"] = self.grpc_channel.unary_unary( + self._stubs["provision_account_ticket"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/ProvisionAccountTicket", request_serializer=analytics_admin.ProvisionAccountTicketRequest.serialize, response_deserializer=analytics_admin.ProvisionAccountTicketResponse.deserialize, @@ -419,7 +504,7 @@ def list_account_summaries( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_account_summaries" not in self._stubs: - self._stubs["list_account_summaries"] = self.grpc_channel.unary_unary( + self._stubs["list_account_summaries"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/ListAccountSummaries", request_serializer=analytics_admin.ListAccountSummariesRequest.serialize, response_deserializer=analytics_admin.ListAccountSummariesResponse.deserialize, @@ -445,7 +530,7 @@ def get_property( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_property" not in self._stubs: - self._stubs["get_property"] = self.grpc_channel.unary_unary( + self._stubs["get_property"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/GetProperty", request_serializer=analytics_admin.GetPropertyRequest.serialize, response_deserializer=resources.Property.deserialize, @@ -480,7 +565,7 @@ def list_properties( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_properties" not in self._stubs: - self._stubs["list_properties"] = self.grpc_channel.unary_unary( + self._stubs["list_properties"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/ListProperties", request_serializer=analytics_admin.ListPropertiesRequest.serialize, response_deserializer=analytics_admin.ListPropertiesResponse.deserialize, @@ -509,7 +594,7 @@ def create_property( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_property" not in self._stubs: - self._stubs["create_property"] = self.grpc_channel.unary_unary( + self._stubs["create_property"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/CreateProperty", request_serializer=analytics_admin.CreatePropertyRequest.serialize, response_deserializer=resources.Property.deserialize, @@ -550,7 +635,7 @@ def delete_property( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_property" not in self._stubs: - self._stubs["delete_property"] = self.grpc_channel.unary_unary( + self._stubs["delete_property"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/DeleteProperty", request_serializer=analytics_admin.DeletePropertyRequest.serialize, response_deserializer=resources.Property.deserialize, @@ -578,7 +663,7 @@ def update_property( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_property" not in self._stubs: - self._stubs["update_property"] = self.grpc_channel.unary_unary( + self._stubs["update_property"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/UpdateProperty", request_serializer=analytics_admin.UpdatePropertyRequest.serialize, response_deserializer=resources.Property.deserialize, @@ -608,7 +693,7 @@ def create_firebase_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_firebase_link" not in self._stubs: - self._stubs["create_firebase_link"] = self.grpc_channel.unary_unary( + self._stubs["create_firebase_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/CreateFirebaseLink", request_serializer=analytics_admin.CreateFirebaseLinkRequest.serialize, response_deserializer=resources.FirebaseLink.deserialize, @@ -636,7 +721,7 @@ def delete_firebase_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_firebase_link" not in self._stubs: - self._stubs["delete_firebase_link"] = self.grpc_channel.unary_unary( + self._stubs["delete_firebase_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/DeleteFirebaseLink", request_serializer=analytics_admin.DeleteFirebaseLinkRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -666,7 +751,7 @@ def list_firebase_links( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_firebase_links" not in self._stubs: - self._stubs["list_firebase_links"] = self.grpc_channel.unary_unary( + self._stubs["list_firebase_links"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/ListFirebaseLinks", request_serializer=analytics_admin.ListFirebaseLinksRequest.serialize, response_deserializer=analytics_admin.ListFirebaseLinksResponse.deserialize, @@ -694,7 +779,7 @@ def create_google_ads_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_google_ads_link" not in self._stubs: - self._stubs["create_google_ads_link"] = self.grpc_channel.unary_unary( + self._stubs["create_google_ads_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/CreateGoogleAdsLink", request_serializer=analytics_admin.CreateGoogleAdsLinkRequest.serialize, response_deserializer=resources.GoogleAdsLink.deserialize, @@ -722,7 +807,7 @@ def update_google_ads_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_google_ads_link" not in self._stubs: - self._stubs["update_google_ads_link"] = self.grpc_channel.unary_unary( + self._stubs["update_google_ads_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/UpdateGoogleAdsLink", request_serializer=analytics_admin.UpdateGoogleAdsLinkRequest.serialize, response_deserializer=resources.GoogleAdsLink.deserialize, @@ -750,7 +835,7 @@ def delete_google_ads_link( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_google_ads_link" not in self._stubs: - self._stubs["delete_google_ads_link"] = self.grpc_channel.unary_unary( + self._stubs["delete_google_ads_link"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/DeleteGoogleAdsLink", request_serializer=analytics_admin.DeleteGoogleAdsLinkRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -779,7 +864,7 @@ def list_google_ads_links( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_google_ads_links" not in self._stubs: - self._stubs["list_google_ads_links"] = self.grpc_channel.unary_unary( + self._stubs["list_google_ads_links"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/ListGoogleAdsLinks", request_serializer=analytics_admin.ListGoogleAdsLinksRequest.serialize, response_deserializer=analytics_admin.ListGoogleAdsLinksResponse.deserialize, @@ -809,7 +894,7 @@ def get_data_sharing_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_data_sharing_settings" not in self._stubs: - self._stubs["get_data_sharing_settings"] = self.grpc_channel.unary_unary( + self._stubs["get_data_sharing_settings"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/GetDataSharingSettings", request_serializer=analytics_admin.GetDataSharingSettingsRequest.serialize, response_deserializer=resources.DataSharingSettings.deserialize, @@ -841,7 +926,7 @@ def get_measurement_protocol_secret( if "get_measurement_protocol_secret" not in self._stubs: self._stubs[ "get_measurement_protocol_secret" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/GetMeasurementProtocolSecret", request_serializer=analytics_admin.GetMeasurementProtocolSecretRequest.serialize, response_deserializer=resources.MeasurementProtocolSecret.deserialize, @@ -874,7 +959,7 @@ def list_measurement_protocol_secrets( if "list_measurement_protocol_secrets" not in self._stubs: self._stubs[ "list_measurement_protocol_secrets" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/ListMeasurementProtocolSecrets", request_serializer=analytics_admin.ListMeasurementProtocolSecretsRequest.serialize, response_deserializer=analytics_admin.ListMeasurementProtocolSecretsResponse.deserialize, @@ -906,7 +991,7 @@ def create_measurement_protocol_secret( if "create_measurement_protocol_secret" not in self._stubs: self._stubs[ "create_measurement_protocol_secret" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/CreateMeasurementProtocolSecret", request_serializer=analytics_admin.CreateMeasurementProtocolSecretRequest.serialize, response_deserializer=resources.MeasurementProtocolSecret.deserialize, @@ -938,7 +1023,7 @@ def delete_measurement_protocol_secret( if "delete_measurement_protocol_secret" not in self._stubs: self._stubs[ "delete_measurement_protocol_secret" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/DeleteMeasurementProtocolSecret", request_serializer=analytics_admin.DeleteMeasurementProtocolSecretRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -970,7 +1055,7 @@ def update_measurement_protocol_secret( if "update_measurement_protocol_secret" not in self._stubs: self._stubs[ "update_measurement_protocol_secret" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/UpdateMeasurementProtocolSecret", request_serializer=analytics_admin.UpdateMeasurementProtocolSecretRequest.serialize, response_deserializer=resources.MeasurementProtocolSecret.deserialize, @@ -1006,7 +1091,7 @@ def acknowledge_user_data_collection( if "acknowledge_user_data_collection" not in self._stubs: self._stubs[ "acknowledge_user_data_collection" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/AcknowledgeUserDataCollection", request_serializer=analytics_admin.AcknowledgeUserDataCollectionRequest.serialize, response_deserializer=analytics_admin.AcknowledgeUserDataCollectionResponse.deserialize, @@ -1036,7 +1121,9 @@ def search_change_history_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_change_history_events" not in self._stubs: - self._stubs["search_change_history_events"] = self.grpc_channel.unary_unary( + self._stubs[ + "search_change_history_events" + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/SearchChangeHistoryEvents", request_serializer=analytics_admin.SearchChangeHistoryEventsRequest.serialize, response_deserializer=analytics_admin.SearchChangeHistoryEventsResponse.deserialize, @@ -1066,7 +1153,7 @@ def create_conversion_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_conversion_event" not in self._stubs: - self._stubs["create_conversion_event"] = self.grpc_channel.unary_unary( + self._stubs["create_conversion_event"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/CreateConversionEvent", request_serializer=analytics_admin.CreateConversionEventRequest.serialize, response_deserializer=resources.ConversionEvent.deserialize, @@ -1096,7 +1183,7 @@ def update_conversion_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_conversion_event" not in self._stubs: - self._stubs["update_conversion_event"] = self.grpc_channel.unary_unary( + self._stubs["update_conversion_event"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/UpdateConversionEvent", request_serializer=analytics_admin.UpdateConversionEventRequest.serialize, response_deserializer=resources.ConversionEvent.deserialize, @@ -1126,7 +1213,7 @@ def get_conversion_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_conversion_event" not in self._stubs: - self._stubs["get_conversion_event"] = self.grpc_channel.unary_unary( + self._stubs["get_conversion_event"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/GetConversionEvent", request_serializer=analytics_admin.GetConversionEventRequest.serialize, response_deserializer=resources.ConversionEvent.deserialize, @@ -1155,7 +1242,7 @@ def delete_conversion_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_conversion_event" not in self._stubs: - self._stubs["delete_conversion_event"] = self.grpc_channel.unary_unary( + self._stubs["delete_conversion_event"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/DeleteConversionEvent", request_serializer=analytics_admin.DeleteConversionEventRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1187,7 +1274,7 @@ def list_conversion_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_conversion_events" not in self._stubs: - self._stubs["list_conversion_events"] = self.grpc_channel.unary_unary( + self._stubs["list_conversion_events"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/ListConversionEvents", request_serializer=analytics_admin.ListConversionEventsRequest.serialize, response_deserializer=analytics_admin.ListConversionEventsResponse.deserialize, @@ -1215,7 +1302,7 @@ def create_key_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_key_event" not in self._stubs: - self._stubs["create_key_event"] = self.grpc_channel.unary_unary( + self._stubs["create_key_event"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/CreateKeyEvent", request_serializer=analytics_admin.CreateKeyEventRequest.serialize, response_deserializer=resources.KeyEvent.deserialize, @@ -1243,7 +1330,7 @@ def update_key_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_key_event" not in self._stubs: - self._stubs["update_key_event"] = self.grpc_channel.unary_unary( + self._stubs["update_key_event"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/UpdateKeyEvent", request_serializer=analytics_admin.UpdateKeyEventRequest.serialize, response_deserializer=resources.KeyEvent.deserialize, @@ -1269,7 +1356,7 @@ def get_key_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_key_event" not in self._stubs: - self._stubs["get_key_event"] = self.grpc_channel.unary_unary( + self._stubs["get_key_event"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/GetKeyEvent", request_serializer=analytics_admin.GetKeyEventRequest.serialize, response_deserializer=resources.KeyEvent.deserialize, @@ -1295,7 +1382,7 @@ def delete_key_event( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_key_event" not in self._stubs: - self._stubs["delete_key_event"] = self.grpc_channel.unary_unary( + self._stubs["delete_key_event"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/DeleteKeyEvent", request_serializer=analytics_admin.DeleteKeyEventRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1326,7 +1413,7 @@ def list_key_events( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_key_events" not in self._stubs: - self._stubs["list_key_events"] = self.grpc_channel.unary_unary( + self._stubs["list_key_events"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/ListKeyEvents", request_serializer=analytics_admin.ListKeyEventsRequest.serialize, response_deserializer=analytics_admin.ListKeyEventsResponse.deserialize, @@ -1355,7 +1442,7 @@ def create_custom_dimension( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_custom_dimension" not in self._stubs: - self._stubs["create_custom_dimension"] = self.grpc_channel.unary_unary( + self._stubs["create_custom_dimension"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/CreateCustomDimension", request_serializer=analytics_admin.CreateCustomDimensionRequest.serialize, response_deserializer=resources.CustomDimension.deserialize, @@ -1384,7 +1471,7 @@ def update_custom_dimension( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_custom_dimension" not in self._stubs: - self._stubs["update_custom_dimension"] = self.grpc_channel.unary_unary( + self._stubs["update_custom_dimension"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/UpdateCustomDimension", request_serializer=analytics_admin.UpdateCustomDimensionRequest.serialize, response_deserializer=resources.CustomDimension.deserialize, @@ -1413,7 +1500,7 @@ def list_custom_dimensions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_custom_dimensions" not in self._stubs: - self._stubs["list_custom_dimensions"] = self.grpc_channel.unary_unary( + self._stubs["list_custom_dimensions"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/ListCustomDimensions", request_serializer=analytics_admin.ListCustomDimensionsRequest.serialize, response_deserializer=analytics_admin.ListCustomDimensionsResponse.deserialize, @@ -1441,7 +1528,7 @@ def archive_custom_dimension( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "archive_custom_dimension" not in self._stubs: - self._stubs["archive_custom_dimension"] = self.grpc_channel.unary_unary( + self._stubs["archive_custom_dimension"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/ArchiveCustomDimension", request_serializer=analytics_admin.ArchiveCustomDimensionRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1470,7 +1557,7 @@ def get_custom_dimension( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_custom_dimension" not in self._stubs: - self._stubs["get_custom_dimension"] = self.grpc_channel.unary_unary( + self._stubs["get_custom_dimension"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/GetCustomDimension", request_serializer=analytics_admin.GetCustomDimensionRequest.serialize, response_deserializer=resources.CustomDimension.deserialize, @@ -1498,7 +1585,7 @@ def create_custom_metric( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_custom_metric" not in self._stubs: - self._stubs["create_custom_metric"] = self.grpc_channel.unary_unary( + self._stubs["create_custom_metric"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/CreateCustomMetric", request_serializer=analytics_admin.CreateCustomMetricRequest.serialize, response_deserializer=resources.CustomMetric.deserialize, @@ -1526,7 +1613,7 @@ def update_custom_metric( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_custom_metric" not in self._stubs: - self._stubs["update_custom_metric"] = self.grpc_channel.unary_unary( + self._stubs["update_custom_metric"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/UpdateCustomMetric", request_serializer=analytics_admin.UpdateCustomMetricRequest.serialize, response_deserializer=resources.CustomMetric.deserialize, @@ -1555,7 +1642,7 @@ def list_custom_metrics( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_custom_metrics" not in self._stubs: - self._stubs["list_custom_metrics"] = self.grpc_channel.unary_unary( + self._stubs["list_custom_metrics"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/ListCustomMetrics", request_serializer=analytics_admin.ListCustomMetricsRequest.serialize, response_deserializer=analytics_admin.ListCustomMetricsResponse.deserialize, @@ -1583,7 +1670,7 @@ def archive_custom_metric( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "archive_custom_metric" not in self._stubs: - self._stubs["archive_custom_metric"] = self.grpc_channel.unary_unary( + self._stubs["archive_custom_metric"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/ArchiveCustomMetric", request_serializer=analytics_admin.ArchiveCustomMetricRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1611,7 +1698,7 @@ def get_custom_metric( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_custom_metric" not in self._stubs: - self._stubs["get_custom_metric"] = self.grpc_channel.unary_unary( + self._stubs["get_custom_metric"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/GetCustomMetric", request_serializer=analytics_admin.GetCustomMetricRequest.serialize, response_deserializer=resources.CustomMetric.deserialize, @@ -1641,7 +1728,9 @@ def get_data_retention_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_data_retention_settings" not in self._stubs: - self._stubs["get_data_retention_settings"] = self.grpc_channel.unary_unary( + self._stubs[ + "get_data_retention_settings" + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/GetDataRetentionSettings", request_serializer=analytics_admin.GetDataRetentionSettingsRequest.serialize, response_deserializer=resources.DataRetentionSettings.deserialize, @@ -1673,7 +1762,7 @@ def update_data_retention_settings( if "update_data_retention_settings" not in self._stubs: self._stubs[ "update_data_retention_settings" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/UpdateDataRetentionSettings", request_serializer=analytics_admin.UpdateDataRetentionSettingsRequest.serialize, response_deserializer=resources.DataRetentionSettings.deserialize, @@ -1701,7 +1790,7 @@ def create_data_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_data_stream" not in self._stubs: - self._stubs["create_data_stream"] = self.grpc_channel.unary_unary( + self._stubs["create_data_stream"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/CreateDataStream", request_serializer=analytics_admin.CreateDataStreamRequest.serialize, response_deserializer=resources.DataStream.deserialize, @@ -1729,7 +1818,7 @@ def delete_data_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_data_stream" not in self._stubs: - self._stubs["delete_data_stream"] = self.grpc_channel.unary_unary( + self._stubs["delete_data_stream"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/DeleteDataStream", request_serializer=analytics_admin.DeleteDataStreamRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1757,7 +1846,7 @@ def update_data_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_data_stream" not in self._stubs: - self._stubs["update_data_stream"] = self.grpc_channel.unary_unary( + self._stubs["update_data_stream"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/UpdateDataStream", request_serializer=analytics_admin.UpdateDataStreamRequest.serialize, response_deserializer=resources.DataStream.deserialize, @@ -1786,7 +1875,7 @@ def list_data_streams( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_data_streams" not in self._stubs: - self._stubs["list_data_streams"] = self.grpc_channel.unary_unary( + self._stubs["list_data_streams"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/ListDataStreams", request_serializer=analytics_admin.ListDataStreamsRequest.serialize, response_deserializer=analytics_admin.ListDataStreamsResponse.deserialize, @@ -1814,7 +1903,7 @@ def get_data_stream( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_data_stream" not in self._stubs: - self._stubs["get_data_stream"] = self.grpc_channel.unary_unary( + self._stubs["get_data_stream"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/GetDataStream", request_serializer=analytics_admin.GetDataStreamRequest.serialize, response_deserializer=resources.DataStream.deserialize, @@ -1858,7 +1947,7 @@ def run_access_report( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "run_access_report" not in self._stubs: - self._stubs["run_access_report"] = self.grpc_channel.unary_unary( + self._stubs["run_access_report"] = self._logged_channel.unary_unary( "/google.analytics.admin.v1beta.AnalyticsAdminService/RunAccessReport", request_serializer=analytics_admin.RunAccessReportRequest.serialize, response_deserializer=analytics_admin.RunAccessReportResponse.deserialize, @@ -2146,7 +2235,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-analytics-admin/google/analytics/admin_v1beta/services/analytics_admin_service/transports/rest.py b/packages/google-analytics-admin/google/analytics/admin_v1beta/services/analytics_admin_service/transports/rest.py index a066c12144d1..8d87cf5c5233 100644 --- a/packages/google-analytics-admin/google/analytics/admin_v1beta/services/analytics_admin_service/transports/rest.py +++ b/packages/google-analytics-admin/google/analytics/admin_v1beta/services/analytics_admin_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, @@ -466,9 +474,10 @@ def post_update_property(self, response): def pre_acknowledge_user_data_collection( self, request: analytics_admin.AcknowledgeUserDataCollectionRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.AcknowledgeUserDataCollectionRequest, Sequence[Tuple[str, str]] + analytics_admin.AcknowledgeUserDataCollectionRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for acknowledge_user_data_collection @@ -491,9 +500,10 @@ def post_acknowledge_user_data_collection( def pre_archive_custom_dimension( self, request: analytics_admin.ArchiveCustomDimensionRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.ArchiveCustomDimensionRequest, Sequence[Tuple[str, str]] + analytics_admin.ArchiveCustomDimensionRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for archive_custom_dimension @@ -505,8 +515,11 @@ def pre_archive_custom_dimension( def pre_archive_custom_metric( self, request: analytics_admin.ArchiveCustomMetricRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.ArchiveCustomMetricRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.ArchiveCustomMetricRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for archive_custom_metric Override in a subclass to manipulate the request or metadata @@ -517,8 +530,11 @@ def pre_archive_custom_metric( def pre_create_conversion_event( self, request: analytics_admin.CreateConversionEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.CreateConversionEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.CreateConversionEventRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_conversion_event Override in a subclass to manipulate the request or metadata @@ -540,8 +556,11 @@ def post_create_conversion_event( def pre_create_custom_dimension( self, request: analytics_admin.CreateCustomDimensionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.CreateCustomDimensionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.CreateCustomDimensionRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_custom_dimension Override in a subclass to manipulate the request or metadata @@ -563,8 +582,11 @@ def post_create_custom_dimension( def pre_create_custom_metric( self, request: analytics_admin.CreateCustomMetricRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.CreateCustomMetricRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.CreateCustomMetricRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_custom_metric Override in a subclass to manipulate the request or metadata @@ -586,8 +608,10 @@ def post_create_custom_metric( def pre_create_data_stream( self, request: analytics_admin.CreateDataStreamRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.CreateDataStreamRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.CreateDataStreamRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_data_stream Override in a subclass to manipulate the request or metadata @@ -609,8 +633,11 @@ def post_create_data_stream( def pre_create_firebase_link( self, request: analytics_admin.CreateFirebaseLinkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.CreateFirebaseLinkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.CreateFirebaseLinkRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_firebase_link Override in a subclass to manipulate the request or metadata @@ -632,8 +659,11 @@ def post_create_firebase_link( def pre_create_google_ads_link( self, request: analytics_admin.CreateGoogleAdsLinkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.CreateGoogleAdsLinkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.CreateGoogleAdsLinkRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_google_ads_link Override in a subclass to manipulate the request or metadata @@ -655,8 +685,10 @@ def post_create_google_ads_link( def pre_create_key_event( self, request: analytics_admin.CreateKeyEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.CreateKeyEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.CreateKeyEventRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_key_event Override in a subclass to manipulate the request or metadata @@ -676,10 +708,10 @@ def post_create_key_event(self, response: resources.KeyEvent) -> resources.KeyEv def pre_create_measurement_protocol_secret( self, request: analytics_admin.CreateMeasurementProtocolSecretRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ analytics_admin.CreateMeasurementProtocolSecretRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_measurement_protocol_secret @@ -702,8 +734,10 @@ def post_create_measurement_protocol_secret( def pre_create_property( self, request: analytics_admin.CreatePropertyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.CreatePropertyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.CreatePropertyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_property Override in a subclass to manipulate the request or metadata @@ -723,8 +757,10 @@ def post_create_property(self, response: resources.Property) -> resources.Proper def pre_delete_account( self, request: analytics_admin.DeleteAccountRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.DeleteAccountRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.DeleteAccountRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_account Override in a subclass to manipulate the request or metadata @@ -735,8 +771,11 @@ def pre_delete_account( def pre_delete_conversion_event( self, request: analytics_admin.DeleteConversionEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.DeleteConversionEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.DeleteConversionEventRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_conversion_event Override in a subclass to manipulate the request or metadata @@ -747,8 +786,10 @@ def pre_delete_conversion_event( def pre_delete_data_stream( self, request: analytics_admin.DeleteDataStreamRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.DeleteDataStreamRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.DeleteDataStreamRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_data_stream Override in a subclass to manipulate the request or metadata @@ -759,8 +800,11 @@ def pre_delete_data_stream( def pre_delete_firebase_link( self, request: analytics_admin.DeleteFirebaseLinkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.DeleteFirebaseLinkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.DeleteFirebaseLinkRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_firebase_link Override in a subclass to manipulate the request or metadata @@ -771,8 +815,11 @@ def pre_delete_firebase_link( def pre_delete_google_ads_link( self, request: analytics_admin.DeleteGoogleAdsLinkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.DeleteGoogleAdsLinkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.DeleteGoogleAdsLinkRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_google_ads_link Override in a subclass to manipulate the request or metadata @@ -783,8 +830,10 @@ def pre_delete_google_ads_link( def pre_delete_key_event( self, request: analytics_admin.DeleteKeyEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.DeleteKeyEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.DeleteKeyEventRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_key_event Override in a subclass to manipulate the request or metadata @@ -795,10 +844,10 @@ def pre_delete_key_event( def pre_delete_measurement_protocol_secret( self, request: analytics_admin.DeleteMeasurementProtocolSecretRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ analytics_admin.DeleteMeasurementProtocolSecretRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_measurement_protocol_secret @@ -810,8 +859,10 @@ def pre_delete_measurement_protocol_secret( def pre_delete_property( self, request: analytics_admin.DeletePropertyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.DeletePropertyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.DeletePropertyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_property Override in a subclass to manipulate the request or metadata @@ -831,8 +882,10 @@ def post_delete_property(self, response: resources.Property) -> resources.Proper def pre_get_account( self, request: analytics_admin.GetAccountRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.GetAccountRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.GetAccountRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_account Override in a subclass to manipulate the request or metadata @@ -852,8 +905,11 @@ def post_get_account(self, response: resources.Account) -> resources.Account: def pre_get_conversion_event( self, request: analytics_admin.GetConversionEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.GetConversionEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.GetConversionEventRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_conversion_event Override in a subclass to manipulate the request or metadata @@ -875,8 +931,11 @@ def post_get_conversion_event( def pre_get_custom_dimension( self, request: analytics_admin.GetCustomDimensionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.GetCustomDimensionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.GetCustomDimensionRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_custom_dimension Override in a subclass to manipulate the request or metadata @@ -898,8 +957,10 @@ def post_get_custom_dimension( def pre_get_custom_metric( self, request: analytics_admin.GetCustomMetricRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.GetCustomMetricRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.GetCustomMetricRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_custom_metric Override in a subclass to manipulate the request or metadata @@ -921,9 +982,10 @@ def post_get_custom_metric( def pre_get_data_retention_settings( self, request: analytics_admin.GetDataRetentionSettingsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.GetDataRetentionSettingsRequest, Sequence[Tuple[str, str]] + analytics_admin.GetDataRetentionSettingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_data_retention_settings @@ -946,9 +1008,10 @@ def post_get_data_retention_settings( def pre_get_data_sharing_settings( self, request: analytics_admin.GetDataSharingSettingsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.GetDataSharingSettingsRequest, Sequence[Tuple[str, str]] + analytics_admin.GetDataSharingSettingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_data_sharing_settings @@ -971,8 +1034,10 @@ def post_get_data_sharing_settings( def pre_get_data_stream( self, request: analytics_admin.GetDataStreamRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.GetDataStreamRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.GetDataStreamRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_data_stream Override in a subclass to manipulate the request or metadata @@ -994,8 +1059,10 @@ def post_get_data_stream( def pre_get_key_event( self, request: analytics_admin.GetKeyEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.GetKeyEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.GetKeyEventRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_key_event Override in a subclass to manipulate the request or metadata @@ -1015,9 +1082,10 @@ def post_get_key_event(self, response: resources.KeyEvent) -> resources.KeyEvent def pre_get_measurement_protocol_secret( self, request: analytics_admin.GetMeasurementProtocolSecretRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.GetMeasurementProtocolSecretRequest, Sequence[Tuple[str, str]] + analytics_admin.GetMeasurementProtocolSecretRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_measurement_protocol_secret @@ -1040,8 +1108,10 @@ def post_get_measurement_protocol_secret( def pre_get_property( self, request: analytics_admin.GetPropertyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.GetPropertyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.GetPropertyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_property Override in a subclass to manipulate the request or metadata @@ -1061,8 +1131,10 @@ def post_get_property(self, response: resources.Property) -> resources.Property: def pre_list_accounts( self, request: analytics_admin.ListAccountsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.ListAccountsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.ListAccountsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_accounts Override in a subclass to manipulate the request or metadata @@ -1084,8 +1156,11 @@ def post_list_accounts( def pre_list_account_summaries( self, request: analytics_admin.ListAccountSummariesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.ListAccountSummariesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.ListAccountSummariesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_account_summaries Override in a subclass to manipulate the request or metadata @@ -1107,8 +1182,11 @@ def post_list_account_summaries( def pre_list_conversion_events( self, request: analytics_admin.ListConversionEventsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.ListConversionEventsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.ListConversionEventsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_conversion_events Override in a subclass to manipulate the request or metadata @@ -1130,8 +1208,11 @@ def post_list_conversion_events( def pre_list_custom_dimensions( self, request: analytics_admin.ListCustomDimensionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.ListCustomDimensionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.ListCustomDimensionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_custom_dimensions Override in a subclass to manipulate the request or metadata @@ -1153,8 +1234,11 @@ def post_list_custom_dimensions( def pre_list_custom_metrics( self, request: analytics_admin.ListCustomMetricsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.ListCustomMetricsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.ListCustomMetricsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_custom_metrics Override in a subclass to manipulate the request or metadata @@ -1176,8 +1260,10 @@ def post_list_custom_metrics( def pre_list_data_streams( self, request: analytics_admin.ListDataStreamsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.ListDataStreamsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.ListDataStreamsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_data_streams Override in a subclass to manipulate the request or metadata @@ -1199,8 +1285,11 @@ def post_list_data_streams( def pre_list_firebase_links( self, request: analytics_admin.ListFirebaseLinksRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.ListFirebaseLinksRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.ListFirebaseLinksRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_firebase_links Override in a subclass to manipulate the request or metadata @@ -1222,8 +1311,11 @@ def post_list_firebase_links( def pre_list_google_ads_links( self, request: analytics_admin.ListGoogleAdsLinksRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.ListGoogleAdsLinksRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.ListGoogleAdsLinksRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_google_ads_links Override in a subclass to manipulate the request or metadata @@ -1245,8 +1337,10 @@ def post_list_google_ads_links( def pre_list_key_events( self, request: analytics_admin.ListKeyEventsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.ListKeyEventsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.ListKeyEventsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_key_events Override in a subclass to manipulate the request or metadata @@ -1268,9 +1362,10 @@ def post_list_key_events( def pre_list_measurement_protocol_secrets( self, request: analytics_admin.ListMeasurementProtocolSecretsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.ListMeasurementProtocolSecretsRequest, Sequence[Tuple[str, str]] + analytics_admin.ListMeasurementProtocolSecretsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_measurement_protocol_secrets @@ -1293,8 +1388,10 @@ def post_list_measurement_protocol_secrets( def pre_list_properties( self, request: analytics_admin.ListPropertiesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.ListPropertiesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.ListPropertiesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_properties Override in a subclass to manipulate the request or metadata @@ -1316,9 +1413,10 @@ def post_list_properties( def pre_provision_account_ticket( self, request: analytics_admin.ProvisionAccountTicketRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.ProvisionAccountTicketRequest, Sequence[Tuple[str, str]] + analytics_admin.ProvisionAccountTicketRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for provision_account_ticket @@ -1341,8 +1439,10 @@ def post_provision_account_ticket( def pre_run_access_report( self, request: analytics_admin.RunAccessReportRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.RunAccessReportRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.RunAccessReportRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for run_access_report Override in a subclass to manipulate the request or metadata @@ -1364,9 +1464,10 @@ def post_run_access_report( def pre_search_change_history_events( self, request: analytics_admin.SearchChangeHistoryEventsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.SearchChangeHistoryEventsRequest, Sequence[Tuple[str, str]] + analytics_admin.SearchChangeHistoryEventsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for search_change_history_events @@ -1389,8 +1490,10 @@ def post_search_change_history_events( def pre_update_account( self, request: analytics_admin.UpdateAccountRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.UpdateAccountRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.UpdateAccountRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_account Override in a subclass to manipulate the request or metadata @@ -1410,8 +1513,11 @@ def post_update_account(self, response: resources.Account) -> resources.Account: def pre_update_conversion_event( self, request: analytics_admin.UpdateConversionEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.UpdateConversionEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.UpdateConversionEventRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_conversion_event Override in a subclass to manipulate the request or metadata @@ -1433,8 +1539,11 @@ def post_update_conversion_event( def pre_update_custom_dimension( self, request: analytics_admin.UpdateCustomDimensionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.UpdateCustomDimensionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.UpdateCustomDimensionRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_custom_dimension Override in a subclass to manipulate the request or metadata @@ -1456,8 +1565,11 @@ def post_update_custom_dimension( def pre_update_custom_metric( self, request: analytics_admin.UpdateCustomMetricRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.UpdateCustomMetricRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.UpdateCustomMetricRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_custom_metric Override in a subclass to manipulate the request or metadata @@ -1479,9 +1591,10 @@ def post_update_custom_metric( def pre_update_data_retention_settings( self, request: analytics_admin.UpdateDataRetentionSettingsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_admin.UpdateDataRetentionSettingsRequest, Sequence[Tuple[str, str]] + analytics_admin.UpdateDataRetentionSettingsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_data_retention_settings @@ -1504,8 +1617,10 @@ def post_update_data_retention_settings( def pre_update_data_stream( self, request: analytics_admin.UpdateDataStreamRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.UpdateDataStreamRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.UpdateDataStreamRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_data_stream Override in a subclass to manipulate the request or metadata @@ -1527,8 +1642,11 @@ def post_update_data_stream( def pre_update_google_ads_link( self, request: analytics_admin.UpdateGoogleAdsLinkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.UpdateGoogleAdsLinkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.UpdateGoogleAdsLinkRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_google_ads_link Override in a subclass to manipulate the request or metadata @@ -1550,8 +1668,10 @@ def post_update_google_ads_link( def pre_update_key_event( self, request: analytics_admin.UpdateKeyEventRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.UpdateKeyEventRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.UpdateKeyEventRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_key_event Override in a subclass to manipulate the request or metadata @@ -1571,10 +1691,10 @@ def post_update_key_event(self, response: resources.KeyEvent) -> resources.KeyEv def pre_update_measurement_protocol_secret( self, request: analytics_admin.UpdateMeasurementProtocolSecretRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ analytics_admin.UpdateMeasurementProtocolSecretRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_measurement_protocol_secret @@ -1597,8 +1717,10 @@ def post_update_measurement_protocol_secret( def pre_update_property( self, request: analytics_admin.UpdatePropertyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_admin.UpdatePropertyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_admin.UpdatePropertyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_property Override in a subclass to manipulate the request or metadata @@ -1740,7 +1862,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.AcknowledgeUserDataCollectionResponse: r"""Call the acknowledge user data collection method over HTTP. @@ -1752,8 +1874,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.AcknowledgeUserDataCollectionResponse: @@ -1765,6 +1889,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseAcknowledgeUserDataCollection._get_http_options() ) + request, metadata = self._interceptor.pre_acknowledge_user_data_collection( request, metadata ) @@ -1781,6 +1906,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.AcknowledgeUserDataCollection", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "AcknowledgeUserDataCollection", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._AcknowledgeUserDataCollection._get_response( self._host, @@ -1802,7 +1954,33 @@ def __call__( pb_resp = analytics_admin.AcknowledgeUserDataCollectionResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_acknowledge_user_data_collection(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.AcknowledgeUserDataCollectionResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.acknowledge_user_data_collection", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "AcknowledgeUserDataCollection", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ArchiveCustomDimension( @@ -1841,7 +2019,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the archive custom dimension method over HTTP. @@ -1852,13 +2030,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseArchiveCustomDimension._get_http_options() ) + request, metadata = self._interceptor.pre_archive_custom_dimension( request, metadata ) @@ -1875,6 +2056,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.ArchiveCustomDimension", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "ArchiveCustomDimension", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._ArchiveCustomDimension._get_response( self._host, @@ -1927,7 +2135,7 @@ 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 archive custom metric method over HTTP. @@ -1938,13 +2146,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 = ( _BaseAnalyticsAdminServiceRestTransport._BaseArchiveCustomMetric._get_http_options() ) + request, metadata = self._interceptor.pre_archive_custom_metric( request, metadata ) @@ -1961,6 +2172,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.ArchiveCustomMetric", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "ArchiveCustomMetric", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._ArchiveCustomMetric._get_response( @@ -2015,7 +2253,7 @@ 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.ConversionEvent: r"""Call the create conversion event method over HTTP. @@ -2026,8 +2264,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ConversionEvent: @@ -2039,6 +2279,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseCreateConversionEvent._get_http_options() ) + request, metadata = self._interceptor.pre_create_conversion_event( request, metadata ) @@ -2055,6 +2296,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.CreateConversionEvent", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "CreateConversionEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._CreateConversionEvent._get_response( @@ -2078,7 +2346,29 @@ def __call__( pb_resp = resources.ConversionEvent.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_conversion_event(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.ConversionEvent.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.create_conversion_event", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "CreateConversionEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateCustomDimension( @@ -2117,7 +2407,7 @@ 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.CustomDimension: r"""Call the create custom dimension method over HTTP. @@ -2128,8 +2418,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.CustomDimension: @@ -2139,6 +2431,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseCreateCustomDimension._get_http_options() ) + request, metadata = self._interceptor.pre_create_custom_dimension( request, metadata ) @@ -2155,6 +2448,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.CreateCustomDimension", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "CreateCustomDimension", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._CreateCustomDimension._get_response( @@ -2178,7 +2498,29 @@ def __call__( pb_resp = resources.CustomDimension.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_custom_dimension(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.CustomDimension.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.create_custom_dimension", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "CreateCustomDimension", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateCustomMetric( @@ -2217,7 +2559,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.CustomMetric: r"""Call the create custom metric method over HTTP. @@ -2228,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: ~.resources.CustomMetric: @@ -2239,6 +2583,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseCreateCustomMetric._get_http_options() ) + request, metadata = self._interceptor.pre_create_custom_metric( request, metadata ) @@ -2255,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.analytics.admin_v1beta.AnalyticsAdminServiceClient.CreateCustomMetric", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "CreateCustomMetric", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._CreateCustomMetric._get_response( @@ -2278,7 +2650,29 @@ def __call__( pb_resp = resources.CustomMetric.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_custom_metric(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.CustomMetric.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.create_custom_metric", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "CreateCustomMetric", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateDataStream( @@ -2317,7 +2711,7 @@ 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.DataStream: r"""Call the create data stream method over HTTP. @@ -2328,8 +2722,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.DataStream: @@ -2341,6 +2737,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseCreateDataStream._get_http_options() ) + request, metadata = self._interceptor.pre_create_data_stream( request, metadata ) @@ -2357,6 +2754,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.CreateDataStream", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "CreateDataStream", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._CreateDataStream._get_response( @@ -2380,7 +2804,29 @@ def __call__( pb_resp = resources.DataStream.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_data_stream(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.DataStream.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.create_data_stream", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "CreateDataStream", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateFirebaseLink( @@ -2419,7 +2865,7 @@ 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.FirebaseLink: r"""Call the create firebase link method over HTTP. @@ -2430,8 +2876,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.FirebaseLink: @@ -2443,6 +2891,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseCreateFirebaseLink._get_http_options() ) + request, metadata = self._interceptor.pre_create_firebase_link( request, metadata ) @@ -2459,6 +2908,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.CreateFirebaseLink", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "CreateFirebaseLink", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._CreateFirebaseLink._get_response( @@ -2482,7 +2958,29 @@ def __call__( pb_resp = resources.FirebaseLink.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_firebase_link(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.FirebaseLink.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.create_firebase_link", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "CreateFirebaseLink", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateGoogleAdsLink( @@ -2521,7 +3019,7 @@ 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.GoogleAdsLink: r"""Call the create google ads link method over HTTP. @@ -2532,8 +3030,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.GoogleAdsLink: @@ -2545,6 +3045,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseCreateGoogleAdsLink._get_http_options() ) + request, metadata = self._interceptor.pre_create_google_ads_link( request, metadata ) @@ -2561,6 +3062,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.CreateGoogleAdsLink", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "CreateGoogleAdsLink", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._CreateGoogleAdsLink._get_response( @@ -2584,7 +3112,29 @@ def __call__( pb_resp = resources.GoogleAdsLink.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_google_ads_link(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.GoogleAdsLink.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.create_google_ads_link", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "CreateGoogleAdsLink", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateKeyEvent( @@ -2623,7 +3173,7 @@ 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.KeyEvent: r"""Call the create key event method over HTTP. @@ -2634,8 +3184,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.KeyEvent: @@ -2647,6 +3199,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseCreateKeyEvent._get_http_options() ) + request, metadata = self._interceptor.pre_create_key_event( request, metadata ) @@ -2663,6 +3216,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.CreateKeyEvent", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "CreateKeyEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._CreateKeyEvent._get_response( self._host, @@ -2684,7 +3264,29 @@ def __call__( pb_resp = resources.KeyEvent.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_key_event(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.KeyEvent.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.create_key_event", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "CreateKeyEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateMeasurementProtocolSecret( @@ -2725,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]]] = (), ) -> resources.MeasurementProtocolSecret: r"""Call the create measurement protocol secret method over HTTP. @@ -2737,8 +3339,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.MeasurementProtocolSecret: @@ -2750,6 +3354,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseCreateMeasurementProtocolSecret._get_http_options() ) + ( request, metadata, @@ -2769,6 +3374,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.CreateMeasurementProtocolSecret", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "CreateMeasurementProtocolSecret", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._CreateMeasurementProtocolSecret._get_response( self._host, @@ -2790,7 +3422,31 @@ def __call__( pb_resp = resources.MeasurementProtocolSecret.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_measurement_protocol_secret(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.MeasurementProtocolSecret.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.create_measurement_protocol_secret", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "CreateMeasurementProtocolSecret", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateProperty( @@ -2829,7 +3485,7 @@ 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.Property: r"""Call the create property method over HTTP. @@ -2840,8 +3496,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.Property: @@ -2853,6 +3511,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseCreateProperty._get_http_options() ) + request, metadata = self._interceptor.pre_create_property(request, metadata) transcoded_request = _BaseAnalyticsAdminServiceRestTransport._BaseCreateProperty._get_transcoded_request( http_options, request @@ -2867,6 +3526,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.CreateProperty", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "CreateProperty", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._CreateProperty._get_response( self._host, @@ -2888,7 +3574,29 @@ def __call__( pb_resp = resources.Property.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_property(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Property.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.create_property", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "CreateProperty", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteAccount( @@ -2926,7 +3634,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete account method over HTTP. @@ -2937,13 +3645,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 = ( _BaseAnalyticsAdminServiceRestTransport._BaseDeleteAccount._get_http_options() ) + request, metadata = self._interceptor.pre_delete_account(request, metadata) transcoded_request = _BaseAnalyticsAdminServiceRestTransport._BaseDeleteAccount._get_transcoded_request( http_options, request @@ -2954,6 +3665,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.DeleteAccount", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "DeleteAccount", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._DeleteAccount._get_response( self._host, @@ -3004,7 +3742,7 @@ 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 conversion event method over HTTP. @@ -3015,13 +3753,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 = ( _BaseAnalyticsAdminServiceRestTransport._BaseDeleteConversionEvent._get_http_options() ) + request, metadata = self._interceptor.pre_delete_conversion_event( request, metadata ) @@ -3034,6 +3775,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.DeleteConversionEvent", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "DeleteConversionEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._DeleteConversionEvent._get_response( @@ -3086,7 +3854,7 @@ 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 stream method over HTTP. @@ -3097,13 +3865,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 = ( _BaseAnalyticsAdminServiceRestTransport._BaseDeleteDataStream._get_http_options() ) + request, metadata = self._interceptor.pre_delete_data_stream( request, metadata ) @@ -3116,6 +3887,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.DeleteDataStream", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "DeleteDataStream", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._DeleteDataStream._get_response( @@ -3168,7 +3966,7 @@ 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 firebase link method over HTTP. @@ -3179,13 +3977,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 = ( _BaseAnalyticsAdminServiceRestTransport._BaseDeleteFirebaseLink._get_http_options() ) + request, metadata = self._interceptor.pre_delete_firebase_link( request, metadata ) @@ -3198,6 +3999,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.DeleteFirebaseLink", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "DeleteFirebaseLink", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._DeleteFirebaseLink._get_response( @@ -3250,7 +4078,7 @@ 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 google ads link method over HTTP. @@ -3261,13 +4089,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 = ( _BaseAnalyticsAdminServiceRestTransport._BaseDeleteGoogleAdsLink._get_http_options() ) + request, metadata = self._interceptor.pre_delete_google_ads_link( request, metadata ) @@ -3280,6 +4111,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.DeleteGoogleAdsLink", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "DeleteGoogleAdsLink", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._DeleteGoogleAdsLink._get_response( @@ -3332,7 +4190,7 @@ 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 key event method over HTTP. @@ -3343,13 +4201,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 = ( _BaseAnalyticsAdminServiceRestTransport._BaseDeleteKeyEvent._get_http_options() ) + request, metadata = self._interceptor.pre_delete_key_event( request, metadata ) @@ -3362,6 +4223,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.DeleteKeyEvent", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "DeleteKeyEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._DeleteKeyEvent._get_response( self._host, @@ -3414,7 +4302,7 @@ 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 measurement protocol secret method over HTTP. @@ -3426,13 +4314,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 = ( _BaseAnalyticsAdminServiceRestTransport._BaseDeleteMeasurementProtocolSecret._get_http_options() ) + ( request, metadata, @@ -3448,6 +4339,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.DeleteMeasurementProtocolSecret", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "DeleteMeasurementProtocolSecret", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._DeleteMeasurementProtocolSecret._get_response( self._host, @@ -3498,7 +4416,7 @@ 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.Property: r"""Call the delete property method over HTTP. @@ -3509,8 +4427,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.Property: @@ -3522,6 +4442,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseDeleteProperty._get_http_options() ) + request, metadata = self._interceptor.pre_delete_property(request, metadata) transcoded_request = _BaseAnalyticsAdminServiceRestTransport._BaseDeleteProperty._get_transcoded_request( http_options, request @@ -3532,6 +4453,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.DeleteProperty", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "DeleteProperty", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._DeleteProperty._get_response( self._host, @@ -3552,7 +4500,29 @@ def __call__( pb_resp = resources.Property.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_property(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Property.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.delete_property", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "DeleteProperty", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAccount( @@ -3590,7 +4560,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Account: r"""Call the get account method over HTTP. @@ -3600,8 +4570,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.Account: @@ -3613,6 +4585,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetAccount._get_http_options() ) + request, metadata = self._interceptor.pre_get_account(request, metadata) transcoded_request = _BaseAnalyticsAdminServiceRestTransport._BaseGetAccount._get_transcoded_request( http_options, request @@ -3623,6 +4596,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.GetAccount", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "GetAccount", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._GetAccount._get_response( self._host, @@ -3643,7 +4643,29 @@ def __call__( pb_resp = resources.Account.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_account(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Account.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.get_account", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "GetAccount", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetConversionEvent( @@ -3681,7 +4703,7 @@ 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.ConversionEvent: r"""Call the get conversion event method over HTTP. @@ -3692,8 +4714,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ConversionEvent: @@ -3705,6 +4729,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetConversionEvent._get_http_options() ) + request, metadata = self._interceptor.pre_get_conversion_event( request, metadata ) @@ -3717,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 = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.GetConversionEvent", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "GetConversionEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._GetConversionEvent._get_response( @@ -3739,7 +4791,29 @@ def __call__( pb_resp = resources.ConversionEvent.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_conversion_event(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.ConversionEvent.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.get_conversion_event", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "GetConversionEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCustomDimension( @@ -3777,7 +4851,7 @@ 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.CustomDimension: r"""Call the get custom dimension method over HTTP. @@ -3788,8 +4862,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.CustomDimension: @@ -3799,6 +4875,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetCustomDimension._get_http_options() ) + request, metadata = self._interceptor.pre_get_custom_dimension( request, metadata ) @@ -3811,6 +4888,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.GetCustomDimension", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "GetCustomDimension", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._GetCustomDimension._get_response( @@ -3833,7 +4937,29 @@ def __call__( pb_resp = resources.CustomDimension.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_custom_dimension(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.CustomDimension.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.get_custom_dimension", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "GetCustomDimension", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCustomMetric( @@ -3871,7 +4997,7 @@ 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.CustomMetric: r"""Call the get custom metric method over HTTP. @@ -3882,8 +5008,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.CustomMetric: @@ -3893,6 +5021,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetCustomMetric._get_http_options() ) + request, metadata = self._interceptor.pre_get_custom_metric( request, metadata ) @@ -3905,6 +5034,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.GetCustomMetric", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "GetCustomMetric", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._GetCustomMetric._get_response( @@ -3927,7 +5083,29 @@ def __call__( pb_resp = resources.CustomMetric.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_custom_metric(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.CustomMetric.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.get_custom_metric", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "GetCustomMetric", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDataRetentionSettings( @@ -3965,7 +5143,7 @@ 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.DataRetentionSettings: r"""Call the get data retention settings method over HTTP. @@ -3977,8 +5155,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.DataRetentionSettings: @@ -3990,6 +5170,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetDataRetentionSettings._get_http_options() ) + request, metadata = self._interceptor.pre_get_data_retention_settings( request, metadata ) @@ -4002,6 +5183,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.GetDataRetentionSettings", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "GetDataRetentionSettings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._GetDataRetentionSettings._get_response( self._host, @@ -4022,7 +5230,29 @@ def __call__( pb_resp = resources.DataRetentionSettings.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_data_retention_settings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.DataRetentionSettings.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.get_data_retention_settings", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "GetDataRetentionSettings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDataSharingSettings( @@ -4060,7 +5290,7 @@ 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.DataSharingSettings: r"""Call the get data sharing settings method over HTTP. @@ -4071,8 +5301,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.DataSharingSettings: @@ -4085,6 +5317,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetDataSharingSettings._get_http_options() ) + request, metadata = self._interceptor.pre_get_data_sharing_settings( request, metadata ) @@ -4097,6 +5330,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.GetDataSharingSettings", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "GetDataSharingSettings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._GetDataSharingSettings._get_response( self._host, @@ -4117,7 +5377,29 @@ def __call__( pb_resp = resources.DataSharingSettings.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_data_sharing_settings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.DataSharingSettings.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.get_data_sharing_settings", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "GetDataSharingSettings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDataStream( @@ -4155,7 +5437,7 @@ 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.DataStream: r"""Call the get data stream method over HTTP. @@ -4166,8 +5448,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.DataStream: @@ -4179,6 +5463,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetDataStream._get_http_options() ) + request, metadata = self._interceptor.pre_get_data_stream(request, metadata) transcoded_request = _BaseAnalyticsAdminServiceRestTransport._BaseGetDataStream._get_transcoded_request( http_options, request @@ -4189,6 +5474,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.GetDataStream", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "GetDataStream", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._GetDataStream._get_response( self._host, @@ -4209,7 +5521,29 @@ def __call__( pb_resp = resources.DataStream.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_data_stream(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.DataStream.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.get_data_stream", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "GetDataStream", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetKeyEvent( @@ -4247,7 +5581,7 @@ 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.KeyEvent: r"""Call the get key event method over HTTP. @@ -4257,8 +5591,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.KeyEvent: @@ -4270,6 +5606,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetKeyEvent._get_http_options() ) + request, metadata = self._interceptor.pre_get_key_event(request, metadata) transcoded_request = _BaseAnalyticsAdminServiceRestTransport._BaseGetKeyEvent._get_transcoded_request( http_options, request @@ -4280,6 +5617,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.GetKeyEvent", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "GetKeyEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._GetKeyEvent._get_response( self._host, @@ -4300,7 +5664,29 @@ def __call__( pb_resp = resources.KeyEvent.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_key_event(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.KeyEvent.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.get_key_event", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "GetKeyEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetMeasurementProtocolSecret( @@ -4340,7 +5726,7 @@ 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.MeasurementProtocolSecret: r"""Call the get measurement protocol secret method over HTTP. @@ -4352,8 +5738,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.MeasurementProtocolSecret: @@ -4365,6 +5753,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetMeasurementProtocolSecret._get_http_options() ) + request, metadata = self._interceptor.pre_get_measurement_protocol_secret( request, metadata ) @@ -4377,6 +5766,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.GetMeasurementProtocolSecret", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "GetMeasurementProtocolSecret", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._GetMeasurementProtocolSecret._get_response( self._host, @@ -4397,7 +5813,31 @@ def __call__( pb_resp = resources.MeasurementProtocolSecret.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_measurement_protocol_secret(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.MeasurementProtocolSecret.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.get_measurement_protocol_secret", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "GetMeasurementProtocolSecret", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetProperty( @@ -4435,7 +5875,7 @@ 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.Property: r"""Call the get property method over HTTP. @@ -4445,8 +5885,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.Property: @@ -4458,6 +5900,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseGetProperty._get_http_options() ) + request, metadata = self._interceptor.pre_get_property(request, metadata) transcoded_request = _BaseAnalyticsAdminServiceRestTransport._BaseGetProperty._get_transcoded_request( http_options, request @@ -4468,6 +5911,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.GetProperty", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "GetProperty", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._GetProperty._get_response( self._host, @@ -4488,7 +5958,29 @@ def __call__( pb_resp = resources.Property.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_property(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Property.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.get_property", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "GetProperty", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAccounts( @@ -4526,7 +6018,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListAccountsResponse: r"""Call the list accounts method over HTTP. @@ -4536,8 +6028,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListAccountsResponse: @@ -4547,6 +6041,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListAccounts._get_http_options() ) + request, metadata = self._interceptor.pre_list_accounts(request, metadata) transcoded_request = _BaseAnalyticsAdminServiceRestTransport._BaseListAccounts._get_transcoded_request( http_options, request @@ -4557,6 +6052,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.ListAccounts", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "ListAccounts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._ListAccounts._get_response( self._host, @@ -4577,7 +6099,31 @@ def __call__( pb_resp = analytics_admin.ListAccountsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_accounts(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = analytics_admin.ListAccountsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.list_accounts", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "ListAccounts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAccountSummaries( @@ -4615,7 +6161,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListAccountSummariesResponse: r"""Call the list account summaries method over HTTP. @@ -4626,8 +6172,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListAccountSummariesResponse: @@ -4639,6 +6187,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListAccountSummaries._get_http_options() ) + request, metadata = self._interceptor.pre_list_account_summaries( request, metadata ) @@ -4651,6 +6200,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.ListAccountSummaries", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "ListAccountSummaries", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._ListAccountSummaries._get_response( @@ -4673,7 +6249,31 @@ def __call__( pb_resp = analytics_admin.ListAccountSummariesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_account_summaries(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.ListAccountSummariesResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.list_account_summaries", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "ListAccountSummaries", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListConversionEvents( @@ -4711,7 +6311,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListConversionEventsResponse: r"""Call the list conversion events method over HTTP. @@ -4722,8 +6322,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListConversionEventsResponse: @@ -4735,6 +6337,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListConversionEvents._get_http_options() ) + request, metadata = self._interceptor.pre_list_conversion_events( request, metadata ) @@ -4747,6 +6350,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.ListConversionEvents", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "ListConversionEvents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._ListConversionEvents._get_response( @@ -4769,7 +6399,31 @@ def __call__( pb_resp = analytics_admin.ListConversionEventsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_conversion_events(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.ListConversionEventsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.list_conversion_events", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "ListConversionEvents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCustomDimensions( @@ -4807,7 +6461,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListCustomDimensionsResponse: r"""Call the list custom dimensions method over HTTP. @@ -4818,8 +6472,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListCustomDimensionsResponse: @@ -4831,6 +6487,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListCustomDimensions._get_http_options() ) + request, metadata = self._interceptor.pre_list_custom_dimensions( request, metadata ) @@ -4843,6 +6500,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.ListCustomDimensions", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "ListCustomDimensions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._ListCustomDimensions._get_response( @@ -4865,7 +6549,31 @@ def __call__( pb_resp = analytics_admin.ListCustomDimensionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_custom_dimensions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.ListCustomDimensionsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.list_custom_dimensions", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "ListCustomDimensions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCustomMetrics( @@ -4903,7 +6611,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListCustomMetricsResponse: r"""Call the list custom metrics method over HTTP. @@ -4914,8 +6622,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListCustomMetricsResponse: @@ -4927,6 +6637,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListCustomMetrics._get_http_options() ) + request, metadata = self._interceptor.pre_list_custom_metrics( request, metadata ) @@ -4939,6 +6650,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.ListCustomMetrics", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "ListCustomMetrics", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._ListCustomMetrics._get_response( @@ -4961,7 +6699,31 @@ def __call__( pb_resp = analytics_admin.ListCustomMetricsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_custom_metrics(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.ListCustomMetricsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.list_custom_metrics", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "ListCustomMetrics", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDataStreams( @@ -4999,7 +6761,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListDataStreamsResponse: r"""Call the list data streams method over HTTP. @@ -5010,8 +6772,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListDataStreamsResponse: @@ -5023,6 +6787,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListDataStreams._get_http_options() ) + request, metadata = self._interceptor.pre_list_data_streams( request, metadata ) @@ -5035,6 +6800,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.ListDataStreams", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "ListDataStreams", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._ListDataStreams._get_response( @@ -5057,7 +6849,31 @@ def __call__( pb_resp = analytics_admin.ListDataStreamsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_data_streams(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = analytics_admin.ListDataStreamsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.list_data_streams", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "ListDataStreams", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListFirebaseLinks( @@ -5095,7 +6911,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListFirebaseLinksResponse: r"""Call the list firebase links method over HTTP. @@ -5106,8 +6922,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListFirebaseLinksResponse: @@ -5119,6 +6937,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListFirebaseLinks._get_http_options() ) + request, metadata = self._interceptor.pre_list_firebase_links( request, metadata ) @@ -5131,6 +6950,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.ListFirebaseLinks", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "ListFirebaseLinks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._ListFirebaseLinks._get_response( @@ -5153,7 +6999,31 @@ def __call__( pb_resp = analytics_admin.ListFirebaseLinksResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_firebase_links(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.ListFirebaseLinksResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.list_firebase_links", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "ListFirebaseLinks", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListGoogleAdsLinks( @@ -5191,7 +7061,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListGoogleAdsLinksResponse: r"""Call the list google ads links method over HTTP. @@ -5202,8 +7072,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListGoogleAdsLinksResponse: @@ -5215,6 +7087,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListGoogleAdsLinks._get_http_options() ) + request, metadata = self._interceptor.pre_list_google_ads_links( request, metadata ) @@ -5227,6 +7100,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.ListGoogleAdsLinks", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "ListGoogleAdsLinks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._ListGoogleAdsLinks._get_response( @@ -5249,7 +7149,31 @@ def __call__( pb_resp = analytics_admin.ListGoogleAdsLinksResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_google_ads_links(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.ListGoogleAdsLinksResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.list_google_ads_links", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "ListGoogleAdsLinks", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListKeyEvents( @@ -5287,7 +7211,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListKeyEventsResponse: r"""Call the list key events method over HTTP. @@ -5297,8 +7221,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListKeyEventsResponse: @@ -5310,6 +7236,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListKeyEvents._get_http_options() ) + request, metadata = self._interceptor.pre_list_key_events(request, metadata) transcoded_request = _BaseAnalyticsAdminServiceRestTransport._BaseListKeyEvents._get_transcoded_request( http_options, request @@ -5320,6 +7247,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.ListKeyEvents", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "ListKeyEvents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._ListKeyEvents._get_response( self._host, @@ -5340,7 +7294,31 @@ def __call__( pb_resp = analytics_admin.ListKeyEventsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_key_events(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = analytics_admin.ListKeyEventsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.list_key_events", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "ListKeyEvents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListMeasurementProtocolSecrets( @@ -5380,7 +7358,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListMeasurementProtocolSecretsResponse: r"""Call the list measurement protocol secrets method over HTTP. @@ -5392,8 +7370,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListMeasurementProtocolSecretsResponse: @@ -5405,6 +7385,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListMeasurementProtocolSecrets._get_http_options() ) + request, metadata = self._interceptor.pre_list_measurement_protocol_secrets( request, metadata ) @@ -5417,6 +7398,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.ListMeasurementProtocolSecrets", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "ListMeasurementProtocolSecrets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._ListMeasurementProtocolSecrets._get_response( self._host, @@ -5437,7 +7445,33 @@ def __call__( pb_resp = analytics_admin.ListMeasurementProtocolSecretsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_measurement_protocol_secrets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.ListMeasurementProtocolSecretsResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.list_measurement_protocol_secrets", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "ListMeasurementProtocolSecrets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListProperties( @@ -5475,7 +7509,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ListPropertiesResponse: r"""Call the list properties method over HTTP. @@ -5486,8 +7520,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ListPropertiesResponse: @@ -5499,6 +7535,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseListProperties._get_http_options() ) + request, metadata = self._interceptor.pre_list_properties(request, metadata) transcoded_request = _BaseAnalyticsAdminServiceRestTransport._BaseListProperties._get_transcoded_request( http_options, request @@ -5509,6 +7546,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.ListProperties", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "ListProperties", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._ListProperties._get_response( self._host, @@ -5529,7 +7593,31 @@ def __call__( pb_resp = analytics_admin.ListPropertiesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_properties(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = analytics_admin.ListPropertiesResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.list_properties", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "ListProperties", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ProvisionAccountTicket( @@ -5568,7 +7656,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.ProvisionAccountTicketResponse: r"""Call the provision account ticket method over HTTP. @@ -5579,8 +7667,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.ProvisionAccountTicketResponse: @@ -5592,6 +7682,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseProvisionAccountTicket._get_http_options() ) + request, metadata = self._interceptor.pre_provision_account_ticket( request, metadata ) @@ -5608,6 +7699,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.ProvisionAccountTicket", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "ProvisionAccountTicket", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._ProvisionAccountTicket._get_response( self._host, @@ -5629,7 +7747,31 @@ def __call__( pb_resp = analytics_admin.ProvisionAccountTicketResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_provision_account_ticket(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.ProvisionAccountTicketResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.provision_account_ticket", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "ProvisionAccountTicket", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RunAccessReport( @@ -5668,7 +7810,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.RunAccessReportResponse: r"""Call the run access report method over HTTP. @@ -5679,8 +7821,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.RunAccessReportResponse: @@ -5692,6 +7836,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseRunAccessReport._get_http_options() ) + request, metadata = self._interceptor.pre_run_access_report( request, metadata ) @@ -5708,6 +7853,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.RunAccessReport", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "RunAccessReport", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._RunAccessReport._get_response( @@ -5731,7 +7903,31 @@ def __call__( pb_resp = analytics_admin.RunAccessReportResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_run_access_report(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = analytics_admin.RunAccessReportResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.run_access_report", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "RunAccessReport", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchChangeHistoryEvents( @@ -5770,7 +7966,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_admin.SearchChangeHistoryEventsResponse: r"""Call the search change history events method over HTTP. @@ -5782,8 +7978,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_admin.SearchChangeHistoryEventsResponse: @@ -5795,6 +7993,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseSearchChangeHistoryEvents._get_http_options() ) + request, metadata = self._interceptor.pre_search_change_history_events( request, metadata ) @@ -5811,6 +8010,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.SearchChangeHistoryEvents", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "SearchChangeHistoryEvents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._SearchChangeHistoryEvents._get_response( self._host, @@ -5832,7 +8058,33 @@ def __call__( pb_resp = analytics_admin.SearchChangeHistoryEventsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_change_history_events(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_admin.SearchChangeHistoryEventsResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.search_change_history_events", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "SearchChangeHistoryEvents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateAccount( @@ -5871,7 +8123,7 @@ 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.Account: r"""Call the update account method over HTTP. @@ -5882,8 +8134,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.Account: @@ -5895,6 +8149,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseUpdateAccount._get_http_options() ) + request, metadata = self._interceptor.pre_update_account(request, metadata) transcoded_request = _BaseAnalyticsAdminServiceRestTransport._BaseUpdateAccount._get_transcoded_request( http_options, request @@ -5909,6 +8164,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.UpdateAccount", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "UpdateAccount", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._UpdateAccount._get_response( self._host, @@ -5930,7 +8212,29 @@ def __call__( pb_resp = resources.Account.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_account(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Account.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.update_account", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "UpdateAccount", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateConversionEvent( @@ -5969,7 +8273,7 @@ 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.ConversionEvent: r"""Call the update conversion event method over HTTP. @@ -5980,8 +8284,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ConversionEvent: @@ -5993,6 +8299,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseUpdateConversionEvent._get_http_options() ) + request, metadata = self._interceptor.pre_update_conversion_event( request, metadata ) @@ -6009,6 +8316,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.UpdateConversionEvent", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "UpdateConversionEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._UpdateConversionEvent._get_response( @@ -6032,7 +8366,29 @@ def __call__( pb_resp = resources.ConversionEvent.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_conversion_event(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.ConversionEvent.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.update_conversion_event", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "UpdateConversionEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCustomDimension( @@ -6071,7 +8427,7 @@ 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.CustomDimension: r"""Call the update custom dimension method over HTTP. @@ -6082,8 +8438,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.CustomDimension: @@ -6093,6 +8451,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseUpdateCustomDimension._get_http_options() ) + request, metadata = self._interceptor.pre_update_custom_dimension( request, metadata ) @@ -6109,6 +8468,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.UpdateCustomDimension", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "UpdateCustomDimension", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._UpdateCustomDimension._get_response( @@ -6132,7 +8518,29 @@ def __call__( pb_resp = resources.CustomDimension.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_custom_dimension(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.CustomDimension.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.update_custom_dimension", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "UpdateCustomDimension", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCustomMetric( @@ -6171,7 +8579,7 @@ 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.CustomMetric: r"""Call the update custom metric method over HTTP. @@ -6182,8 +8590,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.CustomMetric: @@ -6193,6 +8603,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseUpdateCustomMetric._get_http_options() ) + request, metadata = self._interceptor.pre_update_custom_metric( request, metadata ) @@ -6209,6 +8620,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.UpdateCustomMetric", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "UpdateCustomMetric", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._UpdateCustomMetric._get_response( @@ -6232,7 +8670,29 @@ def __call__( pb_resp = resources.CustomMetric.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_custom_metric(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.CustomMetric.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.update_custom_metric", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "UpdateCustomMetric", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateDataRetentionSettings( @@ -6273,7 +8733,7 @@ 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.DataRetentionSettings: r"""Call the update data retention settings method over HTTP. @@ -6285,8 +8745,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.DataRetentionSettings: @@ -6298,6 +8760,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseUpdateDataRetentionSettings._get_http_options() ) + request, metadata = self._interceptor.pre_update_data_retention_settings( request, metadata ) @@ -6314,6 +8777,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.UpdateDataRetentionSettings", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "UpdateDataRetentionSettings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._UpdateDataRetentionSettings._get_response( self._host, @@ -6335,7 +8825,29 @@ def __call__( pb_resp = resources.DataRetentionSettings.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_data_retention_settings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.DataRetentionSettings.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.update_data_retention_settings", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "UpdateDataRetentionSettings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateDataStream( @@ -6374,7 +8886,7 @@ 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.DataStream: r"""Call the update data stream method over HTTP. @@ -6385,8 +8897,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.DataStream: @@ -6398,6 +8912,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseUpdateDataStream._get_http_options() ) + request, metadata = self._interceptor.pre_update_data_stream( request, metadata ) @@ -6414,6 +8929,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.UpdateDataStream", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "UpdateDataStream", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._UpdateDataStream._get_response( @@ -6437,7 +8979,29 @@ def __call__( pb_resp = resources.DataStream.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_data_stream(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.DataStream.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.update_data_stream", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "UpdateDataStream", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateGoogleAdsLink( @@ -6476,7 +9040,7 @@ 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.GoogleAdsLink: r"""Call the update google ads link method over HTTP. @@ -6487,8 +9051,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.GoogleAdsLink: @@ -6500,6 +9066,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseUpdateGoogleAdsLink._get_http_options() ) + request, metadata = self._interceptor.pre_update_google_ads_link( request, metadata ) @@ -6516,6 +9083,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.UpdateGoogleAdsLink", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "UpdateGoogleAdsLink", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AnalyticsAdminServiceRestTransport._UpdateGoogleAdsLink._get_response( @@ -6539,7 +9133,29 @@ def __call__( pb_resp = resources.GoogleAdsLink.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_google_ads_link(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.GoogleAdsLink.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.update_google_ads_link", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "UpdateGoogleAdsLink", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateKeyEvent( @@ -6578,7 +9194,7 @@ 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.KeyEvent: r"""Call the update key event method over HTTP. @@ -6589,8 +9205,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.KeyEvent: @@ -6602,6 +9220,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseUpdateKeyEvent._get_http_options() ) + request, metadata = self._interceptor.pre_update_key_event( request, metadata ) @@ -6618,6 +9237,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.UpdateKeyEvent", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "UpdateKeyEvent", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._UpdateKeyEvent._get_response( self._host, @@ -6639,7 +9285,29 @@ def __call__( pb_resp = resources.KeyEvent.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_key_event(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.KeyEvent.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.update_key_event", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "UpdateKeyEvent", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateMeasurementProtocolSecret( @@ -6680,7 +9348,7 @@ 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.MeasurementProtocolSecret: r"""Call the update measurement protocol secret method over HTTP. @@ -6692,8 +9360,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.MeasurementProtocolSecret: @@ -6705,6 +9375,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseUpdateMeasurementProtocolSecret._get_http_options() ) + ( request, metadata, @@ -6724,6 +9395,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.UpdateMeasurementProtocolSecret", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "UpdateMeasurementProtocolSecret", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._UpdateMeasurementProtocolSecret._get_response( self._host, @@ -6745,7 +9443,31 @@ def __call__( pb_resp = resources.MeasurementProtocolSecret.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_measurement_protocol_secret(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.MeasurementProtocolSecret.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.update_measurement_protocol_secret", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "UpdateMeasurementProtocolSecret", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateProperty( @@ -6784,7 +9506,7 @@ 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.Property: r"""Call the update property method over HTTP. @@ -6795,8 +9517,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.Property: @@ -6808,6 +9532,7 @@ def __call__( http_options = ( _BaseAnalyticsAdminServiceRestTransport._BaseUpdateProperty._get_http_options() ) + request, metadata = self._interceptor.pre_update_property(request, metadata) transcoded_request = _BaseAnalyticsAdminServiceRestTransport._BaseUpdateProperty._get_transcoded_request( http_options, request @@ -6822,6 +9547,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.UpdateProperty", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "UpdateProperty", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AnalyticsAdminServiceRestTransport._UpdateProperty._get_response( self._host, @@ -6843,7 +9595,29 @@ def __call__( pb_resp = resources.Property.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_property(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Property.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.admin_v1beta.AnalyticsAdminServiceClient.update_property", + extra={ + "serviceName": "google.analytics.admin.v1beta.AnalyticsAdminService", + "rpcName": "UpdateProperty", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-analytics-admin/samples/generated_samples/snippet_metadata_google.analytics.admin.v1beta.json b/packages/google-analytics-admin/samples/generated_samples/snippet_metadata_google.analytics.admin.v1beta.json index 5141448d6c81..940f43c20e40 100644 --- a/packages/google-analytics-admin/samples/generated_samples/snippet_metadata_google.analytics.admin.v1beta.json +++ b/packages/google-analytics-admin/samples/generated_samples/snippet_metadata_google.analytics.admin.v1beta.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-analytics-admin", - "version": "0.23.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.analytics.admin_v1beta.types.AcknowledgeUserDataCollectionResponse", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.AcknowledgeUserDataCollectionResponse", @@ -200,7 +200,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "archive_custom_dimension" @@ -277,7 +277,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "archive_custom_dimension" @@ -355,7 +355,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "archive_custom_metric" @@ -432,7 +432,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "archive_custom_metric" @@ -514,7 +514,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.ConversionEvent", @@ -598,7 +598,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.ConversionEvent", @@ -683,7 +683,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.CustomDimension", @@ -767,7 +767,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.CustomDimension", @@ -852,7 +852,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.CustomMetric", @@ -936,7 +936,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.CustomMetric", @@ -1021,7 +1021,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.DataStream", @@ -1105,7 +1105,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.DataStream", @@ -1190,7 +1190,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.FirebaseLink", @@ -1274,7 +1274,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.FirebaseLink", @@ -1359,7 +1359,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.GoogleAdsLink", @@ -1443,7 +1443,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.GoogleAdsLink", @@ -1528,7 +1528,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.KeyEvent", @@ -1612,7 +1612,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.KeyEvent", @@ -1697,7 +1697,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.MeasurementProtocolSecret", @@ -1781,7 +1781,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.MeasurementProtocolSecret", @@ -1862,7 +1862,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.Property", @@ -1942,7 +1942,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.Property", @@ -2023,7 +2023,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_account" @@ -2100,7 +2100,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_account" @@ -2178,7 +2178,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_conversion_event" @@ -2255,7 +2255,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_conversion_event" @@ -2333,7 +2333,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_data_stream" @@ -2410,7 +2410,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_data_stream" @@ -2488,7 +2488,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_firebase_link" @@ -2565,7 +2565,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_firebase_link" @@ -2643,7 +2643,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_google_ads_link" @@ -2720,7 +2720,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_google_ads_link" @@ -2798,7 +2798,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_key_event" @@ -2875,7 +2875,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_key_event" @@ -2953,7 +2953,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_measurement_protocol_secret" @@ -3030,7 +3030,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_measurement_protocol_secret" @@ -3108,7 +3108,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.Property", @@ -3188,7 +3188,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.Property", @@ -3269,7 +3269,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.Account", @@ -3349,7 +3349,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.Account", @@ -3430,7 +3430,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.ConversionEvent", @@ -3510,7 +3510,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.ConversionEvent", @@ -3591,7 +3591,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.CustomDimension", @@ -3671,7 +3671,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.CustomDimension", @@ -3752,7 +3752,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.CustomMetric", @@ -3832,7 +3832,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.CustomMetric", @@ -3913,7 +3913,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.DataRetentionSettings", @@ -3993,7 +3993,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.DataRetentionSettings", @@ -4074,7 +4074,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.DataSharingSettings", @@ -4154,7 +4154,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.DataSharingSettings", @@ -4235,7 +4235,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.DataStream", @@ -4315,7 +4315,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.DataStream", @@ -4396,7 +4396,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.KeyEvent", @@ -4476,7 +4476,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.KeyEvent", @@ -4557,7 +4557,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.MeasurementProtocolSecret", @@ -4637,7 +4637,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.MeasurementProtocolSecret", @@ -4718,7 +4718,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.Property", @@ -4798,7 +4798,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.Property", @@ -4875,7 +4875,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListAccountSummariesAsyncPager", @@ -4951,7 +4951,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListAccountSummariesPager", @@ -5028,7 +5028,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListAccountsAsyncPager", @@ -5104,7 +5104,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListAccountsPager", @@ -5185,7 +5185,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListConversionEventsAsyncPager", @@ -5265,7 +5265,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListConversionEventsPager", @@ -5346,7 +5346,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListCustomDimensionsAsyncPager", @@ -5426,7 +5426,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListCustomDimensionsPager", @@ -5507,7 +5507,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListCustomMetricsAsyncPager", @@ -5587,7 +5587,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListCustomMetricsPager", @@ -5668,7 +5668,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListDataStreamsAsyncPager", @@ -5748,7 +5748,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListDataStreamsPager", @@ -5829,7 +5829,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListFirebaseLinksAsyncPager", @@ -5909,7 +5909,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListFirebaseLinksPager", @@ -5990,7 +5990,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListGoogleAdsLinksAsyncPager", @@ -6070,7 +6070,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListGoogleAdsLinksPager", @@ -6151,7 +6151,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListKeyEventsAsyncPager", @@ -6231,7 +6231,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListKeyEventsPager", @@ -6312,7 +6312,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListMeasurementProtocolSecretsAsyncPager", @@ -6392,7 +6392,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListMeasurementProtocolSecretsPager", @@ -6469,7 +6469,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListPropertiesAsyncPager", @@ -6545,7 +6545,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.services.analytics_admin_service.pagers.ListPropertiesPager", @@ -6622,7 +6622,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.ProvisionAccountTicketResponse", @@ -6698,7 +6698,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.ProvisionAccountTicketResponse", @@ -6775,7 +6775,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.RunAccessReportResponse", @@ -6851,7 +6851,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.RunAccessReportResponse", @@ -6928,7 +6928,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.services.analytics_admin_service.pagers.SearchChangeHistoryEventsAsyncPager", @@ -7004,7 +7004,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.services.analytics_admin_service.pagers.SearchChangeHistoryEventsPager", @@ -7089,7 +7089,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.Account", @@ -7173,7 +7173,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.Account", @@ -7258,7 +7258,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.ConversionEvent", @@ -7342,7 +7342,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.ConversionEvent", @@ -7427,7 +7427,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.CustomDimension", @@ -7511,7 +7511,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.CustomDimension", @@ -7596,7 +7596,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.CustomMetric", @@ -7680,7 +7680,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.CustomMetric", @@ -7765,7 +7765,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.DataRetentionSettings", @@ -7849,7 +7849,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.DataRetentionSettings", @@ -7934,7 +7934,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.DataStream", @@ -8018,7 +8018,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.DataStream", @@ -8103,7 +8103,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.GoogleAdsLink", @@ -8187,7 +8187,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.GoogleAdsLink", @@ -8272,7 +8272,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.KeyEvent", @@ -8356,7 +8356,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.KeyEvent", @@ -8441,7 +8441,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.MeasurementProtocolSecret", @@ -8525,7 +8525,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.MeasurementProtocolSecret", @@ -8610,7 +8610,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.Property", @@ -8694,7 +8694,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.admin_v1beta.types.Property", diff --git a/packages/google-analytics-admin/tests/unit/gapic/admin_v1alpha/test_analytics_admin_service.py b/packages/google-analytics-admin/tests/unit/gapic/admin_v1alpha/test_analytics_admin_service.py index 881d7f07eeda..1fc6486dafa7 100644 --- a/packages/google-analytics-admin/tests/unit/gapic/admin_v1alpha/test_analytics_admin_service.py +++ b/packages/google-analytics-admin/tests/unit/gapic/admin_v1alpha/test_analytics_admin_service.py @@ -56548,6 +56548,7 @@ def test_get_account_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_account(request) @@ -56593,6 +56594,7 @@ def test_get_account_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_account(**mock_args) @@ -56818,6 +56820,7 @@ def test_delete_account_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_account(request) @@ -56861,6 +56864,7 @@ def test_delete_account_rest_flattened(): json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_account(**mock_args) @@ -56988,6 +56992,7 @@ def test_update_account_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_account(request) @@ -57042,6 +57047,7 @@ def test_update_account_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_account(**mock_args) @@ -57317,6 +57323,7 @@ def test_get_property_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_property(request) @@ -57362,6 +57369,7 @@ def test_get_property_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_property(**mock_args) @@ -57503,6 +57511,7 @@ def test_list_properties_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_properties(request) @@ -57697,6 +57706,7 @@ def test_create_property_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_property(request) @@ -57742,6 +57752,7 @@ def test_create_property_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_property(**mock_args) @@ -57871,6 +57882,7 @@ def test_delete_property_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_property(request) @@ -57916,6 +57928,7 @@ def test_delete_property_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_property(**mock_args) @@ -58043,6 +58056,7 @@ def test_update_property_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_property(request) @@ -58097,6 +58111,7 @@ def test_update_property_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_property(**mock_args) @@ -58232,6 +58247,7 @@ def test_create_firebase_link_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_firebase_link(request) @@ -58286,6 +58302,7 @@ def test_create_firebase_link_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_firebase_link(**mock_args) @@ -58418,6 +58435,7 @@ def test_delete_firebase_link_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_firebase_link(request) @@ -58461,6 +58479,7 @@ def test_delete_firebase_link_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_firebase_link(**mock_args) @@ -58602,6 +58621,7 @@ def test_list_firebase_links_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_firebase_links(request) @@ -58655,6 +58675,7 @@ def test_list_firebase_links_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_firebase_links(**mock_args) @@ -58852,6 +58873,7 @@ def test_get_global_site_tag_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_global_site_tag(request) @@ -58899,6 +58921,7 @@ def test_get_global_site_tag_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_global_site_tag(**mock_args) @@ -59036,6 +59059,7 @@ def test_create_google_ads_link_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_google_ads_link(request) @@ -59090,6 +59114,7 @@ def test_create_google_ads_link_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_google_ads_link(**mock_args) @@ -59224,6 +59249,7 @@ def test_update_google_ads_link_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_google_ads_link(request) @@ -59272,6 +59298,7 @@ def test_update_google_ads_link_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_google_ads_link(**mock_args) @@ -59406,6 +59433,7 @@ def test_delete_google_ads_link_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_google_ads_link(request) @@ -59449,6 +59477,7 @@ def test_delete_google_ads_link_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_google_ads_link(**mock_args) @@ -59591,6 +59620,7 @@ def test_list_google_ads_links_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_google_ads_links(request) @@ -59644,6 +59674,7 @@ def test_list_google_ads_links_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_google_ads_links(**mock_args) @@ -59842,6 +59873,7 @@ def test_get_data_sharing_settings_rest_required_fields( response_value._content = json_return_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_sharing_settings(request) @@ -59887,6 +59919,7 @@ def test_get_data_sharing_settings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_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_sharing_settings(**mock_args) @@ -60022,6 +60055,7 @@ def test_get_measurement_protocol_secret_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_measurement_protocol_secret(request) @@ -60071,6 +60105,7 @@ def test_get_measurement_protocol_secret_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_measurement_protocol_secret(**mock_args) @@ -60216,6 +60251,7 @@ def test_list_measurement_protocol_secrets_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_measurement_protocol_secrets(request) @@ -60273,6 +60309,7 @@ def test_list_measurement_protocol_secrets_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_measurement_protocol_secrets(**mock_args) @@ -60478,6 +60515,7 @@ def test_create_measurement_protocol_secret_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_measurement_protocol_secret(request) @@ -60536,6 +60574,7 @@ def test_create_measurement_protocol_secret_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_measurement_protocol_secret(**mock_args) @@ -60674,6 +60713,7 @@ def test_delete_measurement_protocol_secret_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_measurement_protocol_secret(request) @@ -60721,6 +60761,7 @@ def test_delete_measurement_protocol_secret_rest_flattened(): json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_measurement_protocol_secret(**mock_args) @@ -60857,6 +60898,7 @@ def test_update_measurement_protocol_secret_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_measurement_protocol_secret(request) @@ -60919,6 +60961,7 @@ def test_update_measurement_protocol_secret_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_measurement_protocol_secret(**mock_args) @@ -61067,6 +61110,7 @@ def test_acknowledge_user_data_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.acknowledge_user_data_collection(request) @@ -61205,6 +61249,7 @@ def test_get_sk_ad_network_conversion_value_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_sk_ad_network_conversion_value_schema(request) @@ -61256,6 +61301,7 @@ def test_get_sk_ad_network_conversion_value_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_sk_ad_network_conversion_value_schema(**mock_args) @@ -61399,6 +61445,7 @@ def test_create_sk_ad_network_conversion_value_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_sk_ad_network_conversion_value_schema(request) @@ -61457,6 +61504,7 @@ def test_create_sk_ad_network_conversion_value_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_sk_ad_network_conversion_value_schema(**mock_args) @@ -61599,6 +61647,7 @@ def test_delete_sk_ad_network_conversion_value_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_sk_ad_network_conversion_value_schema(request) @@ -61646,6 +61695,7 @@ def test_delete_sk_ad_network_conversion_value_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_sk_ad_network_conversion_value_schema(**mock_args) @@ -61786,6 +61836,7 @@ def test_update_sk_ad_network_conversion_value_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_sk_ad_network_conversion_value_schema(request) @@ -61848,6 +61899,7 @@ def test_update_sk_ad_network_conversion_value_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_sk_ad_network_conversion_value_schema(**mock_args) @@ -62004,6 +62056,7 @@ def test_list_sk_ad_network_conversion_value_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_sk_ad_network_conversion_value_schemas(request) @@ -62061,6 +62114,7 @@ def test_list_sk_ad_network_conversion_value_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_sk_ad_network_conversion_value_schemas(**mock_args) @@ -62276,6 +62330,7 @@ def test_search_change_history_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.search_change_history_events(request) @@ -62464,6 +62519,7 @@ def test_get_google_signals_settings_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_google_signals_settings(request) @@ -62509,6 +62565,7 @@ def test_get_google_signals_settings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_google_signals_settings(**mock_args) @@ -62643,6 +62700,7 @@ def test_update_google_signals_settings_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_google_signals_settings(request) @@ -62703,6 +62761,7 @@ def test_update_google_signals_settings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_google_signals_settings(**mock_args) @@ -62841,6 +62900,7 @@ def test_create_conversion_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_conversion_event(request) @@ -62895,6 +62955,7 @@ def test_create_conversion_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_conversion_event(**mock_args) @@ -63030,6 +63091,7 @@ def test_update_conversion_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_conversion_event(request) @@ -63086,6 +63148,7 @@ def test_update_conversion_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_conversion_event(**mock_args) @@ -63222,6 +63285,7 @@ def test_get_conversion_event_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_conversion_event(request) @@ -63267,6 +63331,7 @@ def test_get_conversion_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_conversion_event(**mock_args) @@ -63400,6 +63465,7 @@ def test_delete_conversion_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_conversion_event(request) @@ -63443,6 +63509,7 @@ def test_delete_conversion_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_conversion_event(**mock_args) @@ -63586,6 +63653,7 @@ def test_list_conversion_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_conversion_events(request) @@ -63639,6 +63707,7 @@ def test_list_conversion_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_conversion_events(**mock_args) @@ -63836,6 +63905,7 @@ def test_create_key_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_key_event(request) @@ -63890,6 +63960,7 @@ def test_create_key_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_key_event(**mock_args) @@ -64021,6 +64092,7 @@ def test_update_key_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_key_event(request) @@ -64075,6 +64147,7 @@ def test_update_key_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_key_event(**mock_args) @@ -64207,6 +64280,7 @@ def test_get_key_event_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_key_event(request) @@ -64252,6 +64326,7 @@ def test_get_key_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_key_event(**mock_args) @@ -64381,6 +64456,7 @@ def test_delete_key_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_key_event(request) @@ -64424,6 +64500,7 @@ def test_delete_key_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_key_event(**mock_args) @@ -64561,6 +64638,7 @@ def test_list_key_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_key_events(request) @@ -64614,6 +64692,7 @@ def test_list_key_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_key_events(**mock_args) @@ -64812,6 +64891,7 @@ def test_get_display_video360_advertiser_link_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_display_video360_advertiser_link(request) @@ -64861,6 +64941,7 @@ def test_get_display_video360_advertiser_link_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_display_video360_advertiser_link(**mock_args) @@ -65014,6 +65095,7 @@ def test_list_display_video360_advertiser_links_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_display_video360_advertiser_links(request) @@ -65071,6 +65153,7 @@ def test_list_display_video360_advertiser_links_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_display_video360_advertiser_links(**mock_args) @@ -65282,6 +65365,7 @@ def test_create_display_video360_advertiser_link_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_display_video360_advertiser_link(request) @@ -65340,6 +65424,7 @@ def test_create_display_video360_advertiser_link_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_display_video360_advertiser_link(**mock_args) @@ -65482,6 +65567,7 @@ def test_delete_display_video360_advertiser_link_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_display_video360_advertiser_link(request) @@ -65529,6 +65615,7 @@ def test_delete_display_video360_advertiser_link_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_display_video360_advertiser_link(**mock_args) @@ -65669,6 +65756,7 @@ def test_update_display_video360_advertiser_link_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_display_video360_advertiser_link(request) @@ -65723,6 +65811,7 @@ def test_update_display_video360_advertiser_link_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_display_video360_advertiser_link(**mock_args) @@ -65870,6 +65959,7 @@ def test_get_display_video360_advertiser_link_proposal_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_display_video360_advertiser_link_proposal(request) @@ -65919,6 +66009,7 @@ def test_get_display_video360_advertiser_link_proposal_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_display_video360_advertiser_link_proposal(**mock_args) @@ -66072,6 +66163,7 @@ def test_list_display_video360_advertiser_link_proposals_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_display_video360_advertiser_link_proposals(request) @@ -66133,6 +66225,7 @@ def test_list_display_video360_advertiser_link_proposals_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_display_video360_advertiser_link_proposals(**mock_args) @@ -66355,6 +66448,7 @@ def test_create_display_video360_advertiser_link_proposal_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_display_video360_advertiser_link_proposal(request) @@ -66413,6 +66507,7 @@ def test_create_display_video360_advertiser_link_proposal_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_display_video360_advertiser_link_proposal(**mock_args) @@ -66555,6 +66650,7 @@ def test_delete_display_video360_advertiser_link_proposal_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_display_video360_advertiser_link_proposal(request) @@ -66602,6 +66698,7 @@ def test_delete_display_video360_advertiser_link_proposal_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_display_video360_advertiser_link_proposal(**mock_args) @@ -66751,6 +66848,7 @@ def test_approve_display_video360_advertiser_link_proposal_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.approve_display_video360_advertiser_link_proposal(request) @@ -66884,6 +66982,7 @@ def test_cancel_display_video360_advertiser_link_proposal_rest_required_fields( response_value._content = json_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_display_video360_advertiser_link_proposal(request) @@ -67011,6 +67110,7 @@ def test_create_custom_dimension_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_custom_dimension(request) @@ -67065,6 +67165,7 @@ def test_create_custom_dimension_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_custom_dimension(**mock_args) @@ -67200,6 +67301,7 @@ def test_update_custom_dimension_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_custom_dimension(request) @@ -67248,6 +67350,7 @@ def test_update_custom_dimension_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_custom_dimension(**mock_args) @@ -67392,6 +67495,7 @@ def test_list_custom_dimensions_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_custom_dimensions(request) @@ -67445,6 +67549,7 @@ def test_list_custom_dimensions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_custom_dimensions(**mock_args) @@ -67642,6 +67747,7 @@ def test_archive_custom_dimension_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.archive_custom_dimension(request) @@ -67685,6 +67791,7 @@ def test_archive_custom_dimension_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.archive_custom_dimension(**mock_args) @@ -67820,6 +67927,7 @@ def test_get_custom_dimension_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_custom_dimension(request) @@ -67865,6 +67973,7 @@ def test_get_custom_dimension_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_custom_dimension(**mock_args) @@ -68001,6 +68110,7 @@ def test_create_custom_metric_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_custom_metric(request) @@ -68055,6 +68165,7 @@ def test_create_custom_metric_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_custom_metric(**mock_args) @@ -68188,6 +68299,7 @@ def test_update_custom_metric_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_custom_metric(request) @@ -68236,6 +68348,7 @@ def test_update_custom_metric_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_custom_metric(**mock_args) @@ -68379,6 +68492,7 @@ def test_list_custom_metrics_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_custom_metrics(request) @@ -68432,6 +68546,7 @@ def test_list_custom_metrics_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_custom_metrics(**mock_args) @@ -68628,6 +68743,7 @@ def test_archive_custom_metric_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.archive_custom_metric(request) @@ -68671,6 +68787,7 @@ def test_archive_custom_metric_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.archive_custom_metric(**mock_args) @@ -68804,6 +68921,7 @@ def test_get_custom_metric_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_custom_metric(request) @@ -68849,6 +68967,7 @@ def test_get_custom_metric_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_custom_metric(**mock_args) @@ -68984,6 +69103,7 @@ def test_get_data_retention_settings_rest_required_fields( response_value._content = json_return_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_retention_settings(request) @@ -69029,6 +69149,7 @@ def test_get_data_retention_settings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_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_retention_settings(**mock_args) @@ -69163,6 +69284,7 @@ def test_update_data_retention_settings_rest_required_fields( response_value._content = json_return_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_retention_settings(request) @@ -69223,6 +69345,7 @@ def test_update_data_retention_settings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_retention_settings(**mock_args) @@ -69360,6 +69483,7 @@ def test_create_data_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_data_stream(request) @@ -69418,6 +69542,7 @@ def test_create_data_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_data_stream(**mock_args) @@ -69554,6 +69679,7 @@ def test_delete_data_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_data_stream(request) @@ -69597,6 +69723,7 @@ def test_delete_data_stream_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_stream(**mock_args) @@ -69729,6 +69856,7 @@ def test_update_data_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_data_stream(request) @@ -69781,6 +69909,7 @@ def test_update_data_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_data_stream(**mock_args) @@ -69926,6 +70055,7 @@ def test_list_data_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_data_streams(request) @@ -69979,6 +70109,7 @@ def test_list_data_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_data_streams(**mock_args) @@ -70172,6 +70303,7 @@ def test_get_data_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.get_data_stream(request) @@ -70217,6 +70349,7 @@ def test_get_data_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_data_stream(**mock_args) @@ -70347,6 +70480,7 @@ def test_get_audience_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_audience(request) @@ -70392,6 +70526,7 @@ def test_get_audience_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_audience(**mock_args) @@ -70529,6 +70664,7 @@ def test_list_audiences_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_audiences(request) @@ -70582,6 +70718,7 @@ def test_list_audiences_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_audiences(**mock_args) @@ -70776,6 +70913,7 @@ def test_create_audience_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_audience(request) @@ -70830,6 +70968,7 @@ def test_create_audience_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_audience(**mock_args) @@ -70959,6 +71098,7 @@ def test_update_audience_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_audience(request) @@ -71013,6 +71153,7 @@ def test_update_audience_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_audience(**mock_args) @@ -71145,6 +71286,7 @@ def test_archive_audience_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.archive_audience(request) @@ -71269,6 +71411,7 @@ def test_get_search_ads360_link_rest_required_fields( response_value._content = json_return_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_ads360_link(request) @@ -71314,6 +71457,7 @@ def test_get_search_ads360_link_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_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_ads360_link(**mock_args) @@ -71459,6 +71603,7 @@ def test_list_search_ads360_links_rest_required_fields( response_value._content = json_return_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_ads360_links(request) @@ -71512,6 +71657,7 @@ def test_list_search_ads360_links_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_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_ads360_links(**mock_args) @@ -71712,6 +71858,7 @@ def test_create_search_ads360_link_rest_required_fields( response_value._content = json_return_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_ads360_link(request) @@ -71766,6 +71913,7 @@ def test_create_search_ads360_link_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_ads360_link(**mock_args) @@ -71900,6 +72048,7 @@ def test_delete_search_ads360_link_rest_required_fields( response_value._content = json_return_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_ads360_link(request) @@ -71943,6 +72092,7 @@ def test_delete_search_ads360_link_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_ads360_link(**mock_args) @@ -72077,6 +72227,7 @@ def test_update_search_ads360_link_rest_required_fields( response_value._content = json_return_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_ads360_link(request) @@ -72127,6 +72278,7 @@ def test_update_search_ads360_link_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_ads360_link(**mock_args) @@ -72264,6 +72416,7 @@ def test_get_attribution_settings_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_attribution_settings(request) @@ -72309,6 +72462,7 @@ def test_get_attribution_settings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_attribution_settings(**mock_args) @@ -72443,6 +72597,7 @@ def test_update_attribution_settings_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_attribution_settings(request) @@ -72499,6 +72654,7 @@ def test_update_attribution_settings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_attribution_settings(**mock_args) @@ -72675,6 +72831,7 @@ def test_create_access_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_access_binding(request) @@ -72729,6 +72886,7 @@ def test_create_access_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_access_binding(**mock_args) @@ -72864,6 +73022,7 @@ def test_get_access_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_access_binding(request) @@ -72909,6 +73068,7 @@ def test_get_access_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_access_binding(**mock_args) @@ -73040,6 +73200,7 @@ def test_update_access_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_access_binding(request) @@ -73087,6 +73248,7 @@ def test_update_access_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_access_binding(**mock_args) @@ -73220,6 +73382,7 @@ def test_delete_access_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_access_binding(request) @@ -73263,6 +73426,7 @@ def test_delete_access_binding_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_access_binding(**mock_args) @@ -73404,6 +73568,7 @@ def test_list_access_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_access_bindings(request) @@ -73457,6 +73622,7 @@ def test_list_access_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_access_bindings(**mock_args) @@ -73658,6 +73824,7 @@ def test_batch_create_access_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.batch_create_access_bindings(request) @@ -73801,6 +73968,7 @@ def test_batch_get_access_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.batch_get_access_bindings(request) @@ -73942,6 +74110,7 @@ def test_batch_update_access_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.batch_update_access_bindings(request) @@ -74072,6 +74241,7 @@ def test_batch_delete_access_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.batch_delete_access_bindings(request) @@ -74204,6 +74374,7 @@ def test_get_expanded_data_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_expanded_data_set(request) @@ -74249,6 +74420,7 @@ def test_get_expanded_data_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_expanded_data_set(**mock_args) @@ -74392,6 +74564,7 @@ def test_list_expanded_data_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_expanded_data_sets(request) @@ -74445,6 +74618,7 @@ def test_list_expanded_data_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_expanded_data_sets(**mock_args) @@ -74645,6 +74819,7 @@ def test_create_expanded_data_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_expanded_data_set(request) @@ -74699,6 +74874,7 @@ def test_create_expanded_data_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_expanded_data_set(**mock_args) @@ -74834,6 +75010,7 @@ def test_update_expanded_data_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_expanded_data_set(request) @@ -74890,6 +75067,7 @@ def test_update_expanded_data_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_expanded_data_set(**mock_args) @@ -75024,6 +75202,7 @@ def test_delete_expanded_data_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_expanded_data_set(request) @@ -75067,6 +75246,7 @@ def test_delete_expanded_data_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_expanded_data_set(**mock_args) @@ -75200,6 +75380,7 @@ def test_get_channel_group_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_channel_group(request) @@ -75245,6 +75426,7 @@ def test_get_channel_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_channel_group(**mock_args) @@ -75386,6 +75568,7 @@ def test_list_channel_groups_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_channel_groups(request) @@ -75439,6 +75622,7 @@ def test_list_channel_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_channel_groups(**mock_args) @@ -75637,6 +75821,7 @@ def test_create_channel_group_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_channel_group(request) @@ -75691,6 +75876,7 @@ def test_create_channel_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_channel_group(**mock_args) @@ -75824,6 +76010,7 @@ def test_update_channel_group_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_channel_group(request) @@ -75880,6 +76067,7 @@ def test_update_channel_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_channel_group(**mock_args) @@ -76013,6 +76201,7 @@ def test_delete_channel_group_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_channel_group(request) @@ -76056,6 +76245,7 @@ def test_delete_channel_group_rest_flattened(): json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_channel_group(**mock_args) @@ -76200,6 +76390,7 @@ def test_set_automated_ga4_configuration_opt_out_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.set_automated_ga4_configuration_opt_out(request) @@ -76335,6 +76526,7 @@ def test_fetch_automated_ga4_configuration_opt_out_rest_required_fields( response_value._content = json_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_automated_ga4_configuration_opt_out(request) @@ -76464,6 +76656,7 @@ def test_create_big_query_link_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_big_query_link(request) @@ -76518,6 +76711,7 @@ def test_create_big_query_link_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_big_query_link(**mock_args) @@ -76653,6 +76847,7 @@ def test_get_big_query_link_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_big_query_link(request) @@ -76698,6 +76893,7 @@ def test_get_big_query_link_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_big_query_link(**mock_args) @@ -76839,6 +77035,7 @@ def test_list_big_query_links_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_big_query_links(request) @@ -76892,6 +77089,7 @@ def test_list_big_query_links_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_big_query_links(**mock_args) @@ -77087,6 +77285,7 @@ def test_delete_big_query_link_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_big_query_link(request) @@ -77130,6 +77329,7 @@ def test_delete_big_query_link_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_big_query_link(**mock_args) @@ -77263,6 +77463,7 @@ def test_update_big_query_link_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_big_query_link(request) @@ -77319,6 +77520,7 @@ def test_update_big_query_link_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_big_query_link(**mock_args) @@ -77456,6 +77658,7 @@ def test_get_enhanced_measurement_settings_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_enhanced_measurement_settings(request) @@ -77505,6 +77708,7 @@ def test_get_enhanced_measurement_settings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_enhanced_measurement_settings(**mock_args) @@ -77641,6 +77845,7 @@ def test_update_enhanced_measurement_settings_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_enhanced_measurement_settings(request) @@ -77703,6 +77908,7 @@ def test_update_enhanced_measurement_settings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_enhanced_measurement_settings(**mock_args) @@ -77842,6 +78048,7 @@ def test_create_connected_site_tag_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_connected_site_tag(request) @@ -78055,6 +78262,7 @@ def test_fetch_connected_ga4_property_rest_required_fields( response_value._content = json_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_connected_ga4_property(request) @@ -78182,6 +78390,7 @@ def test_get_ad_sense_link_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_ad_sense_link(request) @@ -78227,6 +78436,7 @@ def test_get_ad_sense_link_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_ad_sense_link(**mock_args) @@ -78362,6 +78572,7 @@ def test_create_ad_sense_link_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_ad_sense_link(request) @@ -78416,6 +78627,7 @@ def test_create_ad_sense_link_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_ad_sense_link(**mock_args) @@ -78548,6 +78760,7 @@ def test_delete_ad_sense_link_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_ad_sense_link(request) @@ -78591,6 +78804,7 @@ def test_delete_ad_sense_link_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_ad_sense_link(**mock_args) @@ -78732,6 +78946,7 @@ def test_list_ad_sense_links_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_ad_sense_links(request) @@ -78785,6 +79000,7 @@ def test_list_ad_sense_links_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_ad_sense_links(**mock_args) @@ -78983,6 +79199,7 @@ def test_get_event_create_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_event_create_rule(request) @@ -79030,6 +79247,7 @@ def test_get_event_create_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_event_create_rule(**mock_args) @@ -79173,6 +79391,7 @@ def test_list_event_create_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_event_create_rules(request) @@ -79226,6 +79445,7 @@ def test_list_event_create_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_event_create_rules(**mock_args) @@ -79428,6 +79648,7 @@ def test_create_event_create_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_event_create_rule(request) @@ -79482,6 +79703,7 @@ def test_create_event_create_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_event_create_rule(**mock_args) @@ -79617,6 +79839,7 @@ def test_update_event_create_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_event_create_rule(request) @@ -79675,6 +79898,7 @@ def test_update_event_create_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_event_create_rule(**mock_args) @@ -79809,6 +80033,7 @@ def test_delete_event_create_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_event_create_rule(request) @@ -79854,6 +80079,7 @@ def test_delete_event_create_rule_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_create_rule(**mock_args) @@ -79989,6 +80215,7 @@ def test_get_event_edit_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_event_edit_rule(request) @@ -80036,6 +80263,7 @@ def test_get_event_edit_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_event_edit_rule(**mock_args) @@ -80179,6 +80407,7 @@ def test_list_event_edit_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_event_edit_rules(request) @@ -80232,6 +80461,7 @@ def test_list_event_edit_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_event_edit_rules(**mock_args) @@ -80432,6 +80662,7 @@ def test_create_event_edit_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_event_edit_rule(request) @@ -80486,6 +80717,7 @@ def test_create_event_edit_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_event_edit_rule(**mock_args) @@ -80621,6 +80853,7 @@ def test_update_event_edit_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_event_edit_rule(request) @@ -80679,6 +80912,7 @@ def test_update_event_edit_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_event_edit_rule(**mock_args) @@ -80813,6 +81047,7 @@ def test_delete_event_edit_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_event_edit_rule(request) @@ -80858,6 +81093,7 @@ def test_delete_event_edit_rule_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_edit_rule(**mock_args) @@ -80996,6 +81232,7 @@ def test_reorder_event_edit_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.reorder_event_edit_rules(request) @@ -81126,6 +81363,7 @@ def test_update_data_redaction_settings_rest_required_fields( response_value._content = json_return_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_redaction_settings(request) @@ -81186,6 +81424,7 @@ def test_update_data_redaction_settings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_redaction_settings(**mock_args) @@ -81323,6 +81562,7 @@ def test_get_data_redaction_settings_rest_required_fields( response_value._content = json_return_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_redaction_settings(request) @@ -81370,6 +81610,7 @@ def test_get_data_redaction_settings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_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_redaction_settings(**mock_args) @@ -81506,6 +81747,7 @@ def test_get_calculated_metric_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_calculated_metric(request) @@ -81551,6 +81793,7 @@ def test_get_calculated_metric_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_calculated_metric(**mock_args) @@ -81699,6 +81942,7 @@ def test_create_calculated_metric_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_calculated_metric(request) @@ -81761,6 +82005,7 @@ def test_create_calculated_metric_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_calculated_metric(**mock_args) @@ -81908,6 +82153,7 @@ def test_list_calculated_metrics_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_calculated_metrics(request) @@ -81961,6 +82207,7 @@ def test_list_calculated_metrics_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_calculated_metrics(**mock_args) @@ -82158,6 +82405,7 @@ def test_update_calculated_metric_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_calculated_metric(request) @@ -82216,6 +82464,7 @@ def test_update_calculated_metric_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_calculated_metric(**mock_args) @@ -82350,6 +82599,7 @@ def test_delete_calculated_metric_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_calculated_metric(request) @@ -82393,6 +82643,7 @@ def test_delete_calculated_metric_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_calculated_metric(**mock_args) @@ -82525,6 +82776,7 @@ def test_create_rollup_property_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_rollup_property(request) @@ -82649,6 +82901,7 @@ def test_get_rollup_property_source_link_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_rollup_property_source_link(request) @@ -82698,6 +82951,7 @@ def test_get_rollup_property_source_link_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_rollup_property_source_link(**mock_args) @@ -82843,6 +83097,7 @@ def test_list_rollup_property_source_links_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_rollup_property_source_links(request) @@ -82900,6 +83155,7 @@ def test_list_rollup_property_source_links_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_rollup_property_source_links(**mock_args) @@ -83105,6 +83361,7 @@ def test_create_rollup_property_source_link_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_rollup_property_source_link(request) @@ -83163,6 +83420,7 @@ def test_create_rollup_property_source_link_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_rollup_property_source_link(**mock_args) @@ -83301,6 +83559,7 @@ def test_delete_rollup_property_source_link_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_rollup_property_source_link(request) @@ -83348,6 +83607,7 @@ def test_delete_rollup_property_source_link_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_rollup_property_source_link(**mock_args) @@ -83482,6 +83742,7 @@ def test_provision_subproperty_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.provision_subproperty(request) @@ -83609,6 +83870,7 @@ def test_create_subproperty_event_filter_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_subproperty_event_filter(request) @@ -83669,6 +83931,7 @@ def test_create_subproperty_event_filter_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_subproperty_event_filter(**mock_args) @@ -83810,6 +84073,7 @@ def test_get_subproperty_event_filter_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_subproperty_event_filter(request) @@ -83855,6 +84119,7 @@ def test_get_subproperty_event_filter_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_subproperty_event_filter(**mock_args) @@ -84000,6 +84265,7 @@ def test_list_subproperty_event_filters_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_subproperty_event_filters(request) @@ -84057,6 +84323,7 @@ def test_list_subproperty_event_filters_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_subproperty_event_filters(**mock_args) @@ -84262,6 +84529,7 @@ def test_update_subproperty_event_filter_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_subproperty_event_filter(request) @@ -84326,6 +84594,7 @@ def test_update_subproperty_event_filter_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_subproperty_event_filter(**mock_args) @@ -84462,6 +84731,7 @@ def test_delete_subproperty_event_filter_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_subproperty_event_filter(request) @@ -84507,6 +84777,7 @@ def test_delete_subproperty_event_filter_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_subproperty_event_filter(**mock_args) @@ -92618,6 +92889,7 @@ def test_get_account_rest_bad_request(request_type=analytics_admin.GetAccountReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_account(request) @@ -92657,6 +92929,7 @@ def test_get_account_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_account(request) # Establish that the response is the type that we expect. @@ -92701,6 +92974,7 @@ def test_get_account_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = resources.Account.to_json(resources.Account()) req.return_value.content = return_value @@ -92745,6 +93019,7 @@ def test_list_accounts_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_accounts(request) @@ -92780,6 +93055,7 @@ def test_list_accounts_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_accounts(request) # Establish that the response is the type that we expect. @@ -92820,6 +93096,7 @@ def test_list_accounts_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_admin.ListAccountsResponse.to_json( analytics_admin.ListAccountsResponse() ) @@ -92866,6 +93143,7 @@ def test_delete_account_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_account(request) @@ -92896,6 +93174,7 @@ def test_delete_account_rest_call_success(request_type): json_return_value = "" response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_account(request) # Establish that the response is the type that we expect. @@ -92932,6 +93211,7 @@ def test_delete_account_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = analytics_admin.DeleteAccountRequest() metadata = [ @@ -92972,6 +93252,7 @@ def test_update_account_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_account(request) @@ -93087,6 +93368,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_account(request) # Establish that the response is the type that we expect. @@ -93131,6 +93413,7 @@ def test_update_account_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = resources.Account.to_json(resources.Account()) req.return_value.content = return_value @@ -93175,6 +93458,7 @@ def test_provision_account_ticket_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.provision_account_ticket(request) @@ -93210,6 +93494,7 @@ def test_provision_account_ticket_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.provision_account_ticket(request) # Establish that the response is the type that we expect. @@ -93250,6 +93535,7 @@ def test_provision_account_ticket_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_admin.ProvisionAccountTicketResponse.to_json( analytics_admin.ProvisionAccountTicketResponse() ) @@ -93296,6 +93582,7 @@ def test_list_account_summaries_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_account_summaries(request) @@ -93331,6 +93618,7 @@ def test_list_account_summaries_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_account_summaries(request) # Establish that the response is the type that we expect. @@ -93371,6 +93659,7 @@ def test_list_account_summaries_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_admin.ListAccountSummariesResponse.to_json( analytics_admin.ListAccountSummariesResponse() ) @@ -93415,6 +93704,7 @@ def test_get_property_rest_bad_request(request_type=analytics_admin.GetPropertyR response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_property(request) @@ -93458,6 +93748,7 @@ def test_get_property_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_property(request) # Establish that the response is the type that we expect. @@ -93506,6 +93797,7 @@ def test_get_property_rest_interceptors(null_interceptor): req.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.Property.to_json(resources.Property()) req.return_value.content = return_value @@ -93550,6 +93842,7 @@ def test_list_properties_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_properties(request) @@ -93585,6 +93878,7 @@ def test_list_properties_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_properties(request) # Establish that the response is the type that we expect. @@ -93625,6 +93919,7 @@ def test_list_properties_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_admin.ListPropertiesResponse.to_json( analytics_admin.ListPropertiesResponse() ) @@ -93671,6 +93966,7 @@ def test_create_property_rest_bad_request( response_value.status_code = 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_property(request) @@ -93796,6 +94092,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_property(request) # Establish that the response is the type that we expect. @@ -93844,6 +94141,7 @@ def test_create_property_rest_interceptors(null_interceptor): req.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.Property.to_json(resources.Property()) req.return_value.content = return_value @@ -93888,6 +94186,7 @@ def test_delete_property_rest_bad_request( response_value.status_code = 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_property(request) @@ -93931,6 +94230,7 @@ def test_delete_property_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_property(request) # Establish that the response is the type that we expect. @@ -93979,6 +94279,7 @@ def test_delete_property_rest_interceptors(null_interceptor): req.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.Property.to_json(resources.Property()) req.return_value.content = return_value @@ -94023,6 +94324,7 @@ def test_update_property_rest_bad_request( response_value.status_code = 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_property(request) @@ -94148,6 +94450,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_property(request) # Establish that the response is the type that we expect. @@ -94196,6 +94499,7 @@ def test_update_property_rest_interceptors(null_interceptor): req.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.Property.to_json(resources.Property()) req.return_value.content = return_value @@ -94240,6 +94544,7 @@ def test_create_firebase_link_rest_bad_request( response_value.status_code = 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_firebase_link(request) @@ -94348,6 +94653,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_firebase_link(request) # Establish that the response is the type that we expect. @@ -94389,6 +94695,7 @@ def test_create_firebase_link_rest_interceptors(null_interceptor): req.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.FirebaseLink.to_json(resources.FirebaseLink()) req.return_value.content = return_value @@ -94433,6 +94740,7 @@ def test_delete_firebase_link_rest_bad_request( response_value.status_code = 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_firebase_link(request) @@ -94463,6 +94771,7 @@ def test_delete_firebase_link_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_firebase_link(request) # Establish that the response is the type that we expect. @@ -94499,6 +94808,7 @@ def test_delete_firebase_link_rest_interceptors(null_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 = analytics_admin.DeleteFirebaseLinkRequest() metadata = [ @@ -94539,6 +94849,7 @@ def test_list_firebase_links_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_firebase_links(request) @@ -94574,6 +94885,7 @@ def test_list_firebase_links_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_firebase_links(request) # Establish that the response is the type that we expect. @@ -94614,6 +94926,7 @@ def test_list_firebase_links_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_admin.ListFirebaseLinksResponse.to_json( analytics_admin.ListFirebaseLinksResponse() ) @@ -94660,6 +94973,7 @@ def test_get_global_site_tag_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_global_site_tag(request) @@ -94696,6 +95010,7 @@ def test_get_global_site_tag_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_global_site_tag(request) # Establish that the response is the type that we expect. @@ -94737,6 +95052,7 @@ def test_get_global_site_tag_rest_interceptors(null_interceptor): req.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.GlobalSiteTag.to_json(resources.GlobalSiteTag()) req.return_value.content = return_value @@ -94781,6 +95097,7 @@ def test_create_google_ads_link_rest_bad_request( response_value.status_code = 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_google_ads_link(request) @@ -94897,6 +95214,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_google_ads_link(request) # Establish that the response is the type that we expect. @@ -94940,6 +95258,7 @@ def test_create_google_ads_link_rest_interceptors(null_interceptor): req.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.GoogleAdsLink.to_json(resources.GoogleAdsLink()) req.return_value.content = return_value @@ -94986,6 +95305,7 @@ def test_update_google_ads_link_rest_bad_request( response_value.status_code = 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_google_ads_link(request) @@ -95104,6 +95424,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_google_ads_link(request) # Establish that the response is the type that we expect. @@ -95147,6 +95468,7 @@ def test_update_google_ads_link_rest_interceptors(null_interceptor): req.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.GoogleAdsLink.to_json(resources.GoogleAdsLink()) req.return_value.content = return_value @@ -95191,6 +95513,7 @@ def test_delete_google_ads_link_rest_bad_request( response_value.status_code = 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_google_ads_link(request) @@ -95221,6 +95544,7 @@ def test_delete_google_ads_link_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_google_ads_link(request) # Establish that the response is the type that we expect. @@ -95257,6 +95581,7 @@ def test_delete_google_ads_link_rest_interceptors(null_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 = analytics_admin.DeleteGoogleAdsLinkRequest() metadata = [ @@ -95297,6 +95622,7 @@ def test_list_google_ads_links_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_google_ads_links(request) @@ -95332,6 +95658,7 @@ def test_list_google_ads_links_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_google_ads_links(request) # Establish that the response is the type that we expect. @@ -95372,6 +95699,7 @@ def test_list_google_ads_links_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_admin.ListGoogleAdsLinksResponse.to_json( analytics_admin.ListGoogleAdsLinksResponse() ) @@ -95418,6 +95746,7 @@ def test_get_data_sharing_settings_rest_bad_request( response_value.status_code = 400 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_sharing_settings(request) @@ -95458,6 +95787,7 @@ def test_get_data_sharing_settings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_sharing_settings(request) # Establish that the response is the type that we expect. @@ -95504,6 +95834,7 @@ def test_get_data_sharing_settings_rest_interceptors(null_interceptor): req.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.DataSharingSettings.to_json( resources.DataSharingSettings() ) @@ -95552,6 +95883,7 @@ def test_get_measurement_protocol_secret_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_measurement_protocol_secret(request) @@ -95591,6 +95923,7 @@ def test_get_measurement_protocol_secret_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_measurement_protocol_secret(request) # Establish that the response is the type that we expect. @@ -95635,6 +95968,7 @@ def test_get_measurement_protocol_secret_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = resources.MeasurementProtocolSecret.to_json( resources.MeasurementProtocolSecret() ) @@ -95681,6 +96015,7 @@ def test_list_measurement_protocol_secrets_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_measurement_protocol_secrets(request) @@ -95718,6 +96053,7 @@ def test_list_measurement_protocol_secrets_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_measurement_protocol_secrets(request) # Establish that the response is the type that we expect. @@ -95760,6 +96096,7 @@ def test_list_measurement_protocol_secrets_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_admin.ListMeasurementProtocolSecretsResponse.to_json( analytics_admin.ListMeasurementProtocolSecretsResponse() ) @@ -95806,6 +96143,7 @@ def test_create_measurement_protocol_secret_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_measurement_protocol_secret(request) @@ -95921,6 +96259,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_measurement_protocol_secret(request) # Establish that the response is the type that we expect. @@ -95965,6 +96304,7 @@ def test_create_measurement_protocol_secret_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = resources.MeasurementProtocolSecret.to_json( resources.MeasurementProtocolSecret() ) @@ -96013,6 +96353,7 @@ def test_delete_measurement_protocol_secret_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_measurement_protocol_secret(request) @@ -96045,6 +96386,7 @@ def test_delete_measurement_protocol_secret_rest_call_success(request_type): json_return_value = "" response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_measurement_protocol_secret(request) # Establish that the response is the type that we expect. @@ -96082,6 +96424,7 @@ def test_delete_measurement_protocol_secret_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = analytics_admin.DeleteMeasurementProtocolSecretRequest() metadata = [ @@ -96126,6 +96469,7 @@ def test_update_measurement_protocol_secret_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_measurement_protocol_secret(request) @@ -96245,6 +96589,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_measurement_protocol_secret(request) # Establish that the response is the type that we expect. @@ -96289,6 +96634,7 @@ def test_update_measurement_protocol_secret_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = resources.MeasurementProtocolSecret.to_json( resources.MeasurementProtocolSecret() ) @@ -96335,6 +96681,7 @@ def test_acknowledge_user_data_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.acknowledge_user_data_collection(request) @@ -96370,6 +96717,7 @@ def test_acknowledge_user_data_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.acknowledge_user_data_collection(request) # Establish that the response is the type that we expect. @@ -96411,6 +96759,7 @@ def test_acknowledge_user_data_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 = analytics_admin.AcknowledgeUserDataCollectionResponse.to_json( analytics_admin.AcknowledgeUserDataCollectionResponse() ) @@ -96459,6 +96808,7 @@ def test_get_sk_ad_network_conversion_value_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.get_sk_ad_network_conversion_value_schema(request) @@ -96497,6 +96847,7 @@ def test_get_sk_ad_network_conversion_value_schema_rest_call_success(request_typ json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_sk_ad_network_conversion_value_schema(request) # Establish that the response is the type that we expect. @@ -96540,6 +96891,7 @@ def test_get_sk_ad_network_conversion_value_schema_rest_interceptors(null_interc req.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.SKAdNetworkConversionValueSchema.to_json( resources.SKAdNetworkConversionValueSchema() ) @@ -96586,6 +96938,7 @@ def test_create_sk_ad_network_conversion_value_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_sk_ad_network_conversion_value_schema(request) @@ -96725,6 +97078,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_sk_ad_network_conversion_value_schema(request) # Establish that the response is the type that we expect. @@ -96770,6 +97124,7 @@ def test_create_sk_ad_network_conversion_value_schema_rest_interceptors( req.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.SKAdNetworkConversionValueSchema.to_json( resources.SKAdNetworkConversionValueSchema() ) @@ -96818,6 +97173,7 @@ def test_delete_sk_ad_network_conversion_value_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_sk_ad_network_conversion_value_schema(request) @@ -96850,6 +97206,7 @@ def test_delete_sk_ad_network_conversion_value_schema_rest_call_success(request_ 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_sk_ad_network_conversion_value_schema(request) # Establish that the response is the type that we expect. @@ -96889,6 +97246,7 @@ def test_delete_sk_ad_network_conversion_value_schema_rest_interceptors( req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = analytics_admin.DeleteSKAdNetworkConversionValueSchemaRequest() metadata = [ @@ -96933,6 +97291,7 @@ def test_update_sk_ad_network_conversion_value_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_sk_ad_network_conversion_value_schema(request) @@ -97076,6 +97435,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_sk_ad_network_conversion_value_schema(request) # Establish that the response is the type that we expect. @@ -97121,6 +97481,7 @@ def test_update_sk_ad_network_conversion_value_schema_rest_interceptors( req.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.SKAdNetworkConversionValueSchema.to_json( resources.SKAdNetworkConversionValueSchema() ) @@ -97167,6 +97528,7 @@ def test_list_sk_ad_network_conversion_value_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_sk_ad_network_conversion_value_schemas(request) @@ -97204,6 +97566,7 @@ def test_list_sk_ad_network_conversion_value_schemas_rest_call_success(request_t json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_sk_ad_network_conversion_value_schemas(request) # Establish that the response is the type that we expect. @@ -97248,6 +97611,7 @@ def test_list_sk_ad_network_conversion_value_schemas_rest_interceptors( req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = ( analytics_admin.ListSKAdNetworkConversionValueSchemasResponse.to_json( analytics_admin.ListSKAdNetworkConversionValueSchemasResponse() @@ -97298,6 +97662,7 @@ def test_search_change_history_events_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.search_change_history_events(request) @@ -97335,6 +97700,7 @@ def test_search_change_history_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.search_change_history_events(request) # Establish that the response is the type that we expect. @@ -97377,6 +97743,7 @@ def test_search_change_history_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 = analytics_admin.SearchChangeHistoryEventsResponse.to_json( analytics_admin.SearchChangeHistoryEventsResponse() ) @@ -97423,6 +97790,7 @@ def test_get_google_signals_settings_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_google_signals_settings(request) @@ -97460,6 +97828,7 @@ def test_get_google_signals_settings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_google_signals_settings(request) # Establish that the response is the type that we expect. @@ -97507,6 +97876,7 @@ def test_get_google_signals_settings_rest_interceptors(null_interceptor): req.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.GoogleSignalsSettings.to_json( resources.GoogleSignalsSettings() ) @@ -97555,6 +97925,7 @@ def test_update_google_signals_settings_rest_bad_request( response_value.status_code = 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_google_signals_settings(request) @@ -97670,6 +98041,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_google_signals_settings(request) # Establish that the response is the type that we expect. @@ -97717,6 +98089,7 @@ def test_update_google_signals_settings_rest_interceptors(null_interceptor): req.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.GoogleSignalsSettings.to_json( resources.GoogleSignalsSettings() ) @@ -97763,6 +98136,7 @@ def test_create_conversion_event_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_conversion_event(request) @@ -97883,6 +98257,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_conversion_event(request) # Establish that the response is the type that we expect. @@ -97930,6 +98305,7 @@ def test_create_conversion_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.ConversionEvent.to_json(resources.ConversionEvent()) req.return_value.content = return_value @@ -97976,6 +98352,7 @@ def test_update_conversion_event_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_conversion_event(request) @@ -98098,6 +98475,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_conversion_event(request) # Establish that the response is the type that we expect. @@ -98145,6 +98523,7 @@ def test_update_conversion_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.ConversionEvent.to_json(resources.ConversionEvent()) req.return_value.content = return_value @@ -98189,6 +98568,7 @@ def test_get_conversion_event_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_conversion_event(request) @@ -98228,6 +98608,7 @@ def test_get_conversion_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_conversion_event(request) # Establish that the response is the type that we expect. @@ -98275,6 +98656,7 @@ def test_get_conversion_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.ConversionEvent.to_json(resources.ConversionEvent()) req.return_value.content = return_value @@ -98319,6 +98701,7 @@ def test_delete_conversion_event_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_conversion_event(request) @@ -98349,6 +98732,7 @@ def test_delete_conversion_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_conversion_event(request) # Establish that the response is the type that we expect. @@ -98385,6 +98769,7 @@ def test_delete_conversion_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 = analytics_admin.DeleteConversionEventRequest() metadata = [ @@ -98425,6 +98810,7 @@ def test_list_conversion_events_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_conversion_events(request) @@ -98460,6 +98846,7 @@ def test_list_conversion_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_conversion_events(request) # Establish that the response is the type that we expect. @@ -98500,6 +98887,7 @@ def test_list_conversion_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 = analytics_admin.ListConversionEventsResponse.to_json( analytics_admin.ListConversionEventsResponse() ) @@ -98546,6 +98934,7 @@ def test_create_key_event_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_key_event(request) @@ -98664,6 +99053,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_key_event(request) # Establish that the response is the type that we expect. @@ -98708,6 +99098,7 @@ def test_create_key_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.KeyEvent.to_json(resources.KeyEvent()) req.return_value.content = return_value @@ -98752,6 +99143,7 @@ def test_update_key_event_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_key_event(request) @@ -98870,6 +99262,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_key_event(request) # Establish that the response is the type that we expect. @@ -98914,6 +99307,7 @@ def test_update_key_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.KeyEvent.to_json(resources.KeyEvent()) req.return_value.content = return_value @@ -98958,6 +99352,7 @@ def test_get_key_event_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_key_event(request) @@ -98997,6 +99392,7 @@ def test_get_key_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_key_event(request) # Establish that the response is the type that we expect. @@ -99041,6 +99437,7 @@ def test_get_key_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.KeyEvent.to_json(resources.KeyEvent()) req.return_value.content = return_value @@ -99085,6 +99482,7 @@ def test_delete_key_event_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_key_event(request) @@ -99115,6 +99513,7 @@ def test_delete_key_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_key_event(request) # Establish that the response is the type that we expect. @@ -99151,6 +99550,7 @@ def test_delete_key_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 = analytics_admin.DeleteKeyEventRequest() metadata = [ @@ -99191,6 +99591,7 @@ def test_list_key_events_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_key_events(request) @@ -99226,6 +99627,7 @@ def test_list_key_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_key_events(request) # Establish that the response is the type that we expect. @@ -99266,6 +99668,7 @@ def test_list_key_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 = analytics_admin.ListKeyEventsResponse.to_json( analytics_admin.ListKeyEventsResponse() ) @@ -99312,6 +99715,7 @@ def test_get_display_video360_advertiser_link_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_display_video360_advertiser_link(request) @@ -99349,6 +99753,7 @@ def test_get_display_video360_advertiser_link_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_display_video360_advertiser_link(request) # Establish that the response is the type that we expect. @@ -99393,6 +99798,7 @@ def test_get_display_video360_advertiser_link_rest_interceptors(null_interceptor req.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.DisplayVideo360AdvertiserLink.to_json( resources.DisplayVideo360AdvertiserLink() ) @@ -99439,6 +99845,7 @@ def test_list_display_video360_advertiser_links_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_display_video360_advertiser_links(request) @@ -99476,6 +99883,7 @@ def test_list_display_video360_advertiser_links_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_display_video360_advertiser_links(request) # Establish that the response is the type that we expect. @@ -99518,6 +99926,7 @@ def test_list_display_video360_advertiser_links_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 = ( analytics_admin.ListDisplayVideo360AdvertiserLinksResponse.to_json( analytics_admin.ListDisplayVideo360AdvertiserLinksResponse() @@ -99566,6 +99975,7 @@ def test_create_display_video360_advertiser_link_rest_bad_request( response_value.status_code = 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_display_video360_advertiser_link(request) @@ -99686,6 +100096,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_display_video360_advertiser_link(request) # Establish that the response is the type that we expect. @@ -99730,6 +100141,7 @@ def test_create_display_video360_advertiser_link_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 = resources.DisplayVideo360AdvertiserLink.to_json( resources.DisplayVideo360AdvertiserLink() ) @@ -99776,6 +100188,7 @@ def test_delete_display_video360_advertiser_link_rest_bad_request( response_value.status_code = 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_display_video360_advertiser_link(request) @@ -99806,6 +100219,7 @@ def test_delete_display_video360_advertiser_link_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_display_video360_advertiser_link(request) # Establish that the response is the type that we expect. @@ -99843,6 +100257,7 @@ def test_delete_display_video360_advertiser_link_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"} request = analytics_admin.DeleteDisplayVideo360AdvertiserLinkRequest() metadata = [ @@ -99887,6 +100302,7 @@ def test_update_display_video360_advertiser_link_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_display_video360_advertiser_link(request) @@ -100011,6 +100427,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_display_video360_advertiser_link(request) # Establish that the response is the type that we expect. @@ -100055,6 +100472,7 @@ def test_update_display_video360_advertiser_link_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 = resources.DisplayVideo360AdvertiserLink.to_json( resources.DisplayVideo360AdvertiserLink() ) @@ -100103,6 +100521,7 @@ def test_get_display_video360_advertiser_link_proposal_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_display_video360_advertiser_link_proposal(request) @@ -100143,6 +100562,7 @@ def test_get_display_video360_advertiser_link_proposal_rest_call_success(request json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_display_video360_advertiser_link_proposal(request) # Establish that the response is the type that we expect. @@ -100190,6 +100610,7 @@ def test_get_display_video360_advertiser_link_proposal_rest_interceptors( req.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.DisplayVideo360AdvertiserLinkProposal.to_json( resources.DisplayVideo360AdvertiserLinkProposal() ) @@ -100236,6 +100657,7 @@ def test_list_display_video360_advertiser_link_proposals_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_display_video360_advertiser_link_proposals(request) @@ -100279,6 +100701,7 @@ def test_list_display_video360_advertiser_link_proposals_rest_call_success( json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_display_video360_advertiser_link_proposals(request) # Establish that the response is the type that we expect. @@ -100325,6 +100748,7 @@ def test_list_display_video360_advertiser_link_proposals_rest_interceptors( req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = ( analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse.to_json( analytics_admin.ListDisplayVideo360AdvertiserLinkProposalsResponse() @@ -100375,6 +100799,7 @@ def test_create_display_video360_advertiser_link_proposal_rest_bad_request( response_value.status_code = 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_display_video360_advertiser_link_proposal(request) @@ -100513,6 +100938,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_display_video360_advertiser_link_proposal(request) # Establish that the response is the type that we expect. @@ -100562,6 +100988,7 @@ def test_create_display_video360_advertiser_link_proposal_rest_interceptors( req.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.DisplayVideo360AdvertiserLinkProposal.to_json( resources.DisplayVideo360AdvertiserLinkProposal() ) @@ -100610,6 +101037,7 @@ def test_delete_display_video360_advertiser_link_proposal_rest_bad_request( response_value.status_code = 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_display_video360_advertiser_link_proposal(request) @@ -100644,6 +101072,7 @@ def test_delete_display_video360_advertiser_link_proposal_rest_call_success( 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_display_video360_advertiser_link_proposal(request) # Establish that the response is the type that we expect. @@ -100685,6 +101114,7 @@ def test_delete_display_video360_advertiser_link_proposal_rest_interceptors( req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = analytics_admin.DeleteDisplayVideo360AdvertiserLinkProposalRequest() metadata = [ @@ -100727,6 +101157,7 @@ def test_approve_display_video360_advertiser_link_proposal_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.approve_display_video360_advertiser_link_proposal(request) @@ -100770,6 +101201,7 @@ def test_approve_display_video360_advertiser_link_proposal_rest_call_success( json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.approve_display_video360_advertiser_link_proposal(request) # Establish that the response is the type that we expect. @@ -100817,6 +101249,7 @@ def test_approve_display_video360_advertiser_link_proposal_rest_interceptors( req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalResponse.to_json( analytics_admin.ApproveDisplayVideo360AdvertiserLinkProposalResponse() ) @@ -100867,6 +101300,7 @@ def test_cancel_display_video360_advertiser_link_proposal_rest_bad_request( response_value.status_code = 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_display_video360_advertiser_link_proposal(request) @@ -100909,6 +101343,7 @@ def test_cancel_display_video360_advertiser_link_proposal_rest_call_success( json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_display_video360_advertiser_link_proposal(request) # Establish that the response is the type that we expect. @@ -100958,6 +101393,7 @@ def test_cancel_display_video360_advertiser_link_proposal_rest_interceptors( req.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.DisplayVideo360AdvertiserLinkProposal.to_json( resources.DisplayVideo360AdvertiserLinkProposal() ) @@ -101004,6 +101440,7 @@ def test_create_custom_dimension_rest_bad_request( response_value.status_code = 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_custom_dimension(request) @@ -101121,6 +101558,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_custom_dimension(request) # Establish that the response is the type that we expect. @@ -101166,6 +101604,7 @@ def test_create_custom_dimension_rest_interceptors(null_interceptor): req.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.CustomDimension.to_json(resources.CustomDimension()) req.return_value.content = return_value @@ -101212,6 +101651,7 @@ def test_update_custom_dimension_rest_bad_request( response_value.status_code = 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_custom_dimension(request) @@ -101331,6 +101771,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_custom_dimension(request) # Establish that the response is the type that we expect. @@ -101376,6 +101817,7 @@ def test_update_custom_dimension_rest_interceptors(null_interceptor): req.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.CustomDimension.to_json(resources.CustomDimension()) req.return_value.content = return_value @@ -101420,6 +101862,7 @@ def test_list_custom_dimensions_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_custom_dimensions(request) @@ -101455,6 +101898,7 @@ def test_list_custom_dimensions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_custom_dimensions(request) # Establish that the response is the type that we expect. @@ -101495,6 +101939,7 @@ def test_list_custom_dimensions_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_admin.ListCustomDimensionsResponse.to_json( analytics_admin.ListCustomDimensionsResponse() ) @@ -101541,6 +101986,7 @@ def test_archive_custom_dimension_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.archive_custom_dimension(request) @@ -101571,6 +102017,7 @@ def test_archive_custom_dimension_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.archive_custom_dimension(request) # Establish that the response is the type that we expect. @@ -101607,6 +102054,7 @@ def test_archive_custom_dimension_rest_interceptors(null_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 = analytics_admin.ArchiveCustomDimensionRequest() metadata = [ @@ -101647,6 +102095,7 @@ def test_get_custom_dimension_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_custom_dimension(request) @@ -101687,6 +102136,7 @@ def test_get_custom_dimension_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_custom_dimension(request) # Establish that the response is the type that we expect. @@ -101732,6 +102182,7 @@ def test_get_custom_dimension_rest_interceptors(null_interceptor): req.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.CustomDimension.to_json(resources.CustomDimension()) req.return_value.content = return_value @@ -101776,6 +102227,7 @@ def test_create_custom_metric_rest_bad_request( response_value.status_code = 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_custom_metric(request) @@ -101895,6 +102347,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_custom_metric(request) # Establish that the response is the type that we expect. @@ -101943,6 +102396,7 @@ def test_create_custom_metric_rest_interceptors(null_interceptor): req.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.CustomMetric.to_json(resources.CustomMetric()) req.return_value.content = return_value @@ -101989,6 +102443,7 @@ def test_update_custom_metric_rest_bad_request( response_value.status_code = 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_custom_metric(request) @@ -102110,6 +102565,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_custom_metric(request) # Establish that the response is the type that we expect. @@ -102158,6 +102614,7 @@ def test_update_custom_metric_rest_interceptors(null_interceptor): req.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.CustomMetric.to_json(resources.CustomMetric()) req.return_value.content = return_value @@ -102202,6 +102659,7 @@ def test_list_custom_metrics_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_custom_metrics(request) @@ -102237,6 +102695,7 @@ def test_list_custom_metrics_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_custom_metrics(request) # Establish that the response is the type that we expect. @@ -102277,6 +102736,7 @@ def test_list_custom_metrics_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_admin.ListCustomMetricsResponse.to_json( analytics_admin.ListCustomMetricsResponse() ) @@ -102323,6 +102783,7 @@ def test_archive_custom_metric_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.archive_custom_metric(request) @@ -102353,6 +102814,7 @@ def test_archive_custom_metric_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.archive_custom_metric(request) # Establish that the response is the type that we expect. @@ -102389,6 +102851,7 @@ def test_archive_custom_metric_rest_interceptors(null_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 = analytics_admin.ArchiveCustomMetricRequest() metadata = [ @@ -102429,6 +102892,7 @@ def test_get_custom_metric_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_custom_metric(request) @@ -102472,6 +102936,7 @@ def test_get_custom_metric_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_custom_metric(request) # Establish that the response is the type that we expect. @@ -102520,6 +102985,7 @@ def test_get_custom_metric_rest_interceptors(null_interceptor): req.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.CustomMetric.to_json(resources.CustomMetric()) req.return_value.content = return_value @@ -102564,6 +103030,7 @@ def test_get_data_retention_settings_rest_bad_request( response_value.status_code = 400 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_retention_settings(request) @@ -102601,6 +103068,7 @@ def test_get_data_retention_settings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_retention_settings(request) # Establish that the response is the type that we expect. @@ -102648,6 +103116,7 @@ def test_get_data_retention_settings_rest_interceptors(null_interceptor): req.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.DataRetentionSettings.to_json( resources.DataRetentionSettings() ) @@ -102696,6 +103165,7 @@ def test_update_data_retention_settings_rest_bad_request( response_value.status_code = 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_retention_settings(request) @@ -102811,6 +103281,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_retention_settings(request) # Establish that the response is the type that we expect. @@ -102858,6 +103329,7 @@ def test_update_data_retention_settings_rest_interceptors(null_interceptor): req.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.DataRetentionSettings.to_json( resources.DataRetentionSettings() ) @@ -102904,6 +103376,7 @@ def test_create_data_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_data_stream(request) @@ -103028,6 +103501,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_stream(request) # Establish that the response is the type that we expect. @@ -103070,6 +103544,7 @@ def test_create_data_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 = resources.DataStream.to_json(resources.DataStream()) req.return_value.content = return_value @@ -103114,6 +103589,7 @@ def test_delete_data_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_data_stream(request) @@ -103144,6 +103620,7 @@ def test_delete_data_stream_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_stream(request) # Establish that the response is the type that we expect. @@ -103180,6 +103657,7 @@ def test_delete_data_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"} request = analytics_admin.DeleteDataStreamRequest() metadata = [ @@ -103220,6 +103698,7 @@ def test_update_data_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_data_stream(request) @@ -103344,6 +103823,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_stream(request) # Establish that the response is the type that we expect. @@ -103386,6 +103866,7 @@ def test_update_data_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 = resources.DataStream.to_json(resources.DataStream()) req.return_value.content = return_value @@ -103430,6 +103911,7 @@ def test_list_data_streams_rest_bad_request( response_value.status_code = 400 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_streams(request) @@ -103465,6 +103947,7 @@ def test_list_data_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_data_streams(request) # Establish that the response is the type that we expect. @@ -103505,6 +103988,7 @@ def test_list_data_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 = analytics_admin.ListDataStreamsResponse.to_json( analytics_admin.ListDataStreamsResponse() ) @@ -103551,6 +104035,7 @@ def test_get_data_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.get_data_stream(request) @@ -103588,6 +104073,7 @@ def test_get_data_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_data_stream(request) # Establish that the response is the type that we expect. @@ -103630,6 +104116,7 @@ def test_get_data_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 = resources.DataStream.to_json(resources.DataStream()) req.return_value.content = return_value @@ -103672,6 +104159,7 @@ def test_get_audience_rest_bad_request(request_type=analytics_admin.GetAudienceR response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_audience(request) @@ -103712,6 +104200,7 @@ def test_get_audience_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_audience(request) # Establish that the response is the type that we expect. @@ -103760,6 +104249,7 @@ def test_get_audience_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = audience.Audience.to_json(audience.Audience()) req.return_value.content = return_value @@ -103804,6 +104294,7 @@ def test_list_audiences_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_audiences(request) @@ -103839,6 +104330,7 @@ def test_list_audiences_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_audiences(request) # Establish that the response is the type that we expect. @@ -103879,6 +104371,7 @@ def test_list_audiences_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_admin.ListAudiencesResponse.to_json( analytics_admin.ListAudiencesResponse() ) @@ -103925,6 +104418,7 @@ def test_create_audience_rest_bad_request( response_value.status_code = 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_audience(request) @@ -104093,6 +104587,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_audience(request) # Establish that the response is the type that we expect. @@ -104141,6 +104636,7 @@ def test_create_audience_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = gaa_audience.Audience.to_json(gaa_audience.Audience()) req.return_value.content = return_value @@ -104185,6 +104681,7 @@ def test_update_audience_rest_bad_request( response_value.status_code = 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_audience(request) @@ -104353,6 +104850,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_audience(request) # Establish that the response is the type that we expect. @@ -104401,6 +104899,7 @@ def test_update_audience_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = gaa_audience.Audience.to_json(gaa_audience.Audience()) req.return_value.content = return_value @@ -104445,6 +104944,7 @@ def test_archive_audience_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.archive_audience(request) @@ -104475,6 +104975,7 @@ def test_archive_audience_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.archive_audience(request) # Establish that the response is the type that we expect. @@ -104511,6 +105012,7 @@ def test_archive_audience_rest_interceptors(null_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 = analytics_admin.ArchiveAudienceRequest() metadata = [ @@ -104551,6 +105053,7 @@ def test_get_search_ads360_link_rest_bad_request( response_value.status_code = 400 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_ads360_link(request) @@ -104588,6 +105091,7 @@ def test_get_search_ads360_link_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_ads360_link(request) # Establish that the response is the type that we expect. @@ -104630,6 +105134,7 @@ def test_get_search_ads360_link_rest_interceptors(null_interceptor): req.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.SearchAds360Link.to_json(resources.SearchAds360Link()) req.return_value.content = return_value @@ -104674,6 +105179,7 @@ def test_list_search_ads360_links_rest_bad_request( response_value.status_code = 400 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_ads360_links(request) @@ -104709,6 +105215,7 @@ def test_list_search_ads360_links_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_ads360_links(request) # Establish that the response is the type that we expect. @@ -104749,6 +105256,7 @@ def test_list_search_ads360_links_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_admin.ListSearchAds360LinksResponse.to_json( analytics_admin.ListSearchAds360LinksResponse() ) @@ -104795,6 +105303,7 @@ def test_create_search_ads360_link_rest_bad_request( response_value.status_code = 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_ads360_link(request) @@ -104910,6 +105419,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_ads360_link(request) # Establish that the response is the type that we expect. @@ -104953,6 +105463,7 @@ def test_create_search_ads360_link_rest_interceptors(null_interceptor): req.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.SearchAds360Link.to_json(resources.SearchAds360Link()) req.return_value.content = return_value @@ -104997,6 +105508,7 @@ def test_delete_search_ads360_link_rest_bad_request( response_value.status_code = 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_ads360_link(request) @@ -105027,6 +105539,7 @@ def test_delete_search_ads360_link_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_ads360_link(request) # Establish that the response is the type that we expect. @@ -105063,6 +105576,7 @@ def test_delete_search_ads360_link_rest_interceptors(null_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 = analytics_admin.DeleteSearchAds360LinkRequest() metadata = [ @@ -105105,6 +105619,7 @@ def test_update_search_ads360_link_rest_bad_request( response_value.status_code = 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_ads360_link(request) @@ -105222,6 +105737,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_ads360_link(request) # Establish that the response is the type that we expect. @@ -105265,6 +105781,7 @@ def test_update_search_ads360_link_rest_interceptors(null_interceptor): req.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.SearchAds360Link.to_json(resources.SearchAds360Link()) req.return_value.content = return_value @@ -105309,6 +105826,7 @@ def test_get_attribution_settings_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_attribution_settings(request) @@ -105348,6 +105866,7 @@ def test_get_attribution_settings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_attribution_settings(request) # Establish that the response is the type that we expect. @@ -105404,6 +105923,7 @@ def test_get_attribution_settings_rest_interceptors(null_interceptor): req.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.AttributionSettings.to_json( resources.AttributionSettings() ) @@ -105452,6 +105972,7 @@ def test_update_attribution_settings_rest_bad_request( response_value.status_code = 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_attribution_settings(request) @@ -105571,6 +106092,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_attribution_settings(request) # Establish that the response is the type that we expect. @@ -105629,6 +106151,7 @@ def test_update_attribution_settings_rest_interceptors(null_interceptor): req.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.AttributionSettings.to_json( resources.AttributionSettings() ) @@ -105675,6 +106198,7 @@ def test_run_access_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.run_access_report(request) @@ -105710,6 +106234,7 @@ def test_run_access_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.run_access_report(request) # Establish that the response is the type that we expect. @@ -105750,6 +106275,7 @@ def test_run_access_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 = analytics_admin.RunAccessReportResponse.to_json( analytics_admin.RunAccessReportResponse() ) @@ -105796,6 +106322,7 @@ def test_create_access_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_access_binding(request) @@ -105907,6 +106434,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_access_binding(request) # Establish that the response is the type that we expect. @@ -105948,6 +106476,7 @@ def test_create_access_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 = resources.AccessBinding.to_json(resources.AccessBinding()) req.return_value.content = return_value @@ -105992,6 +106521,7 @@ def test_get_access_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_access_binding(request) @@ -106029,6 +106559,7 @@ def test_get_access_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_access_binding(request) # Establish that the response is the type that we expect. @@ -106070,6 +106601,7 @@ def test_get_access_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 = resources.AccessBinding.to_json(resources.AccessBinding()) req.return_value.content = return_value @@ -106116,6 +106648,7 @@ def test_update_access_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_access_binding(request) @@ -106229,6 +106762,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_access_binding(request) # Establish that the response is the type that we expect. @@ -106270,6 +106804,7 @@ def test_update_access_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 = resources.AccessBinding.to_json(resources.AccessBinding()) req.return_value.content = return_value @@ -106314,6 +106849,7 @@ def test_delete_access_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_access_binding(request) @@ -106344,6 +106880,7 @@ def test_delete_access_binding_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_access_binding(request) # Establish that the response is the type that we expect. @@ -106380,6 +106917,7 @@ def test_delete_access_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"} request = analytics_admin.DeleteAccessBindingRequest() metadata = [ @@ -106420,6 +106958,7 @@ def test_list_access_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_access_bindings(request) @@ -106455,6 +106994,7 @@ def test_list_access_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_access_bindings(request) # Establish that the response is the type that we expect. @@ -106495,6 +107035,7 @@ def test_list_access_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 = analytics_admin.ListAccessBindingsResponse.to_json( analytics_admin.ListAccessBindingsResponse() ) @@ -106541,6 +107082,7 @@ def test_batch_create_access_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.batch_create_access_bindings(request) @@ -106576,6 +107118,7 @@ def test_batch_create_access_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.batch_create_access_bindings(request) # Establish that the response is the type that we expect. @@ -106617,6 +107160,7 @@ def test_batch_create_access_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 = analytics_admin.BatchCreateAccessBindingsResponse.to_json( analytics_admin.BatchCreateAccessBindingsResponse() ) @@ -106663,6 +107207,7 @@ def test_batch_get_access_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.batch_get_access_bindings(request) @@ -106696,6 +107241,7 @@ def test_batch_get_access_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.batch_get_access_bindings(request) # Establish that the response is the type that we expect. @@ -106736,6 +107282,7 @@ def test_batch_get_access_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 = analytics_admin.BatchGetAccessBindingsResponse.to_json( analytics_admin.BatchGetAccessBindingsResponse() ) @@ -106782,6 +107329,7 @@ def test_batch_update_access_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.batch_update_access_bindings(request) @@ -106817,6 +107365,7 @@ def test_batch_update_access_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.batch_update_access_bindings(request) # Establish that the response is the type that we expect. @@ -106858,6 +107407,7 @@ def test_batch_update_access_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 = analytics_admin.BatchUpdateAccessBindingsResponse.to_json( analytics_admin.BatchUpdateAccessBindingsResponse() ) @@ -106904,6 +107454,7 @@ def test_batch_delete_access_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.batch_delete_access_bindings(request) @@ -106934,6 +107485,7 @@ def test_batch_delete_access_bindings_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_delete_access_bindings(request) # Establish that the response is the type that we expect. @@ -106971,6 +107523,7 @@ def test_batch_delete_access_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"} request = analytics_admin.BatchDeleteAccessBindingsRequest() metadata = [ @@ -107011,6 +107564,7 @@ def test_get_expanded_data_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_expanded_data_set(request) @@ -107050,6 +107604,7 @@ def test_get_expanded_data_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_expanded_data_set(request) # Establish that the response is the type that we expect. @@ -107094,6 +107649,7 @@ def test_get_expanded_data_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 = expanded_data_set.ExpandedDataSet.to_json( expanded_data_set.ExpandedDataSet() ) @@ -107140,6 +107696,7 @@ def test_list_expanded_data_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_expanded_data_sets(request) @@ -107175,6 +107732,7 @@ def test_list_expanded_data_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_expanded_data_sets(request) # Establish that the response is the type that we expect. @@ -107215,6 +107773,7 @@ def test_list_expanded_data_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 = analytics_admin.ListExpandedDataSetsResponse.to_json( analytics_admin.ListExpandedDataSetsResponse() ) @@ -107261,6 +107820,7 @@ def test_create_expanded_data_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_expanded_data_set(request) @@ -107393,6 +107953,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_expanded_data_set(request) # Establish that the response is the type that we expect. @@ -107437,6 +107998,7 @@ def test_create_expanded_data_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 = gaa_expanded_data_set.ExpandedDataSet.to_json( gaa_expanded_data_set.ExpandedDataSet() ) @@ -107485,6 +108047,7 @@ def test_update_expanded_data_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_expanded_data_set(request) @@ -107619,6 +108182,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_expanded_data_set(request) # Establish that the response is the type that we expect. @@ -107663,6 +108227,7 @@ def test_update_expanded_data_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 = gaa_expanded_data_set.ExpandedDataSet.to_json( gaa_expanded_data_set.ExpandedDataSet() ) @@ -107709,6 +108274,7 @@ def test_delete_expanded_data_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_expanded_data_set(request) @@ -107739,6 +108305,7 @@ def test_delete_expanded_data_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_expanded_data_set(request) # Establish that the response is the type that we expect. @@ -107775,6 +108342,7 @@ def test_delete_expanded_data_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 = analytics_admin.DeleteExpandedDataSetRequest() metadata = [ @@ -107815,6 +108383,7 @@ def test_get_channel_group_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_channel_group(request) @@ -107854,6 +108423,7 @@ def test_get_channel_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_channel_group(request) # Establish that the response is the type that we expect. @@ -107898,6 +108468,7 @@ def test_get_channel_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 = channel_group.ChannelGroup.to_json(channel_group.ChannelGroup()) req.return_value.content = return_value @@ -107942,6 +108513,7 @@ def test_list_channel_groups_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_channel_groups(request) @@ -107977,6 +108549,7 @@ def test_list_channel_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_channel_groups(request) # Establish that the response is the type that we expect. @@ -108017,6 +108590,7 @@ def test_list_channel_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 = analytics_admin.ListChannelGroupsResponse.to_json( analytics_admin.ListChannelGroupsResponse() ) @@ -108063,6 +108637,7 @@ def test_create_channel_group_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_channel_group(request) @@ -108193,6 +108768,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_group(request) # Establish that the response is the type that we expect. @@ -108237,6 +108813,7 @@ def test_create_channel_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 = gaa_channel_group.ChannelGroup.to_json( gaa_channel_group.ChannelGroup() ) @@ -108285,6 +108862,7 @@ def test_update_channel_group_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_channel_group(request) @@ -108417,6 +108995,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_group(request) # Establish that the response is the type that we expect. @@ -108461,6 +109040,7 @@ def test_update_channel_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 = gaa_channel_group.ChannelGroup.to_json( gaa_channel_group.ChannelGroup() ) @@ -108507,6 +109087,7 @@ def test_delete_channel_group_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_channel_group(request) @@ -108537,6 +109118,7 @@ def test_delete_channel_group_rest_call_success(request_type): json_return_value = "" response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_channel_group(request) # Establish that the response is the type that we expect. @@ -108573,6 +109155,7 @@ def test_delete_channel_group_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = analytics_admin.DeleteChannelGroupRequest() metadata = [ @@ -108613,6 +109196,7 @@ def test_set_automated_ga4_configuration_opt_out_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.set_automated_ga4_configuration_opt_out(request) @@ -108648,6 +109232,7 @@ def test_set_automated_ga4_configuration_opt_out_rest_call_success(request_type) json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.set_automated_ga4_configuration_opt_out(request) # Establish that the response is the type that we expect. @@ -108691,6 +109276,7 @@ def test_set_automated_ga4_configuration_opt_out_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 = ( analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse.to_json( analytics_admin.SetAutomatedGa4ConfigurationOptOutResponse() @@ -108739,6 +109325,7 @@ def test_fetch_automated_ga4_configuration_opt_out_rest_bad_request( response_value.status_code = 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_automated_ga4_configuration_opt_out(request) @@ -108776,6 +109363,7 @@ def test_fetch_automated_ga4_configuration_opt_out_rest_call_success(request_typ json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_automated_ga4_configuration_opt_out(request) # Establish that the response is the type that we expect. @@ -108820,6 +109408,7 @@ def test_fetch_automated_ga4_configuration_opt_out_rest_interceptors(null_interc req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = ( analytics_admin.FetchAutomatedGa4ConfigurationOptOutResponse.to_json( analytics_admin.FetchAutomatedGa4ConfigurationOptOutResponse() @@ -108870,6 +109459,7 @@ def test_create_big_query_link_rest_bad_request( response_value.status_code = 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_big_query_link(request) @@ -108992,6 +109582,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_big_query_link(request) # Establish that the response is the type that we expect. @@ -109040,6 +109631,7 @@ def test_create_big_query_link_rest_interceptors(null_interceptor): req.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.BigQueryLink.to_json(resources.BigQueryLink()) req.return_value.content = return_value @@ -109084,6 +109676,7 @@ def test_get_big_query_link_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_big_query_link(request) @@ -109127,6 +109720,7 @@ def test_get_big_query_link_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_big_query_link(request) # Establish that the response is the type that we expect. @@ -109175,6 +109769,7 @@ def test_get_big_query_link_rest_interceptors(null_interceptor): req.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.BigQueryLink.to_json(resources.BigQueryLink()) req.return_value.content = return_value @@ -109219,6 +109814,7 @@ def test_list_big_query_links_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_big_query_links(request) @@ -109254,6 +109850,7 @@ def test_list_big_query_links_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_big_query_links(request) # Establish that the response is the type that we expect. @@ -109294,6 +109891,7 @@ def test_list_big_query_links_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_admin.ListBigQueryLinksResponse.to_json( analytics_admin.ListBigQueryLinksResponse() ) @@ -109340,6 +109938,7 @@ def test_delete_big_query_link_rest_bad_request( response_value.status_code = 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_big_query_link(request) @@ -109370,6 +109969,7 @@ def test_delete_big_query_link_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_big_query_link(request) # Establish that the response is the type that we expect. @@ -109406,6 +110006,7 @@ def test_delete_big_query_link_rest_interceptors(null_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 = analytics_admin.DeleteBigQueryLinkRequest() metadata = [ @@ -109448,6 +110049,7 @@ def test_update_big_query_link_rest_bad_request( response_value.status_code = 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_big_query_link(request) @@ -109572,6 +110174,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_big_query_link(request) # Establish that the response is the type that we expect. @@ -109620,6 +110223,7 @@ def test_update_big_query_link_rest_interceptors(null_interceptor): req.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.BigQueryLink.to_json(resources.BigQueryLink()) req.return_value.content = return_value @@ -109666,6 +110270,7 @@ def test_get_enhanced_measurement_settings_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_enhanced_measurement_settings(request) @@ -109713,6 +110318,7 @@ def test_get_enhanced_measurement_settings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_enhanced_measurement_settings(request) # Establish that the response is the type that we expect. @@ -109765,6 +110371,7 @@ def test_get_enhanced_measurement_settings_rest_interceptors(null_interceptor): req.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.EnhancedMeasurementSettings.to_json( resources.EnhancedMeasurementSettings() ) @@ -109815,6 +110422,7 @@ def test_update_enhanced_measurement_settings_rest_bad_request( response_value.status_code = 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_enhanced_measurement_settings(request) @@ -109952,6 +110560,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_enhanced_measurement_settings(request) # Establish that the response is the type that we expect. @@ -110004,6 +110613,7 @@ def test_update_enhanced_measurement_settings_rest_interceptors(null_interceptor req.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.EnhancedMeasurementSettings.to_json( resources.EnhancedMeasurementSettings() ) @@ -110050,6 +110660,7 @@ def test_create_connected_site_tag_rest_bad_request( response_value.status_code = 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_connected_site_tag(request) @@ -110083,6 +110694,7 @@ def test_create_connected_site_tag_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_connected_site_tag(request) # Establish that the response is the type that we expect. @@ -110123,6 +110735,7 @@ def test_create_connected_site_tag_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_admin.CreateConnectedSiteTagResponse.to_json( analytics_admin.CreateConnectedSiteTagResponse() ) @@ -110169,6 +110782,7 @@ def test_delete_connected_site_tag_rest_bad_request( response_value.status_code = 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_connected_site_tag(request) @@ -110199,6 +110813,7 @@ def test_delete_connected_site_tag_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_connected_site_tag(request) # Establish that the response is the type that we expect. @@ -110235,6 +110850,7 @@ def test_delete_connected_site_tag_rest_interceptors(null_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 = analytics_admin.DeleteConnectedSiteTagRequest() metadata = [ @@ -110275,6 +110891,7 @@ def test_list_connected_site_tags_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_connected_site_tags(request) @@ -110308,6 +110925,7 @@ def test_list_connected_site_tags_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_connected_site_tags(request) # Establish that the response is the type that we expect. @@ -110347,6 +110965,7 @@ def test_list_connected_site_tags_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_admin.ListConnectedSiteTagsResponse.to_json( analytics_admin.ListConnectedSiteTagsResponse() ) @@ -110393,6 +111012,7 @@ def test_fetch_connected_ga4_property_rest_bad_request( response_value.status_code = 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_connected_ga4_property(request) @@ -110430,6 +111050,7 @@ def test_fetch_connected_ga4_property_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_connected_ga4_property(request) # Establish that the response is the type that we expect. @@ -110472,6 +111093,7 @@ def test_fetch_connected_ga4_property_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_admin.FetchConnectedGa4PropertyResponse.to_json( analytics_admin.FetchConnectedGa4PropertyResponse() ) @@ -110518,6 +111140,7 @@ def test_get_ad_sense_link_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_ad_sense_link(request) @@ -110554,6 +111177,7 @@ def test_get_ad_sense_link_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_ad_sense_link(request) # Establish that the response is the type that we expect. @@ -110595,6 +111219,7 @@ def test_get_ad_sense_link_rest_interceptors(null_interceptor): req.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.AdSenseLink.to_json(resources.AdSenseLink()) req.return_value.content = return_value @@ -110639,6 +111264,7 @@ def test_create_ad_sense_link_rest_bad_request( response_value.status_code = 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_ad_sense_link(request) @@ -110746,6 +111372,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_ad_sense_link(request) # Establish that the response is the type that we expect. @@ -110787,6 +111414,7 @@ def test_create_ad_sense_link_rest_interceptors(null_interceptor): req.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.AdSenseLink.to_json(resources.AdSenseLink()) req.return_value.content = return_value @@ -110831,6 +111459,7 @@ def test_delete_ad_sense_link_rest_bad_request( response_value.status_code = 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_ad_sense_link(request) @@ -110861,6 +111490,7 @@ def test_delete_ad_sense_link_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_ad_sense_link(request) # Establish that the response is the type that we expect. @@ -110897,6 +111527,7 @@ def test_delete_ad_sense_link_rest_interceptors(null_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 = analytics_admin.DeleteAdSenseLinkRequest() metadata = [ @@ -110937,6 +111568,7 @@ def test_list_ad_sense_links_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_ad_sense_links(request) @@ -110972,6 +111604,7 @@ def test_list_ad_sense_links_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_ad_sense_links(request) # Establish that the response is the type that we expect. @@ -111012,6 +111645,7 @@ def test_list_ad_sense_links_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_admin.ListAdSenseLinksResponse.to_json( analytics_admin.ListAdSenseLinksResponse() ) @@ -111060,6 +111694,7 @@ def test_get_event_create_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_event_create_rule(request) @@ -111099,6 +111734,7 @@ def test_get_event_create_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_event_create_rule(request) # Establish that the response is the type that we expect. @@ -111141,6 +111777,7 @@ def test_get_event_create_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 = event_create_and_edit.EventCreateRule.to_json( event_create_and_edit.EventCreateRule() ) @@ -111187,6 +111824,7 @@ def test_list_event_create_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_event_create_rules(request) @@ -111222,6 +111860,7 @@ def test_list_event_create_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_event_create_rules(request) # Establish that the response is the type that we expect. @@ -111262,6 +111901,7 @@ def test_list_event_create_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 = analytics_admin.ListEventCreateRulesResponse.to_json( analytics_admin.ListEventCreateRulesResponse() ) @@ -111308,6 +111948,7 @@ def test_create_event_create_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_event_create_rule(request) @@ -111430,6 +112071,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_create_rule(request) # Establish that the response is the type that we expect. @@ -111472,6 +112114,7 @@ def test_create_event_create_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 = event_create_and_edit.EventCreateRule.to_json( event_create_and_edit.EventCreateRule() ) @@ -111522,6 +112165,7 @@ def test_update_event_create_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_event_create_rule(request) @@ -111648,6 +112292,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_create_rule(request) # Establish that the response is the type that we expect. @@ -111690,6 +112335,7 @@ def test_update_event_create_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 = event_create_and_edit.EventCreateRule.to_json( event_create_and_edit.EventCreateRule() ) @@ -111738,6 +112384,7 @@ def test_delete_event_create_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_event_create_rule(request) @@ -111770,6 +112417,7 @@ def test_delete_event_create_rule_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_create_rule(request) # Establish that the response is the type that we expect. @@ -111806,6 +112454,7 @@ def test_delete_event_create_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"} request = analytics_admin.DeleteEventCreateRuleRequest() metadata = [ @@ -111848,6 +112497,7 @@ def test_get_event_edit_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_event_edit_rule(request) @@ -111887,6 +112537,7 @@ def test_get_event_edit_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_event_edit_rule(request) # Establish that the response is the type that we expect. @@ -111929,6 +112580,7 @@ def test_get_event_edit_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 = event_create_and_edit.EventEditRule.to_json( event_create_and_edit.EventEditRule() ) @@ -111975,6 +112627,7 @@ def test_list_event_edit_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_event_edit_rules(request) @@ -112010,6 +112663,7 @@ def test_list_event_edit_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_event_edit_rules(request) # Establish that the response is the type that we expect. @@ -112050,6 +112704,7 @@ def test_list_event_edit_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 = analytics_admin.ListEventEditRulesResponse.to_json( analytics_admin.ListEventEditRulesResponse() ) @@ -112096,6 +112751,7 @@ def test_create_event_edit_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_event_edit_rule(request) @@ -112218,6 +112874,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_edit_rule(request) # Establish that the response is the type that we expect. @@ -112260,6 +112917,7 @@ def test_create_event_edit_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 = event_create_and_edit.EventEditRule.to_json( event_create_and_edit.EventEditRule() ) @@ -112310,6 +112968,7 @@ def test_update_event_edit_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_event_edit_rule(request) @@ -112436,6 +113095,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_edit_rule(request) # Establish that the response is the type that we expect. @@ -112478,6 +113138,7 @@ def test_update_event_edit_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 = event_create_and_edit.EventEditRule.to_json( event_create_and_edit.EventEditRule() ) @@ -112526,6 +113187,7 @@ def test_delete_event_edit_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_event_edit_rule(request) @@ -112558,6 +113220,7 @@ def test_delete_event_edit_rule_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_edit_rule(request) # Establish that the response is the type that we expect. @@ -112594,6 +113257,7 @@ def test_delete_event_edit_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"} request = analytics_admin.DeleteEventEditRuleRequest() metadata = [ @@ -112634,6 +113298,7 @@ def test_reorder_event_edit_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.reorder_event_edit_rules(request) @@ -112664,6 +113329,7 @@ def test_reorder_event_edit_rules_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.reorder_event_edit_rules(request) # Establish that the response is the type that we expect. @@ -112700,6 +113366,7 @@ def test_reorder_event_edit_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"} request = analytics_admin.ReorderEventEditRulesRequest() metadata = [ @@ -112744,6 +113411,7 @@ def test_update_data_redaction_settings_rest_bad_request( response_value.status_code = 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_redaction_settings(request) @@ -112866,6 +113534,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_redaction_settings(request) # Establish that the response is the type that we expect. @@ -112911,6 +113580,7 @@ def test_update_data_redaction_settings_rest_interceptors(null_interceptor): req.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.DataRedactionSettings.to_json( resources.DataRedactionSettings() ) @@ -112959,6 +113629,7 @@ def test_get_data_redaction_settings_rest_bad_request( response_value.status_code = 400 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_redaction_settings(request) @@ -112999,6 +113670,7 @@ def test_get_data_redaction_settings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_redaction_settings(request) # Establish that the response is the type that we expect. @@ -113044,6 +113716,7 @@ def test_get_data_redaction_settings_rest_interceptors(null_interceptor): req.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.DataRedactionSettings.to_json( resources.DataRedactionSettings() ) @@ -113090,6 +113763,7 @@ def test_get_calculated_metric_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_calculated_metric(request) @@ -113134,6 +113808,7 @@ def test_get_calculated_metric_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_calculated_metric(request) # Establish that the response is the type that we expect. @@ -113183,6 +113858,7 @@ def test_get_calculated_metric_rest_interceptors(null_interceptor): req.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.CalculatedMetric.to_json(resources.CalculatedMetric()) req.return_value.content = return_value @@ -113227,6 +113903,7 @@ def test_create_calculated_metric_rest_bad_request( response_value.status_code = 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_calculated_metric(request) @@ -113350,6 +114027,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_calculated_metric(request) # Establish that the response is the type that we expect. @@ -113399,6 +114077,7 @@ def test_create_calculated_metric_rest_interceptors(null_interceptor): req.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.CalculatedMetric.to_json(resources.CalculatedMetric()) req.return_value.content = return_value @@ -113443,6 +114122,7 @@ def test_list_calculated_metrics_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_calculated_metrics(request) @@ -113478,6 +114158,7 @@ def test_list_calculated_metrics_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_calculated_metrics(request) # Establish that the response is the type that we expect. @@ -113518,6 +114199,7 @@ def test_list_calculated_metrics_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_admin.ListCalculatedMetricsResponse.to_json( analytics_admin.ListCalculatedMetricsResponse() ) @@ -113566,6 +114248,7 @@ def test_update_calculated_metric_rest_bad_request( response_value.status_code = 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_calculated_metric(request) @@ -113691,6 +114374,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_calculated_metric(request) # Establish that the response is the type that we expect. @@ -113740,6 +114424,7 @@ def test_update_calculated_metric_rest_interceptors(null_interceptor): req.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.CalculatedMetric.to_json(resources.CalculatedMetric()) req.return_value.content = return_value @@ -113784,6 +114469,7 @@ def test_delete_calculated_metric_rest_bad_request( response_value.status_code = 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_calculated_metric(request) @@ -113814,6 +114500,7 @@ def test_delete_calculated_metric_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_calculated_metric(request) # Establish that the response is the type that we expect. @@ -113850,6 +114537,7 @@ def test_delete_calculated_metric_rest_interceptors(null_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 = analytics_admin.DeleteCalculatedMetricRequest() metadata = [ @@ -113890,6 +114578,7 @@ def test_create_rollup_property_rest_bad_request( response_value.status_code = 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_rollup_property(request) @@ -113923,6 +114612,7 @@ def test_create_rollup_property_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_rollup_property(request) # Establish that the response is the type that we expect. @@ -113962,6 +114652,7 @@ def test_create_rollup_property_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_admin.CreateRollupPropertyResponse.to_json( analytics_admin.CreateRollupPropertyResponse() ) @@ -114008,6 +114699,7 @@ def test_get_rollup_property_source_link_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_rollup_property_source_link(request) @@ -114044,6 +114736,7 @@ def test_get_rollup_property_source_link_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_rollup_property_source_link(request) # Establish that the response is the type that we expect. @@ -114087,6 +114780,7 @@ def test_get_rollup_property_source_link_rest_interceptors(null_interceptor): req.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.RollupPropertySourceLink.to_json( resources.RollupPropertySourceLink() ) @@ -114133,6 +114827,7 @@ def test_list_rollup_property_source_links_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_rollup_property_source_links(request) @@ -114170,6 +114865,7 @@ def test_list_rollup_property_source_links_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_rollup_property_source_links(request) # Establish that the response is the type that we expect. @@ -114212,6 +114908,7 @@ def test_list_rollup_property_source_links_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_admin.ListRollupPropertySourceLinksResponse.to_json( analytics_admin.ListRollupPropertySourceLinksResponse() ) @@ -114258,6 +114955,7 @@ def test_create_rollup_property_source_link_rest_bad_request( response_value.status_code = 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_rollup_property_source_link(request) @@ -114371,6 +115069,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_rollup_property_source_link(request) # Establish that the response is the type that we expect. @@ -114414,6 +115113,7 @@ def test_create_rollup_property_source_link_rest_interceptors(null_interceptor): req.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.RollupPropertySourceLink.to_json( resources.RollupPropertySourceLink() ) @@ -114460,6 +115160,7 @@ def test_delete_rollup_property_source_link_rest_bad_request( response_value.status_code = 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_rollup_property_source_link(request) @@ -114490,6 +115191,7 @@ def test_delete_rollup_property_source_link_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_rollup_property_source_link(request) # Establish that the response is the type that we expect. @@ -114527,6 +115229,7 @@ def test_delete_rollup_property_source_link_rest_interceptors(null_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 = analytics_admin.DeleteRollupPropertySourceLinkRequest() metadata = [ @@ -114567,6 +115270,7 @@ def test_provision_subproperty_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.provision_subproperty(request) @@ -114600,6 +115304,7 @@ def test_provision_subproperty_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.provision_subproperty(request) # Establish that the response is the type that we expect. @@ -114639,6 +115344,7 @@ def test_provision_subproperty_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_admin.ProvisionSubpropertyResponse.to_json( analytics_admin.ProvisionSubpropertyResponse() ) @@ -114685,6 +115391,7 @@ def test_create_subproperty_event_filter_rest_bad_request( response_value.status_code = 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_subproperty_event_filter(request) @@ -114816,6 +115523,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_subproperty_event_filter(request) # Establish that the response is the type that we expect. @@ -114859,6 +115567,7 @@ def test_create_subproperty_event_filter_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = gaa_subproperty_event_filter.SubpropertyEventFilter.to_json( gaa_subproperty_event_filter.SubpropertyEventFilter() ) @@ -114905,6 +115614,7 @@ def test_get_subproperty_event_filter_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_subproperty_event_filter(request) @@ -114941,6 +115651,7 @@ def test_get_subproperty_event_filter_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_subproperty_event_filter(request) # Establish that the response is the type that we expect. @@ -114984,6 +115695,7 @@ def test_get_subproperty_event_filter_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = subproperty_event_filter.SubpropertyEventFilter.to_json( subproperty_event_filter.SubpropertyEventFilter() ) @@ -115030,6 +115742,7 @@ def test_list_subproperty_event_filters_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_subproperty_event_filters(request) @@ -115067,6 +115780,7 @@ def test_list_subproperty_event_filters_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_subproperty_event_filters(request) # Establish that the response is the type that we expect. @@ -115109,6 +115823,7 @@ def test_list_subproperty_event_filters_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_admin.ListSubpropertyEventFiltersResponse.to_json( analytics_admin.ListSubpropertyEventFiltersResponse() ) @@ -115159,6 +115874,7 @@ def test_update_subproperty_event_filter_rest_bad_request( response_value.status_code = 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_subproperty_event_filter(request) @@ -115294,6 +116010,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_subproperty_event_filter(request) # Establish that the response is the type that we expect. @@ -115337,6 +116054,7 @@ def test_update_subproperty_event_filter_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = gaa_subproperty_event_filter.SubpropertyEventFilter.to_json( gaa_subproperty_event_filter.SubpropertyEventFilter() ) @@ -115383,6 +116101,7 @@ def test_delete_subproperty_event_filter_rest_bad_request( response_value.status_code = 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_subproperty_event_filter(request) @@ -115413,6 +116132,7 @@ def test_delete_subproperty_event_filter_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_subproperty_event_filter(request) # Establish that the response is the type that we expect. @@ -115450,6 +116170,7 @@ def test_delete_subproperty_event_filter_rest_interceptors(null_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 = analytics_admin.DeleteSubpropertyEventFilterRequest() metadata = [ diff --git a/packages/google-analytics-admin/tests/unit/gapic/admin_v1beta/test_analytics_admin_service.py b/packages/google-analytics-admin/tests/unit/gapic/admin_v1beta/test_analytics_admin_service.py index 9b5864916859..7ac0ce48bdec 100644 --- a/packages/google-analytics-admin/tests/unit/gapic/admin_v1beta/test_analytics_admin_service.py +++ b/packages/google-analytics-admin/tests/unit/gapic/admin_v1beta/test_analytics_admin_service.py @@ -21561,6 +21561,7 @@ def test_get_account_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_account(request) @@ -21606,6 +21607,7 @@ def test_get_account_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_account(**mock_args) @@ -21831,6 +21833,7 @@ def test_delete_account_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_account(request) @@ -21874,6 +21877,7 @@ def test_delete_account_rest_flattened(): json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_account(**mock_args) @@ -22001,6 +22005,7 @@ def test_update_account_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_account(request) @@ -22055,6 +22060,7 @@ def test_update_account_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_account(**mock_args) @@ -22330,6 +22336,7 @@ def test_get_property_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_property(request) @@ -22375,6 +22382,7 @@ def test_get_property_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_property(**mock_args) @@ -22516,6 +22524,7 @@ def test_list_properties_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_properties(request) @@ -22710,6 +22719,7 @@ def test_create_property_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_property(request) @@ -22755,6 +22765,7 @@ def test_create_property_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_property(**mock_args) @@ -22884,6 +22895,7 @@ def test_delete_property_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_property(request) @@ -22929,6 +22941,7 @@ def test_delete_property_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_property(**mock_args) @@ -23056,6 +23069,7 @@ def test_update_property_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_property(request) @@ -23110,6 +23124,7 @@ def test_update_property_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_property(**mock_args) @@ -23245,6 +23260,7 @@ def test_create_firebase_link_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_firebase_link(request) @@ -23299,6 +23315,7 @@ def test_create_firebase_link_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_firebase_link(**mock_args) @@ -23431,6 +23448,7 @@ def test_delete_firebase_link_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_firebase_link(request) @@ -23474,6 +23492,7 @@ def test_delete_firebase_link_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_firebase_link(**mock_args) @@ -23615,6 +23634,7 @@ def test_list_firebase_links_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_firebase_links(request) @@ -23668,6 +23688,7 @@ def test_list_firebase_links_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_firebase_links(**mock_args) @@ -23867,6 +23888,7 @@ def test_create_google_ads_link_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_google_ads_link(request) @@ -23921,6 +23943,7 @@ def test_create_google_ads_link_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_google_ads_link(**mock_args) @@ -24055,6 +24078,7 @@ def test_update_google_ads_link_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_google_ads_link(request) @@ -24103,6 +24127,7 @@ def test_update_google_ads_link_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_google_ads_link(**mock_args) @@ -24237,6 +24262,7 @@ def test_delete_google_ads_link_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_google_ads_link(request) @@ -24280,6 +24306,7 @@ def test_delete_google_ads_link_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_google_ads_link(**mock_args) @@ -24422,6 +24449,7 @@ def test_list_google_ads_links_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_google_ads_links(request) @@ -24475,6 +24503,7 @@ def test_list_google_ads_links_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_google_ads_links(**mock_args) @@ -24673,6 +24702,7 @@ def test_get_data_sharing_settings_rest_required_fields( response_value._content = json_return_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_sharing_settings(request) @@ -24718,6 +24748,7 @@ def test_get_data_sharing_settings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_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_sharing_settings(**mock_args) @@ -24853,6 +24884,7 @@ def test_get_measurement_protocol_secret_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_measurement_protocol_secret(request) @@ -24902,6 +24934,7 @@ def test_get_measurement_protocol_secret_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_measurement_protocol_secret(**mock_args) @@ -25047,6 +25080,7 @@ def test_list_measurement_protocol_secrets_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_measurement_protocol_secrets(request) @@ -25104,6 +25138,7 @@ def test_list_measurement_protocol_secrets_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_measurement_protocol_secrets(**mock_args) @@ -25309,6 +25344,7 @@ def test_create_measurement_protocol_secret_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_measurement_protocol_secret(request) @@ -25367,6 +25403,7 @@ def test_create_measurement_protocol_secret_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_measurement_protocol_secret(**mock_args) @@ -25505,6 +25542,7 @@ def test_delete_measurement_protocol_secret_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_measurement_protocol_secret(request) @@ -25552,6 +25590,7 @@ def test_delete_measurement_protocol_secret_rest_flattened(): json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_measurement_protocol_secret(**mock_args) @@ -25688,6 +25727,7 @@ def test_update_measurement_protocol_secret_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_measurement_protocol_secret(request) @@ -25750,6 +25790,7 @@ def test_update_measurement_protocol_secret_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_measurement_protocol_secret(**mock_args) @@ -25898,6 +25939,7 @@ def test_acknowledge_user_data_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.acknowledge_user_data_collection(request) @@ -26035,6 +26077,7 @@ def test_search_change_history_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.search_change_history_events(request) @@ -26224,6 +26267,7 @@ def test_create_conversion_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_conversion_event(request) @@ -26278,6 +26322,7 @@ def test_create_conversion_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_conversion_event(**mock_args) @@ -26412,6 +26457,7 @@ def test_update_conversion_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_conversion_event(request) @@ -26468,6 +26514,7 @@ def test_update_conversion_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_conversion_event(**mock_args) @@ -26604,6 +26651,7 @@ def test_get_conversion_event_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_conversion_event(request) @@ -26649,6 +26697,7 @@ def test_get_conversion_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_conversion_event(**mock_args) @@ -26781,6 +26830,7 @@ def test_delete_conversion_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_conversion_event(request) @@ -26824,6 +26874,7 @@ def test_delete_conversion_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_conversion_event(**mock_args) @@ -26966,6 +27017,7 @@ def test_list_conversion_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_conversion_events(request) @@ -27019,6 +27071,7 @@ def test_list_conversion_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_conversion_events(**mock_args) @@ -27215,6 +27268,7 @@ def test_create_key_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_key_event(request) @@ -27269,6 +27323,7 @@ def test_create_key_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_key_event(**mock_args) @@ -27400,6 +27455,7 @@ def test_update_key_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_key_event(request) @@ -27454,6 +27510,7 @@ def test_update_key_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_key_event(**mock_args) @@ -27586,6 +27643,7 @@ def test_get_key_event_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_key_event(request) @@ -27631,6 +27689,7 @@ def test_get_key_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_key_event(**mock_args) @@ -27760,6 +27819,7 @@ def test_delete_key_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_key_event(request) @@ -27803,6 +27863,7 @@ def test_delete_key_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_key_event(**mock_args) @@ -27940,6 +28001,7 @@ def test_list_key_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_key_events(request) @@ -27993,6 +28055,7 @@ def test_list_key_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_key_events(**mock_args) @@ -28192,6 +28255,7 @@ def test_create_custom_dimension_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_custom_dimension(request) @@ -28246,6 +28310,7 @@ def test_create_custom_dimension_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_custom_dimension(**mock_args) @@ -28380,6 +28445,7 @@ def test_update_custom_dimension_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_custom_dimension(request) @@ -28428,6 +28494,7 @@ def test_update_custom_dimension_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_custom_dimension(**mock_args) @@ -28572,6 +28639,7 @@ def test_list_custom_dimensions_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_custom_dimensions(request) @@ -28625,6 +28693,7 @@ def test_list_custom_dimensions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_custom_dimensions(**mock_args) @@ -28821,6 +28890,7 @@ def test_archive_custom_dimension_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.archive_custom_dimension(request) @@ -28864,6 +28934,7 @@ def test_archive_custom_dimension_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.archive_custom_dimension(**mock_args) @@ -28999,6 +29070,7 @@ def test_get_custom_dimension_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_custom_dimension(request) @@ -29044,6 +29116,7 @@ def test_get_custom_dimension_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_custom_dimension(**mock_args) @@ -29179,6 +29252,7 @@ def test_create_custom_metric_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_custom_metric(request) @@ -29233,6 +29307,7 @@ def test_create_custom_metric_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_custom_metric(**mock_args) @@ -29366,6 +29441,7 @@ def test_update_custom_metric_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_custom_metric(request) @@ -29414,6 +29490,7 @@ def test_update_custom_metric_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_custom_metric(**mock_args) @@ -29557,6 +29634,7 @@ def test_list_custom_metrics_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_custom_metrics(request) @@ -29610,6 +29688,7 @@ def test_list_custom_metrics_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_custom_metrics(**mock_args) @@ -29806,6 +29885,7 @@ def test_archive_custom_metric_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.archive_custom_metric(request) @@ -29849,6 +29929,7 @@ def test_archive_custom_metric_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.archive_custom_metric(**mock_args) @@ -29982,6 +30063,7 @@ def test_get_custom_metric_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_custom_metric(request) @@ -30027,6 +30109,7 @@ def test_get_custom_metric_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_custom_metric(**mock_args) @@ -30162,6 +30245,7 @@ def test_get_data_retention_settings_rest_required_fields( response_value._content = json_return_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_retention_settings(request) @@ -30207,6 +30291,7 @@ def test_get_data_retention_settings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_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_retention_settings(**mock_args) @@ -30341,6 +30426,7 @@ def test_update_data_retention_settings_rest_required_fields( response_value._content = json_return_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_retention_settings(request) @@ -30401,6 +30487,7 @@ def test_update_data_retention_settings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_retention_settings(**mock_args) @@ -30538,6 +30625,7 @@ def test_create_data_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_data_stream(request) @@ -30596,6 +30684,7 @@ def test_create_data_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_data_stream(**mock_args) @@ -30732,6 +30821,7 @@ def test_delete_data_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_data_stream(request) @@ -30775,6 +30865,7 @@ def test_delete_data_stream_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_stream(**mock_args) @@ -30907,6 +30998,7 @@ def test_update_data_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_data_stream(request) @@ -30959,6 +31051,7 @@ def test_update_data_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_data_stream(**mock_args) @@ -31104,6 +31197,7 @@ def test_list_data_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_data_streams(request) @@ -31157,6 +31251,7 @@ def test_list_data_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_data_streams(**mock_args) @@ -31350,6 +31445,7 @@ def test_get_data_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.get_data_stream(request) @@ -31395,6 +31491,7 @@ def test_get_data_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_data_stream(**mock_args) @@ -34448,6 +34545,7 @@ def test_get_account_rest_bad_request(request_type=analytics_admin.GetAccountReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_account(request) @@ -34487,6 +34585,7 @@ def test_get_account_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_account(request) # Establish that the response is the type that we expect. @@ -34531,6 +34630,7 @@ def test_get_account_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = resources.Account.to_json(resources.Account()) req.return_value.content = return_value @@ -34575,6 +34675,7 @@ def test_list_accounts_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_accounts(request) @@ -34610,6 +34711,7 @@ def test_list_accounts_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_accounts(request) # Establish that the response is the type that we expect. @@ -34650,6 +34752,7 @@ def test_list_accounts_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_admin.ListAccountsResponse.to_json( analytics_admin.ListAccountsResponse() ) @@ -34696,6 +34799,7 @@ def test_delete_account_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_account(request) @@ -34726,6 +34830,7 @@ def test_delete_account_rest_call_success(request_type): json_return_value = "" response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_account(request) # Establish that the response is the type that we expect. @@ -34762,6 +34867,7 @@ def test_delete_account_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = analytics_admin.DeleteAccountRequest() metadata = [ @@ -34802,6 +34908,7 @@ def test_update_account_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_account(request) @@ -34917,6 +35024,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_account(request) # Establish that the response is the type that we expect. @@ -34961,6 +35069,7 @@ def test_update_account_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = resources.Account.to_json(resources.Account()) req.return_value.content = return_value @@ -35005,6 +35114,7 @@ def test_provision_account_ticket_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.provision_account_ticket(request) @@ -35040,6 +35150,7 @@ def test_provision_account_ticket_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.provision_account_ticket(request) # Establish that the response is the type that we expect. @@ -35080,6 +35191,7 @@ def test_provision_account_ticket_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_admin.ProvisionAccountTicketResponse.to_json( analytics_admin.ProvisionAccountTicketResponse() ) @@ -35126,6 +35238,7 @@ def test_list_account_summaries_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_account_summaries(request) @@ -35161,6 +35274,7 @@ def test_list_account_summaries_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_account_summaries(request) # Establish that the response is the type that we expect. @@ -35201,6 +35315,7 @@ def test_list_account_summaries_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_admin.ListAccountSummariesResponse.to_json( analytics_admin.ListAccountSummariesResponse() ) @@ -35245,6 +35360,7 @@ def test_get_property_rest_bad_request(request_type=analytics_admin.GetPropertyR response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_property(request) @@ -35288,6 +35404,7 @@ def test_get_property_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_property(request) # Establish that the response is the type that we expect. @@ -35336,6 +35453,7 @@ def test_get_property_rest_interceptors(null_interceptor): req.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.Property.to_json(resources.Property()) req.return_value.content = return_value @@ -35380,6 +35498,7 @@ def test_list_properties_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_properties(request) @@ -35415,6 +35534,7 @@ def test_list_properties_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_properties(request) # Establish that the response is the type that we expect. @@ -35455,6 +35575,7 @@ def test_list_properties_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_admin.ListPropertiesResponse.to_json( analytics_admin.ListPropertiesResponse() ) @@ -35501,6 +35622,7 @@ def test_create_property_rest_bad_request( response_value.status_code = 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_property(request) @@ -35626,6 +35748,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_property(request) # Establish that the response is the type that we expect. @@ -35674,6 +35797,7 @@ def test_create_property_rest_interceptors(null_interceptor): req.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.Property.to_json(resources.Property()) req.return_value.content = return_value @@ -35718,6 +35842,7 @@ def test_delete_property_rest_bad_request( response_value.status_code = 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_property(request) @@ -35761,6 +35886,7 @@ def test_delete_property_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_property(request) # Establish that the response is the type that we expect. @@ -35809,6 +35935,7 @@ def test_delete_property_rest_interceptors(null_interceptor): req.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.Property.to_json(resources.Property()) req.return_value.content = return_value @@ -35853,6 +35980,7 @@ def test_update_property_rest_bad_request( response_value.status_code = 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_property(request) @@ -35978,6 +36106,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_property(request) # Establish that the response is the type that we expect. @@ -36026,6 +36155,7 @@ def test_update_property_rest_interceptors(null_interceptor): req.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.Property.to_json(resources.Property()) req.return_value.content = return_value @@ -36070,6 +36200,7 @@ def test_create_firebase_link_rest_bad_request( response_value.status_code = 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_firebase_link(request) @@ -36178,6 +36309,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_firebase_link(request) # Establish that the response is the type that we expect. @@ -36219,6 +36351,7 @@ def test_create_firebase_link_rest_interceptors(null_interceptor): req.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.FirebaseLink.to_json(resources.FirebaseLink()) req.return_value.content = return_value @@ -36263,6 +36396,7 @@ def test_delete_firebase_link_rest_bad_request( response_value.status_code = 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_firebase_link(request) @@ -36293,6 +36427,7 @@ def test_delete_firebase_link_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_firebase_link(request) # Establish that the response is the type that we expect. @@ -36329,6 +36464,7 @@ def test_delete_firebase_link_rest_interceptors(null_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 = analytics_admin.DeleteFirebaseLinkRequest() metadata = [ @@ -36369,6 +36505,7 @@ def test_list_firebase_links_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_firebase_links(request) @@ -36404,6 +36541,7 @@ def test_list_firebase_links_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_firebase_links(request) # Establish that the response is the type that we expect. @@ -36444,6 +36582,7 @@ def test_list_firebase_links_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_admin.ListFirebaseLinksResponse.to_json( analytics_admin.ListFirebaseLinksResponse() ) @@ -36490,6 +36629,7 @@ def test_create_google_ads_link_rest_bad_request( response_value.status_code = 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_google_ads_link(request) @@ -36606,6 +36746,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_google_ads_link(request) # Establish that the response is the type that we expect. @@ -36649,6 +36790,7 @@ def test_create_google_ads_link_rest_interceptors(null_interceptor): req.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.GoogleAdsLink.to_json(resources.GoogleAdsLink()) req.return_value.content = return_value @@ -36695,6 +36837,7 @@ def test_update_google_ads_link_rest_bad_request( response_value.status_code = 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_google_ads_link(request) @@ -36813,6 +36956,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_google_ads_link(request) # Establish that the response is the type that we expect. @@ -36856,6 +37000,7 @@ def test_update_google_ads_link_rest_interceptors(null_interceptor): req.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.GoogleAdsLink.to_json(resources.GoogleAdsLink()) req.return_value.content = return_value @@ -36900,6 +37045,7 @@ def test_delete_google_ads_link_rest_bad_request( response_value.status_code = 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_google_ads_link(request) @@ -36930,6 +37076,7 @@ def test_delete_google_ads_link_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_google_ads_link(request) # Establish that the response is the type that we expect. @@ -36966,6 +37113,7 @@ def test_delete_google_ads_link_rest_interceptors(null_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 = analytics_admin.DeleteGoogleAdsLinkRequest() metadata = [ @@ -37006,6 +37154,7 @@ def test_list_google_ads_links_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_google_ads_links(request) @@ -37041,6 +37190,7 @@ def test_list_google_ads_links_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_google_ads_links(request) # Establish that the response is the type that we expect. @@ -37081,6 +37231,7 @@ def test_list_google_ads_links_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_admin.ListGoogleAdsLinksResponse.to_json( analytics_admin.ListGoogleAdsLinksResponse() ) @@ -37127,6 +37278,7 @@ def test_get_data_sharing_settings_rest_bad_request( response_value.status_code = 400 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_sharing_settings(request) @@ -37167,6 +37319,7 @@ def test_get_data_sharing_settings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_sharing_settings(request) # Establish that the response is the type that we expect. @@ -37213,6 +37366,7 @@ def test_get_data_sharing_settings_rest_interceptors(null_interceptor): req.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.DataSharingSettings.to_json( resources.DataSharingSettings() ) @@ -37261,6 +37415,7 @@ def test_get_measurement_protocol_secret_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_measurement_protocol_secret(request) @@ -37300,6 +37455,7 @@ def test_get_measurement_protocol_secret_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_measurement_protocol_secret(request) # Establish that the response is the type that we expect. @@ -37344,6 +37500,7 @@ def test_get_measurement_protocol_secret_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = resources.MeasurementProtocolSecret.to_json( resources.MeasurementProtocolSecret() ) @@ -37390,6 +37547,7 @@ def test_list_measurement_protocol_secrets_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_measurement_protocol_secrets(request) @@ -37427,6 +37585,7 @@ def test_list_measurement_protocol_secrets_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_measurement_protocol_secrets(request) # Establish that the response is the type that we expect. @@ -37469,6 +37628,7 @@ def test_list_measurement_protocol_secrets_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_admin.ListMeasurementProtocolSecretsResponse.to_json( analytics_admin.ListMeasurementProtocolSecretsResponse() ) @@ -37515,6 +37675,7 @@ def test_create_measurement_protocol_secret_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_measurement_protocol_secret(request) @@ -37630,6 +37791,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_measurement_protocol_secret(request) # Establish that the response is the type that we expect. @@ -37674,6 +37836,7 @@ def test_create_measurement_protocol_secret_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = resources.MeasurementProtocolSecret.to_json( resources.MeasurementProtocolSecret() ) @@ -37722,6 +37885,7 @@ def test_delete_measurement_protocol_secret_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_measurement_protocol_secret(request) @@ -37754,6 +37918,7 @@ def test_delete_measurement_protocol_secret_rest_call_success(request_type): json_return_value = "" response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_measurement_protocol_secret(request) # Establish that the response is the type that we expect. @@ -37791,6 +37956,7 @@ def test_delete_measurement_protocol_secret_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = analytics_admin.DeleteMeasurementProtocolSecretRequest() metadata = [ @@ -37835,6 +38001,7 @@ def test_update_measurement_protocol_secret_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_measurement_protocol_secret(request) @@ -37954,6 +38121,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_measurement_protocol_secret(request) # Establish that the response is the type that we expect. @@ -37998,6 +38166,7 @@ def test_update_measurement_protocol_secret_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = resources.MeasurementProtocolSecret.to_json( resources.MeasurementProtocolSecret() ) @@ -38044,6 +38213,7 @@ def test_acknowledge_user_data_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.acknowledge_user_data_collection(request) @@ -38079,6 +38249,7 @@ def test_acknowledge_user_data_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.acknowledge_user_data_collection(request) # Establish that the response is the type that we expect. @@ -38120,6 +38291,7 @@ def test_acknowledge_user_data_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 = analytics_admin.AcknowledgeUserDataCollectionResponse.to_json( analytics_admin.AcknowledgeUserDataCollectionResponse() ) @@ -38166,6 +38338,7 @@ def test_search_change_history_events_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.search_change_history_events(request) @@ -38203,6 +38376,7 @@ def test_search_change_history_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.search_change_history_events(request) # Establish that the response is the type that we expect. @@ -38245,6 +38419,7 @@ def test_search_change_history_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 = analytics_admin.SearchChangeHistoryEventsResponse.to_json( analytics_admin.SearchChangeHistoryEventsResponse() ) @@ -38291,6 +38466,7 @@ def test_create_conversion_event_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_conversion_event(request) @@ -38411,6 +38587,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_conversion_event(request) # Establish that the response is the type that we expect. @@ -38458,6 +38635,7 @@ def test_create_conversion_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.ConversionEvent.to_json(resources.ConversionEvent()) req.return_value.content = return_value @@ -38504,6 +38682,7 @@ def test_update_conversion_event_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_conversion_event(request) @@ -38626,6 +38805,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_conversion_event(request) # Establish that the response is the type that we expect. @@ -38673,6 +38853,7 @@ def test_update_conversion_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.ConversionEvent.to_json(resources.ConversionEvent()) req.return_value.content = return_value @@ -38717,6 +38898,7 @@ def test_get_conversion_event_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_conversion_event(request) @@ -38756,6 +38938,7 @@ def test_get_conversion_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_conversion_event(request) # Establish that the response is the type that we expect. @@ -38803,6 +38986,7 @@ def test_get_conversion_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.ConversionEvent.to_json(resources.ConversionEvent()) req.return_value.content = return_value @@ -38847,6 +39031,7 @@ def test_delete_conversion_event_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_conversion_event(request) @@ -38877,6 +39062,7 @@ def test_delete_conversion_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_conversion_event(request) # Establish that the response is the type that we expect. @@ -38913,6 +39099,7 @@ def test_delete_conversion_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 = analytics_admin.DeleteConversionEventRequest() metadata = [ @@ -38953,6 +39140,7 @@ def test_list_conversion_events_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_conversion_events(request) @@ -38988,6 +39176,7 @@ def test_list_conversion_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_conversion_events(request) # Establish that the response is the type that we expect. @@ -39028,6 +39217,7 @@ def test_list_conversion_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 = analytics_admin.ListConversionEventsResponse.to_json( analytics_admin.ListConversionEventsResponse() ) @@ -39074,6 +39264,7 @@ def test_create_key_event_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_key_event(request) @@ -39192,6 +39383,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_key_event(request) # Establish that the response is the type that we expect. @@ -39236,6 +39428,7 @@ def test_create_key_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.KeyEvent.to_json(resources.KeyEvent()) req.return_value.content = return_value @@ -39280,6 +39473,7 @@ def test_update_key_event_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_key_event(request) @@ -39398,6 +39592,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_key_event(request) # Establish that the response is the type that we expect. @@ -39442,6 +39637,7 @@ def test_update_key_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.KeyEvent.to_json(resources.KeyEvent()) req.return_value.content = return_value @@ -39486,6 +39682,7 @@ def test_get_key_event_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_key_event(request) @@ -39525,6 +39722,7 @@ def test_get_key_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_key_event(request) # Establish that the response is the type that we expect. @@ -39569,6 +39767,7 @@ def test_get_key_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.KeyEvent.to_json(resources.KeyEvent()) req.return_value.content = return_value @@ -39613,6 +39812,7 @@ def test_delete_key_event_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_key_event(request) @@ -39643,6 +39843,7 @@ def test_delete_key_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_key_event(request) # Establish that the response is the type that we expect. @@ -39679,6 +39880,7 @@ def test_delete_key_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 = analytics_admin.DeleteKeyEventRequest() metadata = [ @@ -39719,6 +39921,7 @@ def test_list_key_events_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_key_events(request) @@ -39754,6 +39957,7 @@ def test_list_key_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_key_events(request) # Establish that the response is the type that we expect. @@ -39794,6 +39998,7 @@ def test_list_key_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 = analytics_admin.ListKeyEventsResponse.to_json( analytics_admin.ListKeyEventsResponse() ) @@ -39840,6 +40045,7 @@ def test_create_custom_dimension_rest_bad_request( response_value.status_code = 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_custom_dimension(request) @@ -39957,6 +40163,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_custom_dimension(request) # Establish that the response is the type that we expect. @@ -40002,6 +40209,7 @@ def test_create_custom_dimension_rest_interceptors(null_interceptor): req.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.CustomDimension.to_json(resources.CustomDimension()) req.return_value.content = return_value @@ -40048,6 +40256,7 @@ def test_update_custom_dimension_rest_bad_request( response_value.status_code = 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_custom_dimension(request) @@ -40167,6 +40376,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_custom_dimension(request) # Establish that the response is the type that we expect. @@ -40212,6 +40422,7 @@ def test_update_custom_dimension_rest_interceptors(null_interceptor): req.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.CustomDimension.to_json(resources.CustomDimension()) req.return_value.content = return_value @@ -40256,6 +40467,7 @@ def test_list_custom_dimensions_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_custom_dimensions(request) @@ -40291,6 +40503,7 @@ def test_list_custom_dimensions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_custom_dimensions(request) # Establish that the response is the type that we expect. @@ -40331,6 +40544,7 @@ def test_list_custom_dimensions_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_admin.ListCustomDimensionsResponse.to_json( analytics_admin.ListCustomDimensionsResponse() ) @@ -40377,6 +40591,7 @@ def test_archive_custom_dimension_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.archive_custom_dimension(request) @@ -40407,6 +40622,7 @@ def test_archive_custom_dimension_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.archive_custom_dimension(request) # Establish that the response is the type that we expect. @@ -40443,6 +40659,7 @@ def test_archive_custom_dimension_rest_interceptors(null_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 = analytics_admin.ArchiveCustomDimensionRequest() metadata = [ @@ -40483,6 +40700,7 @@ def test_get_custom_dimension_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_custom_dimension(request) @@ -40523,6 +40741,7 @@ def test_get_custom_dimension_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_custom_dimension(request) # Establish that the response is the type that we expect. @@ -40568,6 +40787,7 @@ def test_get_custom_dimension_rest_interceptors(null_interceptor): req.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.CustomDimension.to_json(resources.CustomDimension()) req.return_value.content = return_value @@ -40612,6 +40832,7 @@ def test_create_custom_metric_rest_bad_request( response_value.status_code = 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_custom_metric(request) @@ -40731,6 +40952,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_custom_metric(request) # Establish that the response is the type that we expect. @@ -40779,6 +41001,7 @@ def test_create_custom_metric_rest_interceptors(null_interceptor): req.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.CustomMetric.to_json(resources.CustomMetric()) req.return_value.content = return_value @@ -40825,6 +41048,7 @@ def test_update_custom_metric_rest_bad_request( response_value.status_code = 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_custom_metric(request) @@ -40946,6 +41170,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_custom_metric(request) # Establish that the response is the type that we expect. @@ -40994,6 +41219,7 @@ def test_update_custom_metric_rest_interceptors(null_interceptor): req.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.CustomMetric.to_json(resources.CustomMetric()) req.return_value.content = return_value @@ -41038,6 +41264,7 @@ def test_list_custom_metrics_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_custom_metrics(request) @@ -41073,6 +41300,7 @@ def test_list_custom_metrics_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_custom_metrics(request) # Establish that the response is the type that we expect. @@ -41113,6 +41341,7 @@ def test_list_custom_metrics_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_admin.ListCustomMetricsResponse.to_json( analytics_admin.ListCustomMetricsResponse() ) @@ -41159,6 +41388,7 @@ def test_archive_custom_metric_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.archive_custom_metric(request) @@ -41189,6 +41419,7 @@ def test_archive_custom_metric_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.archive_custom_metric(request) # Establish that the response is the type that we expect. @@ -41225,6 +41456,7 @@ def test_archive_custom_metric_rest_interceptors(null_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 = analytics_admin.ArchiveCustomMetricRequest() metadata = [ @@ -41265,6 +41497,7 @@ def test_get_custom_metric_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_custom_metric(request) @@ -41308,6 +41541,7 @@ def test_get_custom_metric_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_custom_metric(request) # Establish that the response is the type that we expect. @@ -41356,6 +41590,7 @@ def test_get_custom_metric_rest_interceptors(null_interceptor): req.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.CustomMetric.to_json(resources.CustomMetric()) req.return_value.content = return_value @@ -41400,6 +41635,7 @@ def test_get_data_retention_settings_rest_bad_request( response_value.status_code = 400 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_retention_settings(request) @@ -41437,6 +41673,7 @@ def test_get_data_retention_settings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_retention_settings(request) # Establish that the response is the type that we expect. @@ -41484,6 +41721,7 @@ def test_get_data_retention_settings_rest_interceptors(null_interceptor): req.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.DataRetentionSettings.to_json( resources.DataRetentionSettings() ) @@ -41532,6 +41770,7 @@ def test_update_data_retention_settings_rest_bad_request( response_value.status_code = 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_retention_settings(request) @@ -41647,6 +41886,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_retention_settings(request) # Establish that the response is the type that we expect. @@ -41694,6 +41934,7 @@ def test_update_data_retention_settings_rest_interceptors(null_interceptor): req.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.DataRetentionSettings.to_json( resources.DataRetentionSettings() ) @@ -41740,6 +41981,7 @@ def test_create_data_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_data_stream(request) @@ -41864,6 +42106,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_stream(request) # Establish that the response is the type that we expect. @@ -41906,6 +42149,7 @@ def test_create_data_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 = resources.DataStream.to_json(resources.DataStream()) req.return_value.content = return_value @@ -41950,6 +42194,7 @@ def test_delete_data_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_data_stream(request) @@ -41980,6 +42225,7 @@ def test_delete_data_stream_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_stream(request) # Establish that the response is the type that we expect. @@ -42016,6 +42262,7 @@ def test_delete_data_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"} request = analytics_admin.DeleteDataStreamRequest() metadata = [ @@ -42056,6 +42303,7 @@ def test_update_data_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_data_stream(request) @@ -42180,6 +42428,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_stream(request) # Establish that the response is the type that we expect. @@ -42222,6 +42471,7 @@ def test_update_data_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 = resources.DataStream.to_json(resources.DataStream()) req.return_value.content = return_value @@ -42266,6 +42516,7 @@ def test_list_data_streams_rest_bad_request( response_value.status_code = 400 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_streams(request) @@ -42301,6 +42552,7 @@ def test_list_data_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_data_streams(request) # Establish that the response is the type that we expect. @@ -42341,6 +42593,7 @@ def test_list_data_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 = analytics_admin.ListDataStreamsResponse.to_json( analytics_admin.ListDataStreamsResponse() ) @@ -42387,6 +42640,7 @@ def test_get_data_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.get_data_stream(request) @@ -42424,6 +42678,7 @@ def test_get_data_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_data_stream(request) # Establish that the response is the type that we expect. @@ -42466,6 +42721,7 @@ def test_get_data_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 = resources.DataStream.to_json(resources.DataStream()) req.return_value.content = return_value @@ -42510,6 +42766,7 @@ def test_run_access_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.run_access_report(request) @@ -42545,6 +42802,7 @@ def test_run_access_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.run_access_report(request) # Establish that the response is the type that we expect. @@ -42585,6 +42843,7 @@ def test_run_access_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 = analytics_admin.RunAccessReportResponse.to_json( analytics_admin.RunAccessReportResponse() ) diff --git a/packages/google-analytics-data/google/analytics/data_v1alpha/services/alpha_analytics_data/async_client.py b/packages/google-analytics-data/google/analytics/data_v1alpha/services/alpha_analytics_data/async_client.py index 85f47086326b..fdfe72993dc6 100644 --- a/packages/google-analytics-data/google/analytics/data_v1alpha/services/alpha_analytics_data/async_client.py +++ b/packages/google-analytics-data/google/analytics/data_v1alpha/services/alpha_analytics_data/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, AlphaAnalyticsDataTransport from .transports.grpc_asyncio import AlphaAnalyticsDataGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class AlphaAnalyticsDataAsyncClient: """Google Analytics reporting data service.""" @@ -281,6 +291,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.analytics.data_v1alpha.AlphaAnalyticsDataAsyncClient`.", + extra={ + "serviceName": "google.analytics.data.v1alpha.AlphaAnalyticsData", + "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.analytics.data.v1alpha.AlphaAnalyticsData", + "credentialsType": None, + }, + ) + async def run_funnel_report( self, request: Optional[ @@ -289,7 +321,7 @@ async def run_funnel_report( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.RunFunnelReportResponse: r"""Returns a customized funnel report of your Google Analytics event data. The data returned from the API is as a table with @@ -341,8 +373,10 @@ async def sample_run_funnel_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.analytics.data_v1alpha.types.RunFunnelReportResponse: @@ -394,7 +428,7 @@ async def create_audience_list( audience_list: Optional[analytics_data_api.AudienceList] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 audience list for later retrieval. This method quickly returns the audience list's resource name and initiates @@ -478,8 +512,10 @@ async def sample_create_audience_list(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -555,7 +591,7 @@ async def query_audience_list( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.QueryAudienceListResponse: r"""Retrieves an audience list of users. After creating an audience, the users are not immediately available for listing. First, a @@ -618,8 +654,10 @@ async def sample_query_audience_list(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.data_v1alpha.types.QueryAudienceListResponse: @@ -680,7 +718,7 @@ async def sheet_export_audience_list( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.SheetExportAudienceListResponse: r"""Exports an audience list of users to a Google Sheet. After creating an audience, the users are not immediately available @@ -744,8 +782,10 @@ async def sample_sheet_export_audience_list(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.data_v1alpha.types.SheetExportAudienceListResponse: @@ -808,7 +848,7 @@ async def get_audience_list( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.AudienceList: r"""Gets configuration metadata about a specific audience list. This method can be used to understand an audience list after it has @@ -864,8 +904,10 @@ async def sample_get_audience_list(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.data_v1alpha.types.AudienceList: @@ -931,7 +973,7 @@ async def list_audience_lists( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAudienceListsAsyncPager: r"""Lists all audience lists for a property. This method can be used for you to find and reuse existing audience lists rather than @@ -991,8 +1033,10 @@ async def sample_list_audience_lists(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.data_v1alpha.services.alpha_analytics_data.pagers.ListAudienceListsAsyncPager: @@ -1072,7 +1116,7 @@ async def create_recurring_audience_list( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.RecurringAudienceList: r"""Creates a recurring audience list. Recurring audience lists produces new audience lists each day. Audience lists are users @@ -1146,8 +1190,10 @@ async def sample_create_recurring_audience_list(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.data_v1alpha.types.RecurringAudienceList: @@ -1219,7 +1265,7 @@ async def get_recurring_audience_list( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.RecurringAudienceList: r"""Gets configuration metadata about a specific recurring audience list. This method can be used to understand a recurring audience @@ -1276,8 +1322,10 @@ async def sample_get_recurring_audience_list(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.data_v1alpha.types.RecurringAudienceList: @@ -1345,7 +1393,7 @@ async def list_recurring_audience_lists( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListRecurringAudienceListsAsyncPager: r"""Lists all recurring audience lists for a property. This method can be used for you to find and reuse existing recurring @@ -1403,8 +1451,10 @@ async def sample_list_recurring_audience_lists(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.data_v1alpha.services.alpha_analytics_data.pagers.ListRecurringAudienceListsAsyncPager: @@ -1483,7 +1533,7 @@ async def get_property_quotas_snapshot( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.PropertyQuotasSnapshot: r"""Get all property quotas organized by quota category for a given property. This will charge 1 property quota @@ -1531,8 +1581,10 @@ async def sample_get_property_quotas_snapshot(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.data_v1alpha.types.PropertyQuotasSnapshot: @@ -1596,7 +1648,7 @@ async def create_report_task( report_task: Optional[analytics_data_api.ReportTask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 creation of a report task. This method quickly returns a report task and initiates a long @@ -1659,8 +1711,10 @@ async def sample_create_report_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.api_core.operation_async.AsyncOperation: @@ -1736,7 +1790,7 @@ async def query_report_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]]] = (), ) -> analytics_data_api.QueryReportTaskResponse: r"""Retrieves a report task's content. After requesting the ``CreateReportTask``, you are able to retrieve the report @@ -1785,8 +1839,10 @@ async def sample_query_report_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.analytics.data_v1alpha.types.QueryReportTaskResponse: @@ -1847,7 +1903,7 @@ async def get_report_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]]] = (), ) -> analytics_data_api.ReportTask: r"""Gets report metadata about a specific report task. After creating a report task, use this method to check @@ -1893,8 +1949,10 @@ async def sample_get_report_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.analytics.data_v1alpha.types.ReportTask: @@ -1955,7 +2013,7 @@ async def list_report_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.ListReportTasksAsyncPager: r"""Lists all report tasks for a property. @@ -2001,8 +2059,10 @@ async def sample_list_report_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.analytics.data_v1alpha.services.alpha_analytics_data.pagers.ListReportTasksAsyncPager: diff --git a/packages/google-analytics-data/google/analytics/data_v1alpha/services/alpha_analytics_data/client.py b/packages/google-analytics-data/google/analytics/data_v1alpha/services/alpha_analytics_data/client.py index 4911b5cf8c7e..421b316b6c2c 100644 --- a/packages/google-analytics-data/google/analytics/data_v1alpha/services/alpha_analytics_data/client.py +++ b/packages/google-analytics-data/google/analytics/data_v1alpha/services/alpha_analytics_data/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 @@ -638,6 +648,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( @@ -704,6 +718,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.analytics.data_v1alpha.AlphaAnalyticsDataClient`.", + extra={ + "serviceName": "google.analytics.data.v1alpha.AlphaAnalyticsData", + "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.analytics.data.v1alpha.AlphaAnalyticsData", + "credentialsType": None, + }, + ) + def run_funnel_report( self, request: Optional[ @@ -712,7 +749,7 @@ def run_funnel_report( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.RunFunnelReportResponse: r"""Returns a customized funnel report of your Google Analytics event data. The data returned from the API is as a table with @@ -764,8 +801,10 @@ def sample_run_funnel_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.analytics.data_v1alpha.types.RunFunnelReportResponse: @@ -815,7 +854,7 @@ def create_audience_list( audience_list: Optional[analytics_data_api.AudienceList] = None, retry: OptionalRetry = gapic_v1.method.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 audience list for later retrieval. This method quickly returns the audience list's resource name and initiates @@ -899,8 +938,10 @@ def sample_create_audience_list(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -973,7 +1014,7 @@ def query_audience_list( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.QueryAudienceListResponse: r"""Retrieves an audience list of users. After creating an audience, the users are not immediately available for listing. First, a @@ -1036,8 +1077,10 @@ def sample_query_audience_list(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.data_v1alpha.types.QueryAudienceListResponse: @@ -1095,7 +1138,7 @@ def sheet_export_audience_list( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.SheetExportAudienceListResponse: r"""Exports an audience list of users to a Google Sheet. After creating an audience, the users are not immediately available @@ -1159,8 +1202,10 @@ def sample_sheet_export_audience_list(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.data_v1alpha.types.SheetExportAudienceListResponse: @@ -1222,7 +1267,7 @@ def get_audience_list( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.AudienceList: r"""Gets configuration metadata about a specific audience list. This method can be used to understand an audience list after it has @@ -1278,8 +1323,10 @@ def sample_get_audience_list(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.data_v1alpha.types.AudienceList: @@ -1342,7 +1389,7 @@ def list_audience_lists( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAudienceListsPager: r"""Lists all audience lists for a property. This method can be used for you to find and reuse existing audience lists rather than @@ -1402,8 +1449,10 @@ def sample_list_audience_lists(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.data_v1alpha.services.alpha_analytics_data.pagers.ListAudienceListsPager: @@ -1480,7 +1529,7 @@ def create_recurring_audience_list( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.RecurringAudienceList: r"""Creates a recurring audience list. Recurring audience lists produces new audience lists each day. Audience lists are users @@ -1554,8 +1603,10 @@ def sample_create_recurring_audience_list(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.data_v1alpha.types.RecurringAudienceList: @@ -1626,7 +1677,7 @@ def get_recurring_audience_list( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.RecurringAudienceList: r"""Gets configuration metadata about a specific recurring audience list. This method can be used to understand a recurring audience @@ -1683,8 +1734,10 @@ def sample_get_recurring_audience_list(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.data_v1alpha.types.RecurringAudienceList: @@ -1751,7 +1804,7 @@ def list_recurring_audience_lists( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListRecurringAudienceListsPager: r"""Lists all recurring audience lists for a property. This method can be used for you to find and reuse existing recurring @@ -1809,8 +1862,10 @@ def sample_list_recurring_audience_lists(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.data_v1alpha.services.alpha_analytics_data.pagers.ListRecurringAudienceListsPager: @@ -1888,7 +1943,7 @@ def get_property_quotas_snapshot( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.PropertyQuotasSnapshot: r"""Get all property quotas organized by quota category for a given property. This will charge 1 property quota @@ -1936,8 +1991,10 @@ def sample_get_property_quotas_snapshot(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.data_v1alpha.types.PropertyQuotasSnapshot: @@ -2000,7 +2057,7 @@ def create_report_task( report_task: Optional[analytics_data_api.ReportTask] = None, retry: OptionalRetry = gapic_v1.method.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 creation of a report task. This method quickly returns a report task and initiates a long @@ -2063,8 +2120,10 @@ def sample_create_report_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.api_core.operation.Operation: @@ -2137,7 +2196,7 @@ def query_report_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]]] = (), ) -> analytics_data_api.QueryReportTaskResponse: r"""Retrieves a report task's content. After requesting the ``CreateReportTask``, you are able to retrieve the report @@ -2186,8 +2245,10 @@ def sample_query_report_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.analytics.data_v1alpha.types.QueryReportTaskResponse: @@ -2245,7 +2306,7 @@ def get_report_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]]] = (), ) -> analytics_data_api.ReportTask: r"""Gets report metadata about a specific report task. After creating a report task, use this method to check @@ -2291,8 +2352,10 @@ def sample_get_report_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.analytics.data_v1alpha.types.ReportTask: @@ -2350,7 +2413,7 @@ def list_report_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.ListReportTasksPager: r"""Lists all report tasks for a property. @@ -2396,8 +2459,10 @@ def sample_list_report_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.analytics.data_v1alpha.services.alpha_analytics_data.pagers.ListReportTasksPager: diff --git a/packages/google-analytics-data/google/analytics/data_v1alpha/services/alpha_analytics_data/pagers.py b/packages/google-analytics-data/google/analytics/data_v1alpha/services/alpha_analytics_data/pagers.py index 53db4b2aff3e..27eb21bac836 100644 --- a/packages/google-analytics-data/google/analytics/data_v1alpha/services/alpha_analytics_data/pagers.py +++ b/packages/google-analytics-data/google/analytics/data_v1alpha/services/alpha_analytics_data/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 = analytics_data_api.ListAudienceListsRequest(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 = analytics_data_api.ListAudienceListsRequest(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 = analytics_data_api.ListRecurringAudienceListsRequest(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 = analytics_data_api.ListRecurringAudienceListsRequest(request) @@ -377,7 +385,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -391,8 +399,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = analytics_data_api.ListReportTasksRequest(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 = analytics_data_api.ListReportTasksRequest(request) diff --git a/packages/google-analytics-data/google/analytics/data_v1alpha/services/alpha_analytics_data/transports/grpc.py b/packages/google-analytics-data/google/analytics/data_v1alpha/services/alpha_analytics_data/transports/grpc.py index c43f7d864e80..b81b01b45462 100644 --- a/packages/google-analytics-data/google/analytics/data_v1alpha/services/alpha_analytics_data/transports/grpc.py +++ b/packages/google-analytics-data/google/analytics/data_v1alpha/services/alpha_analytics_data/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.analytics.data_v1alpha.types import analytics_data_api from .base import DEFAULT_CLIENT_INFO, AlphaAnalyticsDataTransport +try: + from google.api_core import client_logging # 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.analytics.data.v1alpha.AlphaAnalyticsData", + "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.analytics.data.v1alpha.AlphaAnalyticsData", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AlphaAnalyticsDataGrpcTransport(AlphaAnalyticsDataTransport): """gRPC backend transport for AlphaAnalyticsData. @@ -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 @@ -289,7 +377,7 @@ def run_funnel_report( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "run_funnel_report" not in self._stubs: - self._stubs["run_funnel_report"] = self.grpc_channel.unary_unary( + self._stubs["run_funnel_report"] = self._logged_channel.unary_unary( "/google.analytics.data.v1alpha.AlphaAnalyticsData/RunFunnelReport", request_serializer=analytics_data_api.RunFunnelReportRequest.serialize, response_deserializer=analytics_data_api.RunFunnelReportResponse.deserialize, @@ -342,7 +430,7 @@ def create_audience_list( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_audience_list" not in self._stubs: - self._stubs["create_audience_list"] = self.grpc_channel.unary_unary( + self._stubs["create_audience_list"] = self._logged_channel.unary_unary( "/google.analytics.data.v1alpha.AlphaAnalyticsData/CreateAudienceList", request_serializer=analytics_data_api.CreateAudienceListRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -389,7 +477,7 @@ def query_audience_list( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "query_audience_list" not in self._stubs: - self._stubs["query_audience_list"] = self.grpc_channel.unary_unary( + self._stubs["query_audience_list"] = self._logged_channel.unary_unary( "/google.analytics.data.v1alpha.AlphaAnalyticsData/QueryAudienceList", request_serializer=analytics_data_api.QueryAudienceListRequest.serialize, response_deserializer=analytics_data_api.QueryAudienceListResponse.deserialize, @@ -437,7 +525,9 @@ def sheet_export_audience_list( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "sheet_export_audience_list" not in self._stubs: - self._stubs["sheet_export_audience_list"] = self.grpc_channel.unary_unary( + self._stubs[ + "sheet_export_audience_list" + ] = self._logged_channel.unary_unary( "/google.analytics.data.v1alpha.AlphaAnalyticsData/SheetExportAudienceList", request_serializer=analytics_data_api.SheetExportAudienceListRequest.serialize, response_deserializer=analytics_data_api.SheetExportAudienceListResponse.deserialize, @@ -477,7 +567,7 @@ def get_audience_list( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_audience_list" not in self._stubs: - self._stubs["get_audience_list"] = self.grpc_channel.unary_unary( + self._stubs["get_audience_list"] = self._logged_channel.unary_unary( "/google.analytics.data.v1alpha.AlphaAnalyticsData/GetAudienceList", request_serializer=analytics_data_api.GetAudienceListRequest.serialize, response_deserializer=analytics_data_api.AudienceList.deserialize, @@ -520,7 +610,7 @@ def list_audience_lists( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_audience_lists" not in self._stubs: - self._stubs["list_audience_lists"] = self.grpc_channel.unary_unary( + self._stubs["list_audience_lists"] = self._logged_channel.unary_unary( "/google.analytics.data.v1alpha.AlphaAnalyticsData/ListAudienceLists", request_serializer=analytics_data_api.ListAudienceListsRequest.serialize, response_deserializer=analytics_data_api.ListAudienceListsResponse.deserialize, @@ -569,7 +659,7 @@ def create_recurring_audience_list( if "create_recurring_audience_list" not in self._stubs: self._stubs[ "create_recurring_audience_list" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.data.v1alpha.AlphaAnalyticsData/CreateRecurringAudienceList", request_serializer=analytics_data_api.CreateRecurringAudienceListRequest.serialize, response_deserializer=analytics_data_api.RecurringAudienceList.deserialize, @@ -609,7 +699,9 @@ def get_recurring_audience_list( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_recurring_audience_list" not in self._stubs: - self._stubs["get_recurring_audience_list"] = self.grpc_channel.unary_unary( + self._stubs[ + "get_recurring_audience_list" + ] = self._logged_channel.unary_unary( "/google.analytics.data.v1alpha.AlphaAnalyticsData/GetRecurringAudienceList", request_serializer=analytics_data_api.GetRecurringAudienceListRequest.serialize, response_deserializer=analytics_data_api.RecurringAudienceList.deserialize, @@ -652,7 +744,7 @@ def list_recurring_audience_lists( if "list_recurring_audience_lists" not in self._stubs: self._stubs[ "list_recurring_audience_lists" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.data.v1alpha.AlphaAnalyticsData/ListRecurringAudienceLists", request_serializer=analytics_data_api.ListRecurringAudienceListsRequest.serialize, response_deserializer=analytics_data_api.ListRecurringAudienceListsResponse.deserialize, @@ -683,7 +775,9 @@ def get_property_quotas_snapshot( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_property_quotas_snapshot" not in self._stubs: - self._stubs["get_property_quotas_snapshot"] = self.grpc_channel.unary_unary( + self._stubs[ + "get_property_quotas_snapshot" + ] = self._logged_channel.unary_unary( "/google.analytics.data.v1alpha.AlphaAnalyticsData/GetPropertyQuotasSnapshot", request_serializer=analytics_data_api.GetPropertyQuotasSnapshotRequest.serialize, response_deserializer=analytics_data_api.PropertyQuotasSnapshot.deserialize, @@ -720,7 +814,7 @@ def create_report_task( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_report_task" not in self._stubs: - self._stubs["create_report_task"] = self.grpc_channel.unary_unary( + self._stubs["create_report_task"] = self._logged_channel.unary_unary( "/google.analytics.data.v1alpha.AlphaAnalyticsData/CreateReportTask", request_serializer=analytics_data_api.CreateReportTaskRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -754,7 +848,7 @@ def query_report_task( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "query_report_task" not in self._stubs: - self._stubs["query_report_task"] = self.grpc_channel.unary_unary( + self._stubs["query_report_task"] = self._logged_channel.unary_unary( "/google.analytics.data.v1alpha.AlphaAnalyticsData/QueryReportTask", request_serializer=analytics_data_api.QueryReportTaskRequest.serialize, response_deserializer=analytics_data_api.QueryReportTaskResponse.deserialize, @@ -784,7 +878,7 @@ def get_report_task( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_report_task" not in self._stubs: - self._stubs["get_report_task"] = self.grpc_channel.unary_unary( + self._stubs["get_report_task"] = self._logged_channel.unary_unary( "/google.analytics.data.v1alpha.AlphaAnalyticsData/GetReportTask", request_serializer=analytics_data_api.GetReportTaskRequest.serialize, response_deserializer=analytics_data_api.ReportTask.deserialize, @@ -813,7 +907,7 @@ def list_report_tasks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_report_tasks" not in self._stubs: - self._stubs["list_report_tasks"] = self.grpc_channel.unary_unary( + self._stubs["list_report_tasks"] = self._logged_channel.unary_unary( "/google.analytics.data.v1alpha.AlphaAnalyticsData/ListReportTasks", request_serializer=analytics_data_api.ListReportTasksRequest.serialize, response_deserializer=analytics_data_api.ListReportTasksResponse.deserialize, @@ -821,7 +915,7 @@ def list_report_tasks( return self._stubs["list_report_tasks"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-analytics-data/google/analytics/data_v1alpha/services/alpha_analytics_data/transports/grpc_asyncio.py b/packages/google-analytics-data/google/analytics/data_v1alpha/services/alpha_analytics_data/transports/grpc_asyncio.py index e0b029b13d2b..175833449ecb 100644 --- a/packages/google-analytics-data/google/analytics/data_v1alpha/services/alpha_analytics_data/transports/grpc_asyncio.py +++ b/packages/google-analytics-data/google/analytics/data_v1alpha/services/alpha_analytics_data/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.analytics.data_v1alpha.types import analytics_data_api from .base import DEFAULT_CLIENT_INFO, AlphaAnalyticsDataTransport from .grpc import AlphaAnalyticsDataGrpcTransport +try: + from google.api_core import client_logging # 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.analytics.data.v1alpha.AlphaAnalyticsData", + "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.analytics.data.v1alpha.AlphaAnalyticsData", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AlphaAnalyticsDataGrpcAsyncIOTransport(AlphaAnalyticsDataTransport): """gRPC AsyncIO backend transport for AlphaAnalyticsData. @@ -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. @@ -299,7 +384,7 @@ def run_funnel_report( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "run_funnel_report" not in self._stubs: - self._stubs["run_funnel_report"] = self.grpc_channel.unary_unary( + self._stubs["run_funnel_report"] = self._logged_channel.unary_unary( "/google.analytics.data.v1alpha.AlphaAnalyticsData/RunFunnelReport", request_serializer=analytics_data_api.RunFunnelReportRequest.serialize, response_deserializer=analytics_data_api.RunFunnelReportResponse.deserialize, @@ -353,7 +438,7 @@ def create_audience_list( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_audience_list" not in self._stubs: - self._stubs["create_audience_list"] = self.grpc_channel.unary_unary( + self._stubs["create_audience_list"] = self._logged_channel.unary_unary( "/google.analytics.data.v1alpha.AlphaAnalyticsData/CreateAudienceList", request_serializer=analytics_data_api.CreateAudienceListRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -400,7 +485,7 @@ def query_audience_list( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "query_audience_list" not in self._stubs: - self._stubs["query_audience_list"] = self.grpc_channel.unary_unary( + self._stubs["query_audience_list"] = self._logged_channel.unary_unary( "/google.analytics.data.v1alpha.AlphaAnalyticsData/QueryAudienceList", request_serializer=analytics_data_api.QueryAudienceListRequest.serialize, response_deserializer=analytics_data_api.QueryAudienceListResponse.deserialize, @@ -448,7 +533,9 @@ def sheet_export_audience_list( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "sheet_export_audience_list" not in self._stubs: - self._stubs["sheet_export_audience_list"] = self.grpc_channel.unary_unary( + self._stubs[ + "sheet_export_audience_list" + ] = self._logged_channel.unary_unary( "/google.analytics.data.v1alpha.AlphaAnalyticsData/SheetExportAudienceList", request_serializer=analytics_data_api.SheetExportAudienceListRequest.serialize, response_deserializer=analytics_data_api.SheetExportAudienceListResponse.deserialize, @@ -489,7 +576,7 @@ def get_audience_list( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_audience_list" not in self._stubs: - self._stubs["get_audience_list"] = self.grpc_channel.unary_unary( + self._stubs["get_audience_list"] = self._logged_channel.unary_unary( "/google.analytics.data.v1alpha.AlphaAnalyticsData/GetAudienceList", request_serializer=analytics_data_api.GetAudienceListRequest.serialize, response_deserializer=analytics_data_api.AudienceList.deserialize, @@ -532,7 +619,7 @@ def list_audience_lists( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_audience_lists" not in self._stubs: - self._stubs["list_audience_lists"] = self.grpc_channel.unary_unary( + self._stubs["list_audience_lists"] = self._logged_channel.unary_unary( "/google.analytics.data.v1alpha.AlphaAnalyticsData/ListAudienceLists", request_serializer=analytics_data_api.ListAudienceListsRequest.serialize, response_deserializer=analytics_data_api.ListAudienceListsResponse.deserialize, @@ -581,7 +668,7 @@ def create_recurring_audience_list( if "create_recurring_audience_list" not in self._stubs: self._stubs[ "create_recurring_audience_list" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.data.v1alpha.AlphaAnalyticsData/CreateRecurringAudienceList", request_serializer=analytics_data_api.CreateRecurringAudienceListRequest.serialize, response_deserializer=analytics_data_api.RecurringAudienceList.deserialize, @@ -621,7 +708,9 @@ def get_recurring_audience_list( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_recurring_audience_list" not in self._stubs: - self._stubs["get_recurring_audience_list"] = self.grpc_channel.unary_unary( + self._stubs[ + "get_recurring_audience_list" + ] = self._logged_channel.unary_unary( "/google.analytics.data.v1alpha.AlphaAnalyticsData/GetRecurringAudienceList", request_serializer=analytics_data_api.GetRecurringAudienceListRequest.serialize, response_deserializer=analytics_data_api.RecurringAudienceList.deserialize, @@ -664,7 +753,7 @@ def list_recurring_audience_lists( if "list_recurring_audience_lists" not in self._stubs: self._stubs[ "list_recurring_audience_lists" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.analytics.data.v1alpha.AlphaAnalyticsData/ListRecurringAudienceLists", request_serializer=analytics_data_api.ListRecurringAudienceListsRequest.serialize, response_deserializer=analytics_data_api.ListRecurringAudienceListsResponse.deserialize, @@ -695,7 +784,9 @@ def get_property_quotas_snapshot( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_property_quotas_snapshot" not in self._stubs: - self._stubs["get_property_quotas_snapshot"] = self.grpc_channel.unary_unary( + self._stubs[ + "get_property_quotas_snapshot" + ] = self._logged_channel.unary_unary( "/google.analytics.data.v1alpha.AlphaAnalyticsData/GetPropertyQuotasSnapshot", request_serializer=analytics_data_api.GetPropertyQuotasSnapshotRequest.serialize, response_deserializer=analytics_data_api.PropertyQuotasSnapshot.deserialize, @@ -733,7 +824,7 @@ def create_report_task( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_report_task" not in self._stubs: - self._stubs["create_report_task"] = self.grpc_channel.unary_unary( + self._stubs["create_report_task"] = self._logged_channel.unary_unary( "/google.analytics.data.v1alpha.AlphaAnalyticsData/CreateReportTask", request_serializer=analytics_data_api.CreateReportTaskRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -767,7 +858,7 @@ def query_report_task( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "query_report_task" not in self._stubs: - self._stubs["query_report_task"] = self.grpc_channel.unary_unary( + self._stubs["query_report_task"] = self._logged_channel.unary_unary( "/google.analytics.data.v1alpha.AlphaAnalyticsData/QueryReportTask", request_serializer=analytics_data_api.QueryReportTaskRequest.serialize, response_deserializer=analytics_data_api.QueryReportTaskResponse.deserialize, @@ -798,7 +889,7 @@ def get_report_task( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_report_task" not in self._stubs: - self._stubs["get_report_task"] = self.grpc_channel.unary_unary( + self._stubs["get_report_task"] = self._logged_channel.unary_unary( "/google.analytics.data.v1alpha.AlphaAnalyticsData/GetReportTask", request_serializer=analytics_data_api.GetReportTaskRequest.serialize, response_deserializer=analytics_data_api.ReportTask.deserialize, @@ -827,7 +918,7 @@ def list_report_tasks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_report_tasks" not in self._stubs: - self._stubs["list_report_tasks"] = self.grpc_channel.unary_unary( + self._stubs["list_report_tasks"] = self._logged_channel.unary_unary( "/google.analytics.data.v1alpha.AlphaAnalyticsData/ListReportTasks", request_serializer=analytics_data_api.ListReportTasksRequest.serialize, response_deserializer=analytics_data_api.ListReportTasksResponse.deserialize, @@ -915,7 +1006,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-analytics-data/google/analytics/data_v1alpha/services/alpha_analytics_data/transports/rest.py b/packages/google-analytics-data/google/analytics/data_v1alpha/services/alpha_analytics_data/transports/rest.py index 8c10f752b192..faf3c835dd1a 100644 --- a/packages/google-analytics-data/google/analytics/data_v1alpha/services/alpha_analytics_data/transports/rest.py +++ b/packages/google-analytics-data/google/analytics/data_v1alpha/services/alpha_analytics_data/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, @@ -182,8 +190,11 @@ def post_sheet_export_audience_list(self, response): def pre_create_audience_list( self, request: analytics_data_api.CreateAudienceListRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_data_api.CreateAudienceListRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_data_api.CreateAudienceListRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_audience_list Override in a subclass to manipulate the request or metadata @@ -205,9 +216,10 @@ def post_create_audience_list( def pre_create_recurring_audience_list( self, request: analytics_data_api.CreateRecurringAudienceListRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_data_api.CreateRecurringAudienceListRequest, Sequence[Tuple[str, str]] + analytics_data_api.CreateRecurringAudienceListRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_recurring_audience_list @@ -230,8 +242,11 @@ def post_create_recurring_audience_list( def pre_create_report_task( self, request: analytics_data_api.CreateReportTaskRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_data_api.CreateReportTaskRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_data_api.CreateReportTaskRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_report_task Override in a subclass to manipulate the request or metadata @@ -253,8 +268,11 @@ def post_create_report_task( def pre_get_audience_list( self, request: analytics_data_api.GetAudienceListRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_data_api.GetAudienceListRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_data_api.GetAudienceListRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_audience_list Override in a subclass to manipulate the request or metadata @@ -276,9 +294,10 @@ def post_get_audience_list( def pre_get_property_quotas_snapshot( self, request: analytics_data_api.GetPropertyQuotasSnapshotRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_data_api.GetPropertyQuotasSnapshotRequest, Sequence[Tuple[str, str]] + analytics_data_api.GetPropertyQuotasSnapshotRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_property_quotas_snapshot @@ -301,9 +320,10 @@ def post_get_property_quotas_snapshot( def pre_get_recurring_audience_list( self, request: analytics_data_api.GetRecurringAudienceListRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_data_api.GetRecurringAudienceListRequest, Sequence[Tuple[str, str]] + analytics_data_api.GetRecurringAudienceListRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_recurring_audience_list @@ -326,8 +346,10 @@ def post_get_recurring_audience_list( def pre_get_report_task( self, request: analytics_data_api.GetReportTaskRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_data_api.GetReportTaskRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_data_api.GetReportTaskRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_report_task Override in a subclass to manipulate the request or metadata @@ -349,8 +371,11 @@ def post_get_report_task( def pre_list_audience_lists( self, request: analytics_data_api.ListAudienceListsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_data_api.ListAudienceListsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_data_api.ListAudienceListsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_audience_lists Override in a subclass to manipulate the request or metadata @@ -372,9 +397,10 @@ def post_list_audience_lists( def pre_list_recurring_audience_lists( self, request: analytics_data_api.ListRecurringAudienceListsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_data_api.ListRecurringAudienceListsRequest, Sequence[Tuple[str, str]] + analytics_data_api.ListRecurringAudienceListsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_recurring_audience_lists @@ -397,8 +423,11 @@ def post_list_recurring_audience_lists( def pre_list_report_tasks( self, request: analytics_data_api.ListReportTasksRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_data_api.ListReportTasksRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_data_api.ListReportTasksRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_report_tasks Override in a subclass to manipulate the request or metadata @@ -420,8 +449,11 @@ def post_list_report_tasks( def pre_query_audience_list( self, request: analytics_data_api.QueryAudienceListRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_data_api.QueryAudienceListRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_data_api.QueryAudienceListRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for query_audience_list Override in a subclass to manipulate the request or metadata @@ -443,8 +475,11 @@ def post_query_audience_list( def pre_query_report_task( self, request: analytics_data_api.QueryReportTaskRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_data_api.QueryReportTaskRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_data_api.QueryReportTaskRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for query_report_task Override in a subclass to manipulate the request or metadata @@ -466,8 +501,11 @@ def post_query_report_task( def pre_run_funnel_report( self, request: analytics_data_api.RunFunnelReportRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_data_api.RunFunnelReportRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_data_api.RunFunnelReportRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for run_funnel_report Override in a subclass to manipulate the request or metadata @@ -489,9 +527,10 @@ def post_run_funnel_report( def pre_sheet_export_audience_list( self, request: analytics_data_api.SheetExportAudienceListRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_data_api.SheetExportAudienceListRequest, Sequence[Tuple[str, str]] + analytics_data_api.SheetExportAudienceListRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for sheet_export_audience_list @@ -662,7 +701,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 audience list method over HTTP. @@ -673,8 +712,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -687,6 +728,7 @@ def __call__( http_options = ( _BaseAlphaAnalyticsDataRestTransport._BaseCreateAudienceList._get_http_options() ) + request, metadata = self._interceptor.pre_create_audience_list( request, metadata ) @@ -703,6 +745,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.data_v1alpha.AlphaAnalyticsDataClient.CreateAudienceList", + extra={ + "serviceName": "google.analytics.data.v1alpha.AlphaAnalyticsData", + "rpcName": "CreateAudienceList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AlphaAnalyticsDataRestTransport._CreateAudienceList._get_response( @@ -724,7 +793,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_audience_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.data_v1alpha.AlphaAnalyticsDataClient.create_audience_list", + extra={ + "serviceName": "google.analytics.data.v1alpha.AlphaAnalyticsData", + "rpcName": "CreateAudienceList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateRecurringAudienceList( @@ -763,7 +854,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.RecurringAudienceList: r"""Call the create recurring audience list method over HTTP. @@ -775,8 +866,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_data_api.RecurringAudienceList: @@ -793,6 +886,7 @@ def __call__( http_options = ( _BaseAlphaAnalyticsDataRestTransport._BaseCreateRecurringAudienceList._get_http_options() ) + request, metadata = self._interceptor.pre_create_recurring_audience_list( request, metadata ) @@ -809,6 +903,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.data_v1alpha.AlphaAnalyticsDataClient.CreateRecurringAudienceList", + extra={ + "serviceName": "google.analytics.data.v1alpha.AlphaAnalyticsData", + "rpcName": "CreateRecurringAudienceList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlphaAnalyticsDataRestTransport._CreateRecurringAudienceList._get_response( self._host, @@ -830,7 +951,31 @@ def __call__( pb_resp = analytics_data_api.RecurringAudienceList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_recurring_audience_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = analytics_data_api.RecurringAudienceList.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.data_v1alpha.AlphaAnalyticsDataClient.create_recurring_audience_list", + extra={ + "serviceName": "google.analytics.data.v1alpha.AlphaAnalyticsData", + "rpcName": "CreateRecurringAudienceList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateReportTask( @@ -869,7 +1014,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 report task method over HTTP. @@ -879,8 +1024,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -893,6 +1040,7 @@ def __call__( http_options = ( _BaseAlphaAnalyticsDataRestTransport._BaseCreateReportTask._get_http_options() ) + request, metadata = self._interceptor.pre_create_report_task( request, metadata ) @@ -909,6 +1057,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.data_v1alpha.AlphaAnalyticsDataClient.CreateReportTask", + extra={ + "serviceName": "google.analytics.data.v1alpha.AlphaAnalyticsData", + "rpcName": "CreateReportTask", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlphaAnalyticsDataRestTransport._CreateReportTask._get_response( self._host, @@ -928,7 +1103,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_report_task(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.data_v1alpha.AlphaAnalyticsDataClient.create_report_task", + extra={ + "serviceName": "google.analytics.data.v1alpha.AlphaAnalyticsData", + "rpcName": "CreateReportTask", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAudienceList( @@ -966,7 +1163,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.AudienceList: r"""Call the get audience list method over HTTP. @@ -977,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: ~.analytics_data_api.AudienceList: @@ -993,6 +1192,7 @@ def __call__( http_options = ( _BaseAlphaAnalyticsDataRestTransport._BaseGetAudienceList._get_http_options() ) + request, metadata = self._interceptor.pre_get_audience_list( request, metadata ) @@ -1005,6 +1205,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.data_v1alpha.AlphaAnalyticsDataClient.GetAudienceList", + extra={ + "serviceName": "google.analytics.data.v1alpha.AlphaAnalyticsData", + "rpcName": "GetAudienceList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlphaAnalyticsDataRestTransport._GetAudienceList._get_response( self._host, @@ -1025,7 +1252,29 @@ def __call__( pb_resp = analytics_data_api.AudienceList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_audience_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = analytics_data_api.AudienceList.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.data_v1alpha.AlphaAnalyticsDataClient.get_audience_list", + extra={ + "serviceName": "google.analytics.data.v1alpha.AlphaAnalyticsData", + "rpcName": "GetAudienceList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetPropertyQuotasSnapshot( @@ -1063,7 +1312,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.PropertyQuotasSnapshot: r"""Call the get property quotas snapshot method over HTTP. @@ -1076,8 +1325,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_data_api.PropertyQuotasSnapshot: @@ -1089,6 +1340,7 @@ def __call__( http_options = ( _BaseAlphaAnalyticsDataRestTransport._BaseGetPropertyQuotasSnapshot._get_http_options() ) + request, metadata = self._interceptor.pre_get_property_quotas_snapshot( request, metadata ) @@ -1101,6 +1353,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.data_v1alpha.AlphaAnalyticsDataClient.GetPropertyQuotasSnapshot", + extra={ + "serviceName": "google.analytics.data.v1alpha.AlphaAnalyticsData", + "rpcName": "GetPropertyQuotasSnapshot", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlphaAnalyticsDataRestTransport._GetPropertyQuotasSnapshot._get_response( self._host, @@ -1121,7 +1400,31 @@ def __call__( pb_resp = analytics_data_api.PropertyQuotasSnapshot.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_property_quotas_snapshot(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_data_api.PropertyQuotasSnapshot.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.data_v1alpha.AlphaAnalyticsDataClient.get_property_quotas_snapshot", + extra={ + "serviceName": "google.analytics.data.v1alpha.AlphaAnalyticsData", + "rpcName": "GetPropertyQuotasSnapshot", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetRecurringAudienceList( @@ -1159,7 +1462,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.RecurringAudienceList: r"""Call the get recurring audience list method over HTTP. @@ -1172,8 +1475,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_data_api.RecurringAudienceList: @@ -1190,6 +1495,7 @@ def __call__( http_options = ( _BaseAlphaAnalyticsDataRestTransport._BaseGetRecurringAudienceList._get_http_options() ) + request, metadata = self._interceptor.pre_get_recurring_audience_list( request, metadata ) @@ -1202,6 +1508,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.data_v1alpha.AlphaAnalyticsDataClient.GetRecurringAudienceList", + extra={ + "serviceName": "google.analytics.data.v1alpha.AlphaAnalyticsData", + "rpcName": "GetRecurringAudienceList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AlphaAnalyticsDataRestTransport._GetRecurringAudienceList._get_response( @@ -1224,7 +1557,31 @@ def __call__( pb_resp = analytics_data_api.RecurringAudienceList.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_recurring_audience_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = analytics_data_api.RecurringAudienceList.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.data_v1alpha.AlphaAnalyticsDataClient.get_recurring_audience_list", + extra={ + "serviceName": "google.analytics.data.v1alpha.AlphaAnalyticsData", + "rpcName": "GetRecurringAudienceList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetReportTask( @@ -1262,7 +1619,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.ReportTask: r"""Call the get report task method over HTTP. @@ -1273,8 +1630,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_data_api.ReportTask: @@ -1284,6 +1643,7 @@ def __call__( http_options = ( _BaseAlphaAnalyticsDataRestTransport._BaseGetReportTask._get_http_options() ) + request, metadata = self._interceptor.pre_get_report_task(request, metadata) transcoded_request = _BaseAlphaAnalyticsDataRestTransport._BaseGetReportTask._get_transcoded_request( http_options, request @@ -1294,6 +1654,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.data_v1alpha.AlphaAnalyticsDataClient.GetReportTask", + extra={ + "serviceName": "google.analytics.data.v1alpha.AlphaAnalyticsData", + "rpcName": "GetReportTask", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlphaAnalyticsDataRestTransport._GetReportTask._get_response( self._host, @@ -1314,7 +1701,29 @@ def __call__( pb_resp = analytics_data_api.ReportTask.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_report_task(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = analytics_data_api.ReportTask.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.data_v1alpha.AlphaAnalyticsDataClient.get_report_task", + extra={ + "serviceName": "google.analytics.data.v1alpha.AlphaAnalyticsData", + "rpcName": "GetReportTask", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAudienceLists( @@ -1352,7 +1761,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.ListAudienceListsResponse: r"""Call the list audience lists method over HTTP. @@ -1363,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: ~.analytics_data_api.ListAudienceListsResponse: @@ -1376,6 +1787,7 @@ def __call__( http_options = ( _BaseAlphaAnalyticsDataRestTransport._BaseListAudienceLists._get_http_options() ) + request, metadata = self._interceptor.pre_list_audience_lists( request, metadata ) @@ -1388,6 +1800,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.data_v1alpha.AlphaAnalyticsDataClient.ListAudienceLists", + extra={ + "serviceName": "google.analytics.data.v1alpha.AlphaAnalyticsData", + "rpcName": "ListAudienceLists", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlphaAnalyticsDataRestTransport._ListAudienceLists._get_response( self._host, @@ -1408,7 +1847,31 @@ def __call__( pb_resp = analytics_data_api.ListAudienceListsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_audience_lists(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_data_api.ListAudienceListsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.data_v1alpha.AlphaAnalyticsDataClient.list_audience_lists", + extra={ + "serviceName": "google.analytics.data.v1alpha.AlphaAnalyticsData", + "rpcName": "ListAudienceLists", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListRecurringAudienceLists( @@ -1446,7 +1909,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.ListRecurringAudienceListsResponse: r"""Call the list recurring audience lists method over HTTP. @@ -1458,8 +1921,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_data_api.ListRecurringAudienceListsResponse: @@ -1471,6 +1936,7 @@ def __call__( http_options = ( _BaseAlphaAnalyticsDataRestTransport._BaseListRecurringAudienceLists._get_http_options() ) + request, metadata = self._interceptor.pre_list_recurring_audience_lists( request, metadata ) @@ -1483,6 +1949,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.data_v1alpha.AlphaAnalyticsDataClient.ListRecurringAudienceLists", + extra={ + "serviceName": "google.analytics.data.v1alpha.AlphaAnalyticsData", + "rpcName": "ListRecurringAudienceLists", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlphaAnalyticsDataRestTransport._ListRecurringAudienceLists._get_response( self._host, @@ -1503,7 +1996,33 @@ def __call__( pb_resp = analytics_data_api.ListRecurringAudienceListsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_recurring_audience_lists(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_data_api.ListRecurringAudienceListsResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.data_v1alpha.AlphaAnalyticsDataClient.list_recurring_audience_lists", + extra={ + "serviceName": "google.analytics.data.v1alpha.AlphaAnalyticsData", + "rpcName": "ListRecurringAudienceLists", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListReportTasks( @@ -1541,7 +2060,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.ListReportTasksResponse: r"""Call the list report tasks method over HTTP. @@ -1552,8 +2071,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_data_api.ListReportTasksResponse: @@ -1565,6 +2086,7 @@ def __call__( http_options = ( _BaseAlphaAnalyticsDataRestTransport._BaseListReportTasks._get_http_options() ) + request, metadata = self._interceptor.pre_list_report_tasks( request, metadata ) @@ -1577,6 +2099,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.data_v1alpha.AlphaAnalyticsDataClient.ListReportTasks", + extra={ + "serviceName": "google.analytics.data.v1alpha.AlphaAnalyticsData", + "rpcName": "ListReportTasks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlphaAnalyticsDataRestTransport._ListReportTasks._get_response( self._host, @@ -1597,7 +2146,31 @@ def __call__( pb_resp = analytics_data_api.ListReportTasksResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_report_tasks(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_data_api.ListReportTasksResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.data_v1alpha.AlphaAnalyticsDataClient.list_report_tasks", + extra={ + "serviceName": "google.analytics.data.v1alpha.AlphaAnalyticsData", + "rpcName": "ListReportTasks", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _QueryAudienceList( @@ -1636,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]]] = (), ) -> analytics_data_api.QueryAudienceListResponse: r"""Call the query audience list method over HTTP. @@ -1647,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: ~.analytics_data_api.QueryAudienceListResponse: @@ -1658,6 +2233,7 @@ def __call__( http_options = ( _BaseAlphaAnalyticsDataRestTransport._BaseQueryAudienceList._get_http_options() ) + request, metadata = self._interceptor.pre_query_audience_list( request, metadata ) @@ -1674,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 = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.data_v1alpha.AlphaAnalyticsDataClient.QueryAudienceList", + extra={ + "serviceName": "google.analytics.data.v1alpha.AlphaAnalyticsData", + "rpcName": "QueryAudienceList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlphaAnalyticsDataRestTransport._QueryAudienceList._get_response( self._host, @@ -1695,7 +2298,31 @@ def __call__( pb_resp = analytics_data_api.QueryAudienceListResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_query_audience_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_data_api.QueryAudienceListResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.data_v1alpha.AlphaAnalyticsDataClient.query_audience_list", + extra={ + "serviceName": "google.analytics.data.v1alpha.AlphaAnalyticsData", + "rpcName": "QueryAudienceList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _QueryReportTask( @@ -1734,7 +2361,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.QueryReportTaskResponse: r"""Call the query report task method over HTTP. @@ -1745,8 +2372,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_data_api.QueryReportTaskResponse: @@ -1758,6 +2387,7 @@ def __call__( http_options = ( _BaseAlphaAnalyticsDataRestTransport._BaseQueryReportTask._get_http_options() ) + request, metadata = self._interceptor.pre_query_report_task( request, metadata ) @@ -1774,6 +2404,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.data_v1alpha.AlphaAnalyticsDataClient.QueryReportTask", + extra={ + "serviceName": "google.analytics.data.v1alpha.AlphaAnalyticsData", + "rpcName": "QueryReportTask", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlphaAnalyticsDataRestTransport._QueryReportTask._get_response( self._host, @@ -1795,7 +2452,31 @@ def __call__( pb_resp = analytics_data_api.QueryReportTaskResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_query_report_task(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_data_api.QueryReportTaskResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.data_v1alpha.AlphaAnalyticsDataClient.query_report_task", + extra={ + "serviceName": "google.analytics.data.v1alpha.AlphaAnalyticsData", + "rpcName": "QueryReportTask", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RunFunnelReport( @@ -1834,7 +2515,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.RunFunnelReportResponse: r"""Call the run funnel report method over HTTP. @@ -1844,8 +2525,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_data_api.RunFunnelReportResponse: @@ -1859,6 +2542,7 @@ def __call__( http_options = ( _BaseAlphaAnalyticsDataRestTransport._BaseRunFunnelReport._get_http_options() ) + request, metadata = self._interceptor.pre_run_funnel_report( request, metadata ) @@ -1875,6 +2559,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.data_v1alpha.AlphaAnalyticsDataClient.RunFunnelReport", + extra={ + "serviceName": "google.analytics.data.v1alpha.AlphaAnalyticsData", + "rpcName": "RunFunnelReport", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlphaAnalyticsDataRestTransport._RunFunnelReport._get_response( self._host, @@ -1896,7 +2607,31 @@ def __call__( pb_resp = analytics_data_api.RunFunnelReportResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_run_funnel_report(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_data_api.RunFunnelReportResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.data_v1alpha.AlphaAnalyticsDataClient.run_funnel_report", + extra={ + "serviceName": "google.analytics.data.v1alpha.AlphaAnalyticsData", + "rpcName": "RunFunnelReport", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SheetExportAudienceList( @@ -1935,7 +2670,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.SheetExportAudienceListResponse: r"""Call the sheet export audience list method over HTTP. @@ -1947,8 +2682,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_data_api.SheetExportAudienceListResponse: @@ -1960,6 +2697,7 @@ def __call__( http_options = ( _BaseAlphaAnalyticsDataRestTransport._BaseSheetExportAudienceList._get_http_options() ) + request, metadata = self._interceptor.pre_sheet_export_audience_list( request, metadata ) @@ -1976,6 +2714,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.data_v1alpha.AlphaAnalyticsDataClient.SheetExportAudienceList", + extra={ + "serviceName": "google.analytics.data.v1alpha.AlphaAnalyticsData", + "rpcName": "SheetExportAudienceList", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AlphaAnalyticsDataRestTransport._SheetExportAudienceList._get_response( @@ -1999,7 +2764,33 @@ def __call__( pb_resp = analytics_data_api.SheetExportAudienceListResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_sheet_export_audience_list(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_data_api.SheetExportAudienceListResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.data_v1alpha.AlphaAnalyticsDataClient.sheet_export_audience_list", + extra={ + "serviceName": "google.analytics.data.v1alpha.AlphaAnalyticsData", + "rpcName": "SheetExportAudienceList", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-analytics-data/google/analytics/data_v1beta/services/beta_analytics_data/async_client.py b/packages/google-analytics-data/google/analytics/data_v1beta/services/beta_analytics_data/async_client.py index aa7983a3e079..206a93f1e9ee 100644 --- a/packages/google-analytics-data/google/analytics/data_v1beta/services/beta_analytics_data/async_client.py +++ b/packages/google-analytics-data/google/analytics/data_v1beta/services/beta_analytics_data/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, BetaAnalyticsDataTransport from .transports.grpc_asyncio import BetaAnalyticsDataGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class BetaAnalyticsDataAsyncClient: """Google Analytics reporting data service.""" @@ -267,13 +277,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.analytics.data_v1beta.BetaAnalyticsDataAsyncClient`.", + extra={ + "serviceName": "google.analytics.data.v1beta.BetaAnalyticsData", + "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.analytics.data.v1beta.BetaAnalyticsData", + "credentialsType": None, + }, + ) + async def run_report( self, request: Optional[Union[analytics_data_api.RunReportRequest, 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]]] = (), ) -> analytics_data_api.RunReportResponse: r"""Returns a customized report of your Google Analytics event data. Reports contain statistics derived from data collected by the @@ -319,8 +351,10 @@ async def sample_run_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.analytics.data_v1beta.types.RunReportResponse: @@ -366,7 +400,7 @@ async def run_pivot_report( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.RunPivotReportResponse: r"""Returns a customized pivot report of your Google Analytics event data. Pivot reports are more advanced @@ -407,8 +441,10 @@ async def sample_run_pivot_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.analytics.data_v1beta.types.RunPivotReportResponse: @@ -456,7 +492,7 @@ async def batch_run_reports( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.BatchRunReportsResponse: r"""Returns multiple reports in a batch. All reports must be for the same Google Analytics property. @@ -493,8 +529,10 @@ async def sample_batch_run_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.analytics.data_v1beta.types.BatchRunReportsResponse: @@ -542,7 +580,7 @@ async def batch_run_pivot_reports( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.BatchRunPivotReportsResponse: r"""Returns multiple pivot reports in a batch. All reports must be for the same Google Analytics property. @@ -579,8 +617,10 @@ async def sample_batch_run_pivot_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.analytics.data_v1beta.types.BatchRunPivotReportsResponse: @@ -627,7 +667,7 @@ async def get_metadata( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.Metadata: r"""Returns metadata for dimensions and metrics available in reporting methods. Used to explore the dimensions and metrics. @@ -691,8 +731,10 @@ async def sample_get_metadata(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.data_v1beta.types.Metadata: @@ -755,7 +797,7 @@ async def run_realtime_report( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.RunRealtimeReportResponse: r"""Returns a customized report of realtime event data for your property. Events appear in realtime reports seconds after they @@ -800,8 +842,10 @@ async def sample_run_realtime_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.analytics.data_v1beta.types.RunRealtimeReportResponse: @@ -849,7 +893,7 @@ async def check_compatibility( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.CheckCompatibilityResponse: r"""This compatibility method lists dimensions and metrics that can be added to a report request and @@ -900,8 +944,10 @@ async def sample_check_compatibility(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.data_v1beta.types.CheckCompatibilityResponse: @@ -952,7 +998,7 @@ async def create_audience_export( audience_export: Optional[analytics_data_api.AudienceExport] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 audience export for later retrieval. This method quickly returns the audience export's resource name and @@ -1038,8 +1084,10 @@ async def sample_create_audience_export(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -1115,7 +1163,7 @@ async def query_audience_export( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.QueryAudienceExportResponse: r"""Retrieves an audience export of users. After creating an audience, the users are not immediately available for exporting. @@ -1179,8 +1227,10 @@ async def sample_query_audience_export(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.data_v1beta.types.QueryAudienceExportResponse: @@ -1243,7 +1293,7 @@ async def get_audience_export( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.AudienceExport: r"""Gets configuration metadata about a specific audience export. This method can be used to understand an audience export after @@ -1301,8 +1351,10 @@ async def sample_get_audience_export(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.data_v1beta.types.AudienceExport: @@ -1368,7 +1420,7 @@ async def list_audience_exports( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAudienceExportsAsyncPager: r"""Lists all audience exports for a property. This method can be used for you to find and reuse existing audience exports rather @@ -1429,8 +1481,10 @@ async def sample_list_audience_exports(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.data_v1beta.services.beta_analytics_data.pagers.ListAudienceExportsAsyncPager: diff --git a/packages/google-analytics-data/google/analytics/data_v1beta/services/beta_analytics_data/client.py b/packages/google-analytics-data/google/analytics/data_v1beta/services/beta_analytics_data/client.py index 9de2126d9dd8..0e690944ba66 100644 --- a/packages/google-analytics-data/google/analytics/data_v1beta/services/beta_analytics_data/client.py +++ b/packages/google-analytics-data/google/analytics/data_v1beta/services/beta_analytics_data/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 @@ -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,13 +680,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.analytics.data_v1beta.BetaAnalyticsDataClient`.", + extra={ + "serviceName": "google.analytics.data.v1beta.BetaAnalyticsData", + "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.analytics.data.v1beta.BetaAnalyticsData", + "credentialsType": None, + }, + ) + def run_report( self, request: Optional[Union[analytics_data_api.RunReportRequest, 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]]] = (), ) -> analytics_data_api.RunReportResponse: r"""Returns a customized report of your Google Analytics event data. Reports contain statistics derived from data collected by the @@ -718,8 +755,10 @@ def sample_run_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.analytics.data_v1beta.types.RunReportResponse: @@ -763,7 +802,7 @@ def run_pivot_report( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.RunPivotReportResponse: r"""Returns a customized pivot report of your Google Analytics event data. Pivot reports are more advanced @@ -804,8 +843,10 @@ def sample_run_pivot_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.analytics.data_v1beta.types.RunPivotReportResponse: @@ -851,7 +892,7 @@ def batch_run_reports( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.BatchRunReportsResponse: r"""Returns multiple reports in a batch. All reports must be for the same Google Analytics property. @@ -888,8 +929,10 @@ def sample_batch_run_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.analytics.data_v1beta.types.BatchRunReportsResponse: @@ -935,7 +978,7 @@ def batch_run_pivot_reports( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.BatchRunPivotReportsResponse: r"""Returns multiple pivot reports in a batch. All reports must be for the same Google Analytics property. @@ -972,8 +1015,10 @@ def sample_batch_run_pivot_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.analytics.data_v1beta.types.BatchRunPivotReportsResponse: @@ -1018,7 +1063,7 @@ def get_metadata( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.Metadata: r"""Returns metadata for dimensions and metrics available in reporting methods. Used to explore the dimensions and metrics. @@ -1082,8 +1127,10 @@ def sample_get_metadata(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.data_v1beta.types.Metadata: @@ -1143,7 +1190,7 @@ def run_realtime_report( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.RunRealtimeReportResponse: r"""Returns a customized report of realtime event data for your property. Events appear in realtime reports seconds after they @@ -1188,8 +1235,10 @@ def sample_run_realtime_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.analytics.data_v1beta.types.RunRealtimeReportResponse: @@ -1235,7 +1284,7 @@ def check_compatibility( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.CheckCompatibilityResponse: r"""This compatibility method lists dimensions and metrics that can be added to a report request and @@ -1286,8 +1335,10 @@ def sample_check_compatibility(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.data_v1beta.types.CheckCompatibilityResponse: @@ -1336,7 +1387,7 @@ def create_audience_export( audience_export: Optional[analytics_data_api.AudienceExport] = None, retry: OptionalRetry = gapic_v1.method.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 audience export for later retrieval. This method quickly returns the audience export's resource name and @@ -1422,8 +1473,10 @@ def sample_create_audience_export(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -1496,7 +1549,7 @@ def query_audience_export( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.QueryAudienceExportResponse: r"""Retrieves an audience export of users. After creating an audience, the users are not immediately available for exporting. @@ -1560,8 +1613,10 @@ def sample_query_audience_export(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.data_v1beta.types.QueryAudienceExportResponse: @@ -1621,7 +1676,7 @@ def get_audience_export( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.AudienceExport: r"""Gets configuration metadata about a specific audience export. This method can be used to understand an audience export after @@ -1679,8 +1734,10 @@ def sample_get_audience_export(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.data_v1beta.types.AudienceExport: @@ -1743,7 +1800,7 @@ def list_audience_exports( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAudienceExportsPager: r"""Lists all audience exports for a property. This method can be used for you to find and reuse existing audience exports rather @@ -1804,8 +1861,10 @@ def sample_list_audience_exports(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.analytics.data_v1beta.services.beta_analytics_data.pagers.ListAudienceExportsPager: diff --git a/packages/google-analytics-data/google/analytics/data_v1beta/services/beta_analytics_data/pagers.py b/packages/google-analytics-data/google/analytics/data_v1beta/services/beta_analytics_data/pagers.py index 2c3ddf0b3f9e..ad91c5183953 100644 --- a/packages/google-analytics-data/google/analytics/data_v1beta/services/beta_analytics_data/pagers.py +++ b/packages/google-analytics-data/google/analytics/data_v1beta/services/beta_analytics_data/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 = analytics_data_api.ListAudienceExportsRequest(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 = analytics_data_api.ListAudienceExportsRequest(request) diff --git a/packages/google-analytics-data/google/analytics/data_v1beta/services/beta_analytics_data/transports/grpc.py b/packages/google-analytics-data/google/analytics/data_v1beta/services/beta_analytics_data/transports/grpc.py index 35405dbf9043..e9fae2300814 100644 --- a/packages/google-analytics-data/google/analytics/data_v1beta/services/beta_analytics_data/transports/grpc.py +++ b/packages/google-analytics-data/google/analytics/data_v1beta/services/beta_analytics_data/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.analytics.data_v1beta.types import analytics_data_api from .base import DEFAULT_CLIENT_INFO, BetaAnalyticsDataTransport +try: + from google.api_core import client_logging # 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.analytics.data.v1beta.BetaAnalyticsData", + "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.analytics.data.v1beta.BetaAnalyticsData", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class BetaAnalyticsDataGrpcTransport(BetaAnalyticsDataTransport): """gRPC backend transport for BetaAnalyticsData. @@ -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 @@ -282,7 +370,7 @@ def run_report( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "run_report" not in self._stubs: - self._stubs["run_report"] = self.grpc_channel.unary_unary( + self._stubs["run_report"] = self._logged_channel.unary_unary( "/google.analytics.data.v1beta.BetaAnalyticsData/RunReport", request_serializer=analytics_data_api.RunReportRequest.serialize, response_deserializer=analytics_data_api.RunReportResponse.deserialize, @@ -316,7 +404,7 @@ def run_pivot_report( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "run_pivot_report" not in self._stubs: - self._stubs["run_pivot_report"] = self.grpc_channel.unary_unary( + self._stubs["run_pivot_report"] = self._logged_channel.unary_unary( "/google.analytics.data.v1beta.BetaAnalyticsData/RunPivotReport", request_serializer=analytics_data_api.RunPivotReportRequest.serialize, response_deserializer=analytics_data_api.RunPivotReportResponse.deserialize, @@ -346,7 +434,7 @@ def batch_run_reports( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_run_reports" not in self._stubs: - self._stubs["batch_run_reports"] = self.grpc_channel.unary_unary( + self._stubs["batch_run_reports"] = self._logged_channel.unary_unary( "/google.analytics.data.v1beta.BetaAnalyticsData/BatchRunReports", request_serializer=analytics_data_api.BatchRunReportsRequest.serialize, response_deserializer=analytics_data_api.BatchRunReportsResponse.deserialize, @@ -376,7 +464,7 @@ def batch_run_pivot_reports( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_run_pivot_reports" not in self._stubs: - self._stubs["batch_run_pivot_reports"] = self.grpc_channel.unary_unary( + self._stubs["batch_run_pivot_reports"] = self._logged_channel.unary_unary( "/google.analytics.data.v1beta.BetaAnalyticsData/BatchRunPivotReports", request_serializer=analytics_data_api.BatchRunPivotReportsRequest.serialize, response_deserializer=analytics_data_api.BatchRunPivotReportsResponse.deserialize, @@ -412,7 +500,7 @@ def get_metadata( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_metadata" not in self._stubs: - self._stubs["get_metadata"] = self.grpc_channel.unary_unary( + self._stubs["get_metadata"] = self._logged_channel.unary_unary( "/google.analytics.data.v1beta.BetaAnalyticsData/GetMetadata", request_serializer=analytics_data_api.GetMetadataRequest.serialize, response_deserializer=analytics_data_api.Metadata.deserialize, @@ -450,7 +538,7 @@ def run_realtime_report( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "run_realtime_report" not in self._stubs: - self._stubs["run_realtime_report"] = self.grpc_channel.unary_unary( + self._stubs["run_realtime_report"] = self._logged_channel.unary_unary( "/google.analytics.data.v1beta.BetaAnalyticsData/RunRealtimeReport", request_serializer=analytics_data_api.RunRealtimeReportRequest.serialize, response_deserializer=analytics_data_api.RunRealtimeReportResponse.deserialize, @@ -491,7 +579,7 @@ def check_compatibility( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "check_compatibility" not in self._stubs: - self._stubs["check_compatibility"] = self.grpc_channel.unary_unary( + self._stubs["check_compatibility"] = self._logged_channel.unary_unary( "/google.analytics.data.v1beta.BetaAnalyticsData/CheckCompatibility", request_serializer=analytics_data_api.CheckCompatibilityRequest.serialize, response_deserializer=analytics_data_api.CheckCompatibilityResponse.deserialize, @@ -546,7 +634,7 @@ def create_audience_export( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_audience_export" not in self._stubs: - self._stubs["create_audience_export"] = self.grpc_channel.unary_unary( + self._stubs["create_audience_export"] = self._logged_channel.unary_unary( "/google.analytics.data.v1beta.BetaAnalyticsData/CreateAudienceExport", request_serializer=analytics_data_api.CreateAudienceExportRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -594,7 +682,7 @@ def query_audience_export( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "query_audience_export" not in self._stubs: - self._stubs["query_audience_export"] = self.grpc_channel.unary_unary( + self._stubs["query_audience_export"] = self._logged_channel.unary_unary( "/google.analytics.data.v1beta.BetaAnalyticsData/QueryAudienceExport", request_serializer=analytics_data_api.QueryAudienceExportRequest.serialize, response_deserializer=analytics_data_api.QueryAudienceExportResponse.deserialize, @@ -635,7 +723,7 @@ def get_audience_export( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_audience_export" not in self._stubs: - self._stubs["get_audience_export"] = self.grpc_channel.unary_unary( + self._stubs["get_audience_export"] = self._logged_channel.unary_unary( "/google.analytics.data.v1beta.BetaAnalyticsData/GetAudienceExport", request_serializer=analytics_data_api.GetAudienceExportRequest.serialize, response_deserializer=analytics_data_api.AudienceExport.deserialize, @@ -679,7 +767,7 @@ def list_audience_exports( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_audience_exports" not in self._stubs: - self._stubs["list_audience_exports"] = self.grpc_channel.unary_unary( + self._stubs["list_audience_exports"] = self._logged_channel.unary_unary( "/google.analytics.data.v1beta.BetaAnalyticsData/ListAudienceExports", request_serializer=analytics_data_api.ListAudienceExportsRequest.serialize, response_deserializer=analytics_data_api.ListAudienceExportsResponse.deserialize, @@ -687,7 +775,7 @@ def list_audience_exports( return self._stubs["list_audience_exports"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-analytics-data/google/analytics/data_v1beta/services/beta_analytics_data/transports/grpc_asyncio.py b/packages/google-analytics-data/google/analytics/data_v1beta/services/beta_analytics_data/transports/grpc_asyncio.py index 4fcb09ce2150..d2722397a2de 100644 --- a/packages/google-analytics-data/google/analytics/data_v1beta/services/beta_analytics_data/transports/grpc_asyncio.py +++ b/packages/google-analytics-data/google/analytics/data_v1beta/services/beta_analytics_data/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.analytics.data_v1beta.types import analytics_data_api from .base import DEFAULT_CLIENT_INFO, BetaAnalyticsDataTransport from .grpc import BetaAnalyticsDataGrpcTransport +try: + from google.api_core import client_logging # 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.analytics.data.v1beta.BetaAnalyticsData", + "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.analytics.data.v1beta.BetaAnalyticsData", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class BetaAnalyticsDataGrpcAsyncIOTransport(BetaAnalyticsDataTransport): """gRPC AsyncIO backend transport for BetaAnalyticsData. @@ -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. @@ -293,7 +378,7 @@ def run_report( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "run_report" not in self._stubs: - self._stubs["run_report"] = self.grpc_channel.unary_unary( + self._stubs["run_report"] = self._logged_channel.unary_unary( "/google.analytics.data.v1beta.BetaAnalyticsData/RunReport", request_serializer=analytics_data_api.RunReportRequest.serialize, response_deserializer=analytics_data_api.RunReportResponse.deserialize, @@ -327,7 +412,7 @@ def run_pivot_report( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "run_pivot_report" not in self._stubs: - self._stubs["run_pivot_report"] = self.grpc_channel.unary_unary( + self._stubs["run_pivot_report"] = self._logged_channel.unary_unary( "/google.analytics.data.v1beta.BetaAnalyticsData/RunPivotReport", request_serializer=analytics_data_api.RunPivotReportRequest.serialize, response_deserializer=analytics_data_api.RunPivotReportResponse.deserialize, @@ -357,7 +442,7 @@ def batch_run_reports( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_run_reports" not in self._stubs: - self._stubs["batch_run_reports"] = self.grpc_channel.unary_unary( + self._stubs["batch_run_reports"] = self._logged_channel.unary_unary( "/google.analytics.data.v1beta.BetaAnalyticsData/BatchRunReports", request_serializer=analytics_data_api.BatchRunReportsRequest.serialize, response_deserializer=analytics_data_api.BatchRunReportsResponse.deserialize, @@ -387,7 +472,7 @@ def batch_run_pivot_reports( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_run_pivot_reports" not in self._stubs: - self._stubs["batch_run_pivot_reports"] = self.grpc_channel.unary_unary( + self._stubs["batch_run_pivot_reports"] = self._logged_channel.unary_unary( "/google.analytics.data.v1beta.BetaAnalyticsData/BatchRunPivotReports", request_serializer=analytics_data_api.BatchRunPivotReportsRequest.serialize, response_deserializer=analytics_data_api.BatchRunPivotReportsResponse.deserialize, @@ -425,7 +510,7 @@ def get_metadata( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_metadata" not in self._stubs: - self._stubs["get_metadata"] = self.grpc_channel.unary_unary( + self._stubs["get_metadata"] = self._logged_channel.unary_unary( "/google.analytics.data.v1beta.BetaAnalyticsData/GetMetadata", request_serializer=analytics_data_api.GetMetadataRequest.serialize, response_deserializer=analytics_data_api.Metadata.deserialize, @@ -463,7 +548,7 @@ def run_realtime_report( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "run_realtime_report" not in self._stubs: - self._stubs["run_realtime_report"] = self.grpc_channel.unary_unary( + self._stubs["run_realtime_report"] = self._logged_channel.unary_unary( "/google.analytics.data.v1beta.BetaAnalyticsData/RunRealtimeReport", request_serializer=analytics_data_api.RunRealtimeReportRequest.serialize, response_deserializer=analytics_data_api.RunRealtimeReportResponse.deserialize, @@ -504,7 +589,7 @@ def check_compatibility( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "check_compatibility" not in self._stubs: - self._stubs["check_compatibility"] = self.grpc_channel.unary_unary( + self._stubs["check_compatibility"] = self._logged_channel.unary_unary( "/google.analytics.data.v1beta.BetaAnalyticsData/CheckCompatibility", request_serializer=analytics_data_api.CheckCompatibilityRequest.serialize, response_deserializer=analytics_data_api.CheckCompatibilityResponse.deserialize, @@ -560,7 +645,7 @@ def create_audience_export( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_audience_export" not in self._stubs: - self._stubs["create_audience_export"] = self.grpc_channel.unary_unary( + self._stubs["create_audience_export"] = self._logged_channel.unary_unary( "/google.analytics.data.v1beta.BetaAnalyticsData/CreateAudienceExport", request_serializer=analytics_data_api.CreateAudienceExportRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -608,7 +693,7 @@ def query_audience_export( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "query_audience_export" not in self._stubs: - self._stubs["query_audience_export"] = self.grpc_channel.unary_unary( + self._stubs["query_audience_export"] = self._logged_channel.unary_unary( "/google.analytics.data.v1beta.BetaAnalyticsData/QueryAudienceExport", request_serializer=analytics_data_api.QueryAudienceExportRequest.serialize, response_deserializer=analytics_data_api.QueryAudienceExportResponse.deserialize, @@ -650,7 +735,7 @@ def get_audience_export( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_audience_export" not in self._stubs: - self._stubs["get_audience_export"] = self.grpc_channel.unary_unary( + self._stubs["get_audience_export"] = self._logged_channel.unary_unary( "/google.analytics.data.v1beta.BetaAnalyticsData/GetAudienceExport", request_serializer=analytics_data_api.GetAudienceExportRequest.serialize, response_deserializer=analytics_data_api.AudienceExport.deserialize, @@ -694,7 +779,7 @@ def list_audience_exports( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_audience_exports" not in self._stubs: - self._stubs["list_audience_exports"] = self.grpc_channel.unary_unary( + self._stubs["list_audience_exports"] = self._logged_channel.unary_unary( "/google.analytics.data.v1beta.BetaAnalyticsData/ListAudienceExports", request_serializer=analytics_data_api.ListAudienceExportsRequest.serialize, response_deserializer=analytics_data_api.ListAudienceExportsResponse.deserialize, @@ -767,7 +852,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-analytics-data/google/analytics/data_v1beta/services/beta_analytics_data/transports/rest.py b/packages/google-analytics-data/google/analytics/data_v1beta/services/beta_analytics_data/transports/rest.py index 9550156a8217..d0802352956b 100644 --- a/packages/google-analytics-data/google/analytics/data_v1beta/services/beta_analytics_data/transports/rest.py +++ b/packages/google-analytics-data/google/analytics/data_v1beta/services/beta_analytics_data/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, @@ -158,9 +166,10 @@ def post_run_report(self, response): def pre_batch_run_pivot_reports( self, request: analytics_data_api.BatchRunPivotReportsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_data_api.BatchRunPivotReportsRequest, Sequence[Tuple[str, str]] + analytics_data_api.BatchRunPivotReportsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for batch_run_pivot_reports @@ -183,8 +192,11 @@ def post_batch_run_pivot_reports( def pre_batch_run_reports( self, request: analytics_data_api.BatchRunReportsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_data_api.BatchRunReportsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_data_api.BatchRunReportsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for batch_run_reports Override in a subclass to manipulate the request or metadata @@ -206,8 +218,11 @@ def post_batch_run_reports( def pre_check_compatibility( self, request: analytics_data_api.CheckCompatibilityRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_data_api.CheckCompatibilityRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_data_api.CheckCompatibilityRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for check_compatibility Override in a subclass to manipulate the request or metadata @@ -229,9 +244,10 @@ def post_check_compatibility( def pre_create_audience_export( self, request: analytics_data_api.CreateAudienceExportRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_data_api.CreateAudienceExportRequest, Sequence[Tuple[str, str]] + analytics_data_api.CreateAudienceExportRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_audience_export @@ -254,8 +270,11 @@ def post_create_audience_export( def pre_get_audience_export( self, request: analytics_data_api.GetAudienceExportRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_data_api.GetAudienceExportRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_data_api.GetAudienceExportRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_audience_export Override in a subclass to manipulate the request or metadata @@ -277,8 +296,10 @@ def post_get_audience_export( def pre_get_metadata( self, request: analytics_data_api.GetMetadataRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_data_api.GetMetadataRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_data_api.GetMetadataRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_metadata Override in a subclass to manipulate the request or metadata @@ -300,9 +321,10 @@ def post_get_metadata( def pre_list_audience_exports( self, request: analytics_data_api.ListAudienceExportsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_data_api.ListAudienceExportsRequest, Sequence[Tuple[str, str]] + analytics_data_api.ListAudienceExportsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_audience_exports @@ -325,9 +347,10 @@ def post_list_audience_exports( def pre_query_audience_export( self, request: analytics_data_api.QueryAudienceExportRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - analytics_data_api.QueryAudienceExportRequest, Sequence[Tuple[str, str]] + analytics_data_api.QueryAudienceExportRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for query_audience_export @@ -350,8 +373,11 @@ def post_query_audience_export( def pre_run_pivot_report( self, request: analytics_data_api.RunPivotReportRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_data_api.RunPivotReportRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_data_api.RunPivotReportRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for run_pivot_report Override in a subclass to manipulate the request or metadata @@ -373,8 +399,11 @@ def post_run_pivot_report( def pre_run_realtime_report( self, request: analytics_data_api.RunRealtimeReportRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_data_api.RunRealtimeReportRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_data_api.RunRealtimeReportRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for run_realtime_report Override in a subclass to manipulate the request or metadata @@ -396,8 +425,10 @@ def post_run_realtime_report( def pre_run_report( self, request: analytics_data_api.RunReportRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[analytics_data_api.RunReportRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + analytics_data_api.RunReportRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for run_report 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]]] = (), ) -> analytics_data_api.BatchRunPivotReportsResponse: r"""Call the batch run pivot reports method over HTTP. @@ -578,8 +609,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_data_api.BatchRunPivotReportsResponse: @@ -591,6 +624,7 @@ def __call__( http_options = ( _BaseBetaAnalyticsDataRestTransport._BaseBatchRunPivotReports._get_http_options() ) + request, metadata = self._interceptor.pre_batch_run_pivot_reports( 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 = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.data_v1beta.BetaAnalyticsDataClient.BatchRunPivotReports", + extra={ + "serviceName": "google.analytics.data.v1beta.BetaAnalyticsData", + "rpcName": "BatchRunPivotReports", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( BetaAnalyticsDataRestTransport._BatchRunPivotReports._get_response( @@ -630,7 +691,33 @@ def __call__( pb_resp = analytics_data_api.BatchRunPivotReportsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_run_pivot_reports(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_data_api.BatchRunPivotReportsResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.data_v1beta.BetaAnalyticsDataClient.batch_run_pivot_reports", + extra={ + "serviceName": "google.analytics.data.v1beta.BetaAnalyticsData", + "rpcName": "BatchRunPivotReports", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchRunReports( @@ -669,7 +756,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.BatchRunReportsResponse: r"""Call the batch run reports method over HTTP. @@ -680,8 +767,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_data_api.BatchRunReportsResponse: @@ -693,6 +782,7 @@ def __call__( http_options = ( _BaseBetaAnalyticsDataRestTransport._BaseBatchRunReports._get_http_options() ) + request, metadata = self._interceptor.pre_batch_run_reports( request, metadata ) @@ -709,6 +799,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.data_v1beta.BetaAnalyticsDataClient.BatchRunReports", + extra={ + "serviceName": "google.analytics.data.v1beta.BetaAnalyticsData", + "rpcName": "BatchRunReports", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BetaAnalyticsDataRestTransport._BatchRunReports._get_response( self._host, @@ -730,7 +847,31 @@ def __call__( pb_resp = analytics_data_api.BatchRunReportsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_run_reports(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_data_api.BatchRunReportsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.data_v1beta.BetaAnalyticsDataClient.batch_run_reports", + extra={ + "serviceName": "google.analytics.data.v1beta.BetaAnalyticsData", + "rpcName": "BatchRunReports", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CheckCompatibility( @@ -769,7 +910,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.CheckCompatibilityResponse: r"""Call the check compatibility method over HTTP. @@ -783,8 +924,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_data_api.CheckCompatibilityResponse: @@ -797,6 +940,7 @@ def __call__( http_options = ( _BaseBetaAnalyticsDataRestTransport._BaseCheckCompatibility._get_http_options() ) + request, metadata = self._interceptor.pre_check_compatibility( request, metadata ) @@ -813,6 +957,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.data_v1beta.BetaAnalyticsDataClient.CheckCompatibility", + extra={ + "serviceName": "google.analytics.data.v1beta.BetaAnalyticsData", + "rpcName": "CheckCompatibility", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BetaAnalyticsDataRestTransport._CheckCompatibility._get_response( self._host, @@ -834,7 +1005,31 @@ def __call__( pb_resp = analytics_data_api.CheckCompatibilityResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_check_compatibility(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_data_api.CheckCompatibilityResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.data_v1beta.BetaAnalyticsDataClient.check_compatibility", + extra={ + "serviceName": "google.analytics.data.v1beta.BetaAnalyticsData", + "rpcName": "CheckCompatibility", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateAudienceExport( @@ -873,7 +1068,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create audience export method over HTTP. @@ -884,8 +1079,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -898,6 +1095,7 @@ def __call__( http_options = ( _BaseBetaAnalyticsDataRestTransport._BaseCreateAudienceExport._get_http_options() ) + request, metadata = self._interceptor.pre_create_audience_export( request, metadata ) @@ -914,6 +1112,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.data_v1beta.BetaAnalyticsDataClient.CreateAudienceExport", + extra={ + "serviceName": "google.analytics.data.v1beta.BetaAnalyticsData", + "rpcName": "CreateAudienceExport", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( BetaAnalyticsDataRestTransport._CreateAudienceExport._get_response( @@ -935,7 +1160,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_audience_export(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.data_v1beta.BetaAnalyticsDataClient.create_audience_export", + extra={ + "serviceName": "google.analytics.data.v1beta.BetaAnalyticsData", + "rpcName": "CreateAudienceExport", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAudienceExport( @@ -973,7 +1220,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.AudienceExport: r"""Call the get audience export method over HTTP. @@ -985,8 +1232,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_data_api.AudienceExport: @@ -1001,6 +1250,7 @@ def __call__( http_options = ( _BaseBetaAnalyticsDataRestTransport._BaseGetAudienceExport._get_http_options() ) + request, metadata = self._interceptor.pre_get_audience_export( request, metadata ) @@ -1013,6 +1263,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.data_v1beta.BetaAnalyticsDataClient.GetAudienceExport", + extra={ + "serviceName": "google.analytics.data.v1beta.BetaAnalyticsData", + "rpcName": "GetAudienceExport", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BetaAnalyticsDataRestTransport._GetAudienceExport._get_response( self._host, @@ -1033,7 +1310,31 @@ def __call__( pb_resp = analytics_data_api.AudienceExport.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_audience_export(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = analytics_data_api.AudienceExport.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.data_v1beta.BetaAnalyticsDataClient.get_audience_export", + extra={ + "serviceName": "google.analytics.data.v1beta.BetaAnalyticsData", + "rpcName": "GetAudienceExport", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetMetadata( @@ -1070,7 +1371,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.Metadata: r"""Call the get metadata method over HTTP. @@ -1081,8 +1382,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_data_api.Metadata: @@ -1095,6 +1398,7 @@ def __call__( http_options = ( _BaseBetaAnalyticsDataRestTransport._BaseGetMetadata._get_http_options() ) + request, metadata = self._interceptor.pre_get_metadata(request, metadata) transcoded_request = _BaseBetaAnalyticsDataRestTransport._BaseGetMetadata._get_transcoded_request( http_options, request @@ -1105,6 +1409,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.data_v1beta.BetaAnalyticsDataClient.GetMetadata", + extra={ + "serviceName": "google.analytics.data.v1beta.BetaAnalyticsData", + "rpcName": "GetMetadata", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BetaAnalyticsDataRestTransport._GetMetadata._get_response( self._host, @@ -1125,7 +1456,29 @@ def __call__( pb_resp = analytics_data_api.Metadata.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_metadata(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = analytics_data_api.Metadata.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.data_v1beta.BetaAnalyticsDataClient.get_metadata", + extra={ + "serviceName": "google.analytics.data.v1beta.BetaAnalyticsData", + "rpcName": "GetMetadata", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAudienceExports( @@ -1163,7 +1516,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.ListAudienceExportsResponse: r"""Call the list audience exports method over HTTP. @@ -1174,8 +1527,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_data_api.ListAudienceExportsResponse: @@ -1187,6 +1542,7 @@ def __call__( http_options = ( _BaseBetaAnalyticsDataRestTransport._BaseListAudienceExports._get_http_options() ) + request, metadata = self._interceptor.pre_list_audience_exports( request, metadata ) @@ -1199,6 +1555,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.data_v1beta.BetaAnalyticsDataClient.ListAudienceExports", + extra={ + "serviceName": "google.analytics.data.v1beta.BetaAnalyticsData", + "rpcName": "ListAudienceExports", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( BetaAnalyticsDataRestTransport._ListAudienceExports._get_response( @@ -1221,7 +1604,31 @@ def __call__( pb_resp = analytics_data_api.ListAudienceExportsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_audience_exports(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_data_api.ListAudienceExportsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.data_v1beta.BetaAnalyticsDataClient.list_audience_exports", + extra={ + "serviceName": "google.analytics.data.v1beta.BetaAnalyticsData", + "rpcName": "ListAudienceExports", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _QueryAudienceExport( @@ -1260,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]]] = (), ) -> analytics_data_api.QueryAudienceExportResponse: r"""Call the query audience export method over HTTP. @@ -1271,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: ~.analytics_data_api.QueryAudienceExportResponse: @@ -1284,6 +1693,7 @@ def __call__( http_options = ( _BaseBetaAnalyticsDataRestTransport._BaseQueryAudienceExport._get_http_options() ) + request, metadata = self._interceptor.pre_query_audience_export( request, metadata ) @@ -1300,6 +1710,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.data_v1beta.BetaAnalyticsDataClient.QueryAudienceExport", + extra={ + "serviceName": "google.analytics.data.v1beta.BetaAnalyticsData", + "rpcName": "QueryAudienceExport", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( BetaAnalyticsDataRestTransport._QueryAudienceExport._get_response( @@ -1323,7 +1760,31 @@ def __call__( pb_resp = analytics_data_api.QueryAudienceExportResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_query_audience_export(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_data_api.QueryAudienceExportResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.data_v1beta.BetaAnalyticsDataClient.query_audience_export", + extra={ + "serviceName": "google.analytics.data.v1beta.BetaAnalyticsData", + "rpcName": "QueryAudienceExport", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RunPivotReport( @@ -1362,7 +1823,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.RunPivotReportResponse: r"""Call the run pivot report method over HTTP. @@ -1373,8 +1834,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_data_api.RunPivotReportResponse: @@ -1386,6 +1849,7 @@ def __call__( http_options = ( _BaseBetaAnalyticsDataRestTransport._BaseRunPivotReport._get_http_options() ) + request, metadata = self._interceptor.pre_run_pivot_report( request, metadata ) @@ -1402,6 +1866,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.data_v1beta.BetaAnalyticsDataClient.RunPivotReport", + extra={ + "serviceName": "google.analytics.data.v1beta.BetaAnalyticsData", + "rpcName": "RunPivotReport", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BetaAnalyticsDataRestTransport._RunPivotReport._get_response( self._host, @@ -1423,7 +1914,31 @@ def __call__( pb_resp = analytics_data_api.RunPivotReportResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_run_pivot_report(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_data_api.RunPivotReportResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.data_v1beta.BetaAnalyticsDataClient.run_pivot_report", + extra={ + "serviceName": "google.analytics.data.v1beta.BetaAnalyticsData", + "rpcName": "RunPivotReport", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RunRealtimeReport( @@ -1462,7 +1977,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.RunRealtimeReportResponse: r"""Call the run realtime report method over HTTP. @@ -1473,8 +1988,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_data_api.RunRealtimeReportResponse: @@ -1486,6 +2003,7 @@ def __call__( http_options = ( _BaseBetaAnalyticsDataRestTransport._BaseRunRealtimeReport._get_http_options() ) + request, metadata = self._interceptor.pre_run_realtime_report( request, metadata ) @@ -1502,6 +2020,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.data_v1beta.BetaAnalyticsDataClient.RunRealtimeReport", + extra={ + "serviceName": "google.analytics.data.v1beta.BetaAnalyticsData", + "rpcName": "RunRealtimeReport", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BetaAnalyticsDataRestTransport._RunRealtimeReport._get_response( self._host, @@ -1523,7 +2068,31 @@ def __call__( pb_resp = analytics_data_api.RunRealtimeReportResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_run_realtime_report(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + analytics_data_api.RunRealtimeReportResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.data_v1beta.BetaAnalyticsDataClient.run_realtime_report", + extra={ + "serviceName": "google.analytics.data.v1beta.BetaAnalyticsData", + "rpcName": "RunRealtimeReport", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RunReport( @@ -1561,7 +2130,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analytics_data_api.RunReportResponse: r"""Call the run report method over HTTP. @@ -1571,8 +2140,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.analytics_data_api.RunReportResponse: @@ -1584,6 +2155,7 @@ def __call__( http_options = ( _BaseBetaAnalyticsDataRestTransport._BaseRunReport._get_http_options() ) + request, metadata = self._interceptor.pre_run_report(request, metadata) transcoded_request = _BaseBetaAnalyticsDataRestTransport._BaseRunReport._get_transcoded_request( http_options, request @@ -1598,6 +2170,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.analytics.data_v1beta.BetaAnalyticsDataClient.RunReport", + extra={ + "serviceName": "google.analytics.data.v1beta.BetaAnalyticsData", + "rpcName": "RunReport", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BetaAnalyticsDataRestTransport._RunReport._get_response( self._host, @@ -1619,7 +2218,31 @@ def __call__( pb_resp = analytics_data_api.RunReportResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_run_report(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = analytics_data_api.RunReportResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.analytics.data_v1beta.BetaAnalyticsDataClient.run_report", + extra={ + "serviceName": "google.analytics.data.v1beta.BetaAnalyticsData", + "rpcName": "RunReport", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-analytics-data/samples/generated_samples/snippet_metadata_google.analytics.data.v1alpha.json b/packages/google-analytics-data/samples/generated_samples/snippet_metadata_google.analytics.data.v1alpha.json index 15f8d0d6e6d8..102d88b3e1e4 100644 --- a/packages/google-analytics-data/samples/generated_samples/snippet_metadata_google.analytics.data.v1alpha.json +++ b/packages/google-analytics-data/samples/generated_samples/snippet_metadata_google.analytics.data.v1alpha.json @@ -51,7 +51,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -220,7 +220,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1alpha.types.RecurringAudienceList", @@ -304,7 +304,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1alpha.types.RecurringAudienceList", @@ -389,7 +389,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -473,7 +473,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -554,7 +554,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1alpha.types.AudienceList", @@ -634,7 +634,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1alpha.types.AudienceList", @@ -715,7 +715,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1alpha.types.PropertyQuotasSnapshot", @@ -795,7 +795,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1alpha.types.PropertyQuotasSnapshot", @@ -876,7 +876,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1alpha.types.RecurringAudienceList", @@ -956,7 +956,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1alpha.types.RecurringAudienceList", @@ -1037,7 +1037,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1alpha.types.ReportTask", @@ -1117,7 +1117,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1alpha.types.ReportTask", @@ -1198,7 +1198,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1alpha.services.alpha_analytics_data.pagers.ListAudienceListsAsyncPager", @@ -1278,7 +1278,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1alpha.services.alpha_analytics_data.pagers.ListAudienceListsPager", @@ -1359,7 +1359,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1alpha.services.alpha_analytics_data.pagers.ListRecurringAudienceListsAsyncPager", @@ -1439,7 +1439,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1alpha.services.alpha_analytics_data.pagers.ListRecurringAudienceListsPager", @@ -1520,7 +1520,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1alpha.services.alpha_analytics_data.pagers.ListReportTasksAsyncPager", @@ -1600,7 +1600,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1alpha.services.alpha_analytics_data.pagers.ListReportTasksPager", @@ -1681,7 +1681,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1alpha.types.QueryAudienceListResponse", @@ -1761,7 +1761,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1alpha.types.QueryAudienceListResponse", @@ -1842,7 +1842,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1alpha.types.QueryReportTaskResponse", @@ -1922,7 +1922,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1alpha.types.QueryReportTaskResponse", @@ -1999,7 +1999,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1alpha.types.RunFunnelReportResponse", @@ -2075,7 +2075,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1alpha.types.RunFunnelReportResponse", @@ -2156,7 +2156,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1alpha.types.SheetExportAudienceListResponse", @@ -2236,7 +2236,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1alpha.types.SheetExportAudienceListResponse", diff --git a/packages/google-analytics-data/samples/generated_samples/snippet_metadata_google.analytics.data.v1beta.json b/packages/google-analytics-data/samples/generated_samples/snippet_metadata_google.analytics.data.v1beta.json index 29e86a085403..0da1d46ae49b 100644 --- a/packages/google-analytics-data/samples/generated_samples/snippet_metadata_google.analytics.data.v1beta.json +++ b/packages/google-analytics-data/samples/generated_samples/snippet_metadata_google.analytics.data.v1beta.json @@ -43,7 +43,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1beta.types.BatchRunPivotReportsResponse", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1beta.types.BatchRunPivotReportsResponse", @@ -196,7 +196,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1beta.types.BatchRunReportsResponse", @@ -272,7 +272,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1beta.types.BatchRunReportsResponse", @@ -349,7 +349,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1beta.types.CheckCompatibilityResponse", @@ -425,7 +425,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1beta.types.CheckCompatibilityResponse", @@ -510,7 +510,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -594,7 +594,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -675,7 +675,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1beta.types.AudienceExport", @@ -755,7 +755,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1beta.types.AudienceExport", @@ -836,7 +836,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1beta.types.Metadata", @@ -916,7 +916,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1beta.types.Metadata", @@ -997,7 +997,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1beta.services.beta_analytics_data.pagers.ListAudienceExportsAsyncPager", @@ -1077,7 +1077,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1beta.services.beta_analytics_data.pagers.ListAudienceExportsPager", @@ -1158,7 +1158,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1beta.types.QueryAudienceExportResponse", @@ -1238,7 +1238,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1beta.types.QueryAudienceExportResponse", @@ -1315,7 +1315,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1beta.types.RunPivotReportResponse", @@ -1391,7 +1391,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1beta.types.RunPivotReportResponse", @@ -1468,7 +1468,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1beta.types.RunRealtimeReportResponse", @@ -1544,7 +1544,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1beta.types.RunRealtimeReportResponse", @@ -1621,7 +1621,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1beta.types.RunReportResponse", @@ -1697,7 +1697,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.analytics.data_v1beta.types.RunReportResponse", diff --git a/packages/google-analytics-data/tests/unit/gapic/data_v1alpha/test_alpha_analytics_data.py b/packages/google-analytics-data/tests/unit/gapic/data_v1alpha/test_alpha_analytics_data.py index 3a749b3210c1..fb3ad3b3bf7b 100644 --- a/packages/google-analytics-data/tests/unit/gapic/data_v1alpha/test_alpha_analytics_data.py +++ b/packages/google-analytics-data/tests/unit/gapic/data_v1alpha/test_alpha_analytics_data.py @@ -6683,6 +6683,7 @@ def test_create_audience_list_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_audience_list(request) @@ -6735,6 +6736,7 @@ def test_create_audience_list_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_audience_list(**mock_args) @@ -6871,6 +6873,7 @@ def test_query_audience_list_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.query_audience_list(request) @@ -6916,6 +6919,7 @@ def test_query_audience_list_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.query_audience_list(**mock_args) @@ -7055,6 +7059,7 @@ def test_sheet_export_audience_list_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.sheet_export_audience_list(request) @@ -7102,6 +7107,7 @@ def test_sheet_export_audience_list_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.sheet_export_audience_list(**mock_args) @@ -7235,6 +7241,7 @@ def test_get_audience_list_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_audience_list(request) @@ -7280,6 +7287,7 @@ def test_get_audience_list_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_audience_list(**mock_args) @@ -7421,6 +7429,7 @@ def test_list_audience_lists_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_audience_lists(request) @@ -7474,6 +7483,7 @@ def test_list_audience_lists_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_audience_lists(**mock_args) @@ -7673,6 +7683,7 @@ def test_create_recurring_audience_list_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_recurring_audience_list(request) @@ -7731,6 +7742,7 @@ def test_create_recurring_audience_list_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_recurring_audience_list(**mock_args) @@ -7870,6 +7882,7 @@ def test_get_recurring_audience_list_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_recurring_audience_list(request) @@ -7915,6 +7928,7 @@ def test_get_recurring_audience_list_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_recurring_audience_list(**mock_args) @@ -8060,6 +8074,7 @@ def test_list_recurring_audience_lists_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_recurring_audience_lists(request) @@ -8117,6 +8132,7 @@ def test_list_recurring_audience_lists_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_recurring_audience_lists(**mock_args) @@ -8319,6 +8335,7 @@ def test_get_property_quotas_snapshot_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_property_quotas_snapshot(request) @@ -8364,6 +8381,7 @@ def test_get_property_quotas_snapshot_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_property_quotas_snapshot(**mock_args) @@ -8501,6 +8519,7 @@ def test_create_report_task_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_report_task(request) @@ -8553,6 +8572,7 @@ def test_create_report_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_report_task(**mock_args) @@ -8687,6 +8707,7 @@ def test_query_report_task_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.query_report_task(request) @@ -8732,6 +8753,7 @@ def test_query_report_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.query_report_task(**mock_args) @@ -8863,6 +8885,7 @@ def test_get_report_task_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_report_task(request) @@ -8908,6 +8931,7 @@ def test_get_report_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_report_task(**mock_args) @@ -9047,6 +9071,7 @@ def test_list_report_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.list_report_tasks(request) @@ -9100,6 +9125,7 @@ def test_list_report_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_report_tasks(**mock_args) @@ -10077,6 +10103,7 @@ def test_run_funnel_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.run_funnel_report(request) @@ -10112,6 +10139,7 @@ def test_run_funnel_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.run_funnel_report(request) # Establish that the response is the type that we expect. @@ -10152,6 +10180,7 @@ def test_run_funnel_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 = analytics_data_api.RunFunnelReportResponse.to_json( analytics_data_api.RunFunnelReportResponse() ) @@ -10198,6 +10227,7 @@ def test_create_audience_list_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_audience_list(request) @@ -10314,6 +10344,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_audience_list(request) # Establish that the response is the type that we expect. @@ -10355,6 +10386,7 @@ def test_create_audience_list_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -10399,6 +10431,7 @@ def test_query_audience_list_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.query_audience_list(request) @@ -10434,6 +10467,7 @@ def test_query_audience_list_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.query_audience_list(request) # Establish that the response is the type that we expect. @@ -10474,6 +10508,7 @@ def test_query_audience_list_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_data_api.QueryAudienceListResponse.to_json( analytics_data_api.QueryAudienceListResponse() ) @@ -10520,6 +10555,7 @@ def test_sheet_export_audience_list_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.sheet_export_audience_list(request) @@ -10559,6 +10595,7 @@ def test_sheet_export_audience_list_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.sheet_export_audience_list(request) # Establish that the response is the type that we expect. @@ -10601,6 +10638,7 @@ def test_sheet_export_audience_list_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_data_api.SheetExportAudienceListResponse.to_json( analytics_data_api.SheetExportAudienceListResponse() ) @@ -10647,6 +10685,7 @@ def test_get_audience_list_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_audience_list(request) @@ -10690,6 +10729,7 @@ def test_get_audience_list_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_audience_list(request) # Establish that the response is the type that we expect. @@ -10738,6 +10778,7 @@ def test_get_audience_list_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_data_api.AudienceList.to_json( analytics_data_api.AudienceList() ) @@ -10784,6 +10825,7 @@ def test_list_audience_lists_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_audience_lists(request) @@ -10819,6 +10861,7 @@ def test_list_audience_lists_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_audience_lists(request) # Establish that the response is the type that we expect. @@ -10859,6 +10902,7 @@ def test_list_audience_lists_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_data_api.ListAudienceListsResponse.to_json( analytics_data_api.ListAudienceListsResponse() ) @@ -10905,6 +10949,7 @@ def test_create_recurring_audience_list_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_recurring_audience_list(request) @@ -11027,6 +11072,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_recurring_audience_list(request) # Establish that the response is the type that we expect. @@ -11073,6 +11119,7 @@ def test_create_recurring_audience_list_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_data_api.RecurringAudienceList.to_json( analytics_data_api.RecurringAudienceList() ) @@ -11119,6 +11166,7 @@ def test_get_recurring_audience_list_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_recurring_audience_list(request) @@ -11158,6 +11206,7 @@ def test_get_recurring_audience_list_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_recurring_audience_list(request) # Establish that the response is the type that we expect. @@ -11202,6 +11251,7 @@ def test_get_recurring_audience_list_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_data_api.RecurringAudienceList.to_json( analytics_data_api.RecurringAudienceList() ) @@ -11248,6 +11298,7 @@ def test_list_recurring_audience_lists_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_recurring_audience_lists(request) @@ -11285,6 +11336,7 @@ def test_list_recurring_audience_lists_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_recurring_audience_lists(request) # Establish that the response is the type that we expect. @@ -11327,6 +11379,7 @@ def test_list_recurring_audience_lists_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_data_api.ListRecurringAudienceListsResponse.to_json( analytics_data_api.ListRecurringAudienceListsResponse() ) @@ -11373,6 +11426,7 @@ def test_get_property_quotas_snapshot_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_property_quotas_snapshot(request) @@ -11408,6 +11462,7 @@ def test_get_property_quotas_snapshot_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_property_quotas_snapshot(request) # Establish that the response is the type that we expect. @@ -11449,6 +11504,7 @@ def test_get_property_quotas_snapshot_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_data_api.PropertyQuotasSnapshot.to_json( analytics_data_api.PropertyQuotasSnapshot() ) @@ -11495,6 +11551,7 @@ def test_create_report_task_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_report_task(request) @@ -11693,6 +11750,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_report_task(request) # Establish that the response is the type that we expect. @@ -11734,6 +11792,7 @@ def test_create_report_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -11778,6 +11837,7 @@ def test_query_report_task_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.query_report_task(request) @@ -11813,6 +11873,7 @@ def test_query_report_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.query_report_task(request) # Establish that the response is the type that we expect. @@ -11853,6 +11914,7 @@ def test_query_report_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 = analytics_data_api.QueryReportTaskResponse.to_json( analytics_data_api.QueryReportTaskResponse() ) @@ -11899,6 +11961,7 @@ def test_get_report_task_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_report_task(request) @@ -11934,6 +11997,7 @@ def test_get_report_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_report_task(request) # Establish that the response is the type that we expect. @@ -11974,6 +12038,7 @@ def test_get_report_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 = analytics_data_api.ReportTask.to_json( analytics_data_api.ReportTask() ) @@ -12020,6 +12085,7 @@ def test_list_report_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.list_report_tasks(request) @@ -12055,6 +12121,7 @@ def test_list_report_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_report_tasks(request) # Establish that the response is the type that we expect. @@ -12095,6 +12162,7 @@ def test_list_report_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 = analytics_data_api.ListReportTasksResponse.to_json( analytics_data_api.ListReportTasksResponse() ) diff --git a/packages/google-analytics-data/tests/unit/gapic/data_v1beta/test_beta_analytics_data.py b/packages/google-analytics-data/tests/unit/gapic/data_v1beta/test_beta_analytics_data.py index c32d40baa2b6..0f74b9eed126 100644 --- a/packages/google-analytics-data/tests/unit/gapic/data_v1beta/test_beta_analytics_data.py +++ b/packages/google-analytics-data/tests/unit/gapic/data_v1beta/test_beta_analytics_data.py @@ -4819,6 +4819,7 @@ def test_get_metadata_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_metadata(request) @@ -4864,6 +4865,7 @@ def test_get_metadata_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_metadata(**mock_args) @@ -5080,6 +5082,7 @@ def test_create_audience_export_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_audience_export(request) @@ -5132,6 +5135,7 @@ def test_create_audience_export_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_audience_export(**mock_args) @@ -5271,6 +5275,7 @@ def test_query_audience_export_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.query_audience_export(request) @@ -5316,6 +5321,7 @@ def test_query_audience_export_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.query_audience_export(**mock_args) @@ -5451,6 +5457,7 @@ def test_get_audience_export_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_audience_export(request) @@ -5496,6 +5503,7 @@ def test_get_audience_export_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_audience_export(**mock_args) @@ -5640,6 +5648,7 @@ def test_list_audience_exports_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_audience_exports(request) @@ -5693,6 +5702,7 @@ def test_list_audience_exports_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_audience_exports(**mock_args) @@ -6495,6 +6505,7 @@ def test_run_report_rest_bad_request(request_type=analytics_data_api.RunReportRe response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.run_report(request) @@ -6531,6 +6542,7 @@ def test_run_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.run_report(request) # Establish that the response is the type that we expect. @@ -6572,6 +6584,7 @@ def test_run_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 = analytics_data_api.RunReportResponse.to_json( analytics_data_api.RunReportResponse() ) @@ -6618,6 +6631,7 @@ def test_run_pivot_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.run_pivot_report(request) @@ -6653,6 +6667,7 @@ def test_run_pivot_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.run_pivot_report(request) # Establish that the response is the type that we expect. @@ -6693,6 +6708,7 @@ def test_run_pivot_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 = analytics_data_api.RunPivotReportResponse.to_json( analytics_data_api.RunPivotReportResponse() ) @@ -6739,6 +6755,7 @@ def test_batch_run_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.batch_run_reports(request) @@ -6774,6 +6791,7 @@ def test_batch_run_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.batch_run_reports(request) # Establish that the response is the type that we expect. @@ -6814,6 +6832,7 @@ def test_batch_run_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 = analytics_data_api.BatchRunReportsResponse.to_json( analytics_data_api.BatchRunReportsResponse() ) @@ -6860,6 +6879,7 @@ def test_batch_run_pivot_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.batch_run_pivot_reports(request) @@ -6895,6 +6915,7 @@ def test_batch_run_pivot_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.batch_run_pivot_reports(request) # Establish that the response is the type that we expect. @@ -6935,6 +6956,7 @@ def test_batch_run_pivot_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 = analytics_data_api.BatchRunPivotReportsResponse.to_json( analytics_data_api.BatchRunPivotReportsResponse() ) @@ -6981,6 +7003,7 @@ def test_get_metadata_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_metadata(request) @@ -7016,6 +7039,7 @@ def test_get_metadata_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_metadata(request) # Establish that the response is the type that we expect. @@ -7056,6 +7080,7 @@ def test_get_metadata_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_data_api.Metadata.to_json( analytics_data_api.Metadata() ) @@ -7102,6 +7127,7 @@ def test_run_realtime_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.run_realtime_report(request) @@ -7138,6 +7164,7 @@ def test_run_realtime_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.run_realtime_report(request) # Establish that the response is the type that we expect. @@ -7179,6 +7206,7 @@ def test_run_realtime_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 = analytics_data_api.RunRealtimeReportResponse.to_json( analytics_data_api.RunRealtimeReportResponse() ) @@ -7225,6 +7253,7 @@ def test_check_compatibility_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.check_compatibility(request) @@ -7258,6 +7287,7 @@ def test_check_compatibility_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.check_compatibility(request) # Establish that the response is the type that we expect. @@ -7297,6 +7327,7 @@ def test_check_compatibility_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_data_api.CheckCompatibilityResponse.to_json( analytics_data_api.CheckCompatibilityResponse() ) @@ -7343,6 +7374,7 @@ def test_create_audience_export_rest_bad_request( response_value.status_code = 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_audience_export(request) @@ -7454,6 +7486,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_audience_export(request) # Establish that the response is the type that we expect. @@ -7495,6 +7528,7 @@ def test_create_audience_export_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -7539,6 +7573,7 @@ def test_query_audience_export_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.query_audience_export(request) @@ -7574,6 +7609,7 @@ def test_query_audience_export_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.query_audience_export(request) # Establish that the response is the type that we expect. @@ -7614,6 +7650,7 @@ def test_query_audience_export_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_data_api.QueryAudienceExportResponse.to_json( analytics_data_api.QueryAudienceExportResponse() ) @@ -7660,6 +7697,7 @@ def test_get_audience_export_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_audience_export(request) @@ -7702,6 +7740,7 @@ def test_get_audience_export_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_audience_export(request) # Establish that the response is the type that we expect. @@ -7749,6 +7788,7 @@ def test_get_audience_export_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_data_api.AudienceExport.to_json( analytics_data_api.AudienceExport() ) @@ -7795,6 +7835,7 @@ def test_list_audience_exports_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_audience_exports(request) @@ -7830,6 +7871,7 @@ def test_list_audience_exports_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_audience_exports(request) # Establish that the response is the type that we expect. @@ -7870,6 +7912,7 @@ def test_list_audience_exports_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = analytics_data_api.ListAudienceExportsResponse.to_json( analytics_data_api.ListAudienceExportsResponse() ) diff --git a/packages/google-apps-meet/google/apps/meet/gapic_version.py b/packages/google-apps-meet/google/apps/meet/gapic_version.py index 9413c3341313..558c8aab67c5 100644 --- a/packages/google-apps-meet/google/apps/meet/gapic_version.py +++ b/packages/google-apps-meet/google/apps/meet/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.10" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-apps-meet/google/apps/meet_v2/gapic_version.py b/packages/google-apps-meet/google/apps/meet_v2/gapic_version.py index 9413c3341313..558c8aab67c5 100644 --- a/packages/google-apps-meet/google/apps/meet_v2/gapic_version.py +++ b/packages/google-apps-meet/google/apps/meet_v2/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.10" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-apps-meet/google/apps/meet_v2/services/conference_records_service/async_client.py b/packages/google-apps-meet/google/apps/meet_v2/services/conference_records_service/async_client.py index d1eeabee1a10..e16d5f4e5016 100644 --- a/packages/google-apps-meet/google/apps/meet_v2/services/conference_records_service/async_client.py +++ b/packages/google-apps-meet/google/apps/meet_v2/services/conference_records_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, ConferenceRecordsServiceTransport from .transports.grpc_asyncio import ConferenceRecordsServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class ConferenceRecordsServiceAsyncClient: """REST API for services dealing with conference records.""" @@ -296,6 +306,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.apps.meet_v2.ConferenceRecordsServiceAsyncClient`.", + extra={ + "serviceName": "google.apps.meet.v2.ConferenceRecordsService", + "universeDomain": getattr( + self._client._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._client._transport._credentials).__module__}.{type(self._client._transport._credentials).__qualname__}", + "credentialsInfo": getattr( + self.transport._credentials, "get_cred_info", lambda: None + )(), + } + if hasattr(self._client._transport, "_credentials") + else { + "serviceName": "google.apps.meet.v2.ConferenceRecordsService", + "credentialsType": None, + }, + ) + async def get_conference_record( self, request: Optional[Union[service.GetConferenceRecordRequest, dict]] = None, @@ -303,7 +335,7 @@ async def get_conference_record( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.ConferenceRecord: r"""Gets a conference record by conference ID. @@ -346,8 +378,10 @@ async def sample_get_conference_record(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2.types.ConferenceRecord: @@ -407,7 +441,7 @@ async def list_conference_records( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListConferenceRecordsAsyncPager: r"""Lists the conference records. By default, ordered by start time and in descending order. @@ -445,8 +479,10 @@ async def sample_list_conference_records(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2.services.conference_records_service.pagers.ListConferenceRecordsAsyncPager: @@ -501,7 +537,7 @@ async def get_participant( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.Participant: r"""Gets a participant by participant ID. @@ -544,8 +580,10 @@ async def sample_get_participant(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2.types.Participant: @@ -606,7 +644,7 @@ async def list_participants( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListParticipantsAsyncPager: r"""Lists the participants in a conference record. By default, ordered by join time and in descending order. This API supports @@ -655,8 +693,10 @@ async def sample_list_participants(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2.services.conference_records_service.pagers.ListParticipantsAsyncPager: @@ -731,7 +771,7 @@ async def get_participant_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]]] = (), ) -> resource.ParticipantSession: r"""Gets a participant session by participant session ID. @@ -774,8 +814,10 @@ async def sample_get_participant_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.apps.meet_v2.types.ParticipantSession: @@ -843,7 +885,7 @@ async def list_participant_sessions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListParticipantSessionsAsyncPager: r"""Lists the participant sessions of a participant in a conference record. By default, ordered by join time and in descending @@ -894,8 +936,10 @@ async def sample_list_participant_sessions(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2.services.conference_records_service.pagers.ListParticipantSessionsAsyncPager: @@ -970,7 +1014,7 @@ async def get_recording( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.Recording: r"""Gets a recording by recording ID. @@ -1014,8 +1058,10 @@ async def sample_get_recording(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2.types.Recording: @@ -1076,7 +1122,7 @@ async def list_recordings( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListRecordingsAsyncPager: r"""Lists the recording resources from the conference record. By default, ordered by start time and in @@ -1122,8 +1168,10 @@ async def sample_list_recordings(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2.services.conference_records_service.pagers.ListRecordingsAsyncPager: @@ -1198,7 +1246,7 @@ async def get_transcript( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.Transcript: r"""Gets a transcript by transcript ID. @@ -1241,8 +1289,10 @@ async def sample_get_transcript(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2.types.Transcript: @@ -1305,7 +1355,7 @@ async def list_transcripts( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTranscriptsAsyncPager: r"""Lists the set of transcripts from the conference record. By default, ordered by start time and in @@ -1351,8 +1401,10 @@ async def sample_list_transcripts(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2.services.conference_records_service.pagers.ListTranscriptsAsyncPager: @@ -1427,7 +1479,7 @@ async def get_transcript_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]]] = (), ) -> resource.TranscriptEntry: r"""Gets a ``TranscriptEntry`` resource by entry ID. @@ -1474,8 +1526,10 @@ async def sample_get_transcript_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.apps.meet_v2.types.TranscriptEntry: @@ -1536,7 +1590,7 @@ async def list_transcript_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.ListTranscriptEntriesAsyncPager: r"""Lists the structured transcript entries per transcript. By default, ordered by start time and in @@ -1589,8 +1643,10 @@ async def sample_list_transcript_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.apps.meet_v2.services.conference_records_service.pagers.ListTranscriptEntriesAsyncPager: diff --git a/packages/google-apps-meet/google/apps/meet_v2/services/conference_records_service/client.py b/packages/google-apps-meet/google/apps/meet_v2/services/conference_records_service/client.py index 55f1e5855eab..35bd560991ad 100644 --- a/packages/google-apps-meet/google/apps/meet_v2/services/conference_records_service/client.py +++ b/packages/google-apps-meet/google/apps/meet_v2/services/conference_records_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.apps.meet_v2.services.conference_records_service import pagers @@ -702,6 +712,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( @@ -768,6 +782,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.apps.meet_v2.ConferenceRecordsServiceClient`.", + extra={ + "serviceName": "google.apps.meet.v2.ConferenceRecordsService", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__module__}.{type(self._transport._credentials).__qualname__}", + "credentialsInfo": getattr( + self.transport._credentials, "get_cred_info", lambda: None + )(), + } + if hasattr(self._transport, "_credentials") + else { + "serviceName": "google.apps.meet.v2.ConferenceRecordsService", + "credentialsType": None, + }, + ) + def get_conference_record( self, request: Optional[Union[service.GetConferenceRecordRequest, dict]] = None, @@ -775,7 +812,7 @@ def get_conference_record( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.ConferenceRecord: r"""Gets a conference record by conference ID. @@ -818,8 +855,10 @@ def sample_get_conference_record(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2.types.ConferenceRecord: @@ -876,7 +915,7 @@ def list_conference_records( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListConferenceRecordsPager: r"""Lists the conference records. By default, ordered by start time and in descending order. @@ -914,8 +953,10 @@ def sample_list_conference_records(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2.services.conference_records_service.pagers.ListConferenceRecordsPager: @@ -968,7 +1009,7 @@ def get_participant( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.Participant: r"""Gets a participant by participant ID. @@ -1011,8 +1052,10 @@ def sample_get_participant(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2.types.Participant: @@ -1070,7 +1113,7 @@ def list_participants( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListParticipantsPager: r"""Lists the participants in a conference record. By default, ordered by join time and in descending order. This API supports @@ -1119,8 +1162,10 @@ def sample_list_participants(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2.services.conference_records_service.pagers.ListParticipantsPager: @@ -1192,7 +1237,7 @@ def get_participant_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]]] = (), ) -> resource.ParticipantSession: r"""Gets a participant session by participant session ID. @@ -1235,8 +1280,10 @@ def sample_get_participant_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.apps.meet_v2.types.ParticipantSession: @@ -1301,7 +1348,7 @@ def list_participant_sessions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListParticipantSessionsPager: r"""Lists the participant sessions of a participant in a conference record. By default, ordered by join time and in descending @@ -1352,8 +1399,10 @@ def sample_list_participant_sessions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2.services.conference_records_service.pagers.ListParticipantSessionsPager: @@ -1427,7 +1476,7 @@ def get_recording( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.Recording: r"""Gets a recording by recording ID. @@ -1471,8 +1520,10 @@ def sample_get_recording(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2.types.Recording: @@ -1530,7 +1581,7 @@ def list_recordings( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListRecordingsPager: r"""Lists the recording resources from the conference record. By default, ordered by start time and in @@ -1576,8 +1627,10 @@ def sample_list_recordings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2.services.conference_records_service.pagers.ListRecordingsPager: @@ -1649,7 +1702,7 @@ def get_transcript( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.Transcript: r"""Gets a transcript by transcript ID. @@ -1692,8 +1745,10 @@ def sample_get_transcript(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2.types.Transcript: @@ -1753,7 +1808,7 @@ def list_transcripts( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTranscriptsPager: r"""Lists the set of transcripts from the conference record. By default, ordered by start time and in @@ -1799,8 +1854,10 @@ def sample_list_transcripts(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2.services.conference_records_service.pagers.ListTranscriptsPager: @@ -1872,7 +1929,7 @@ def get_transcript_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]]] = (), ) -> resource.TranscriptEntry: r"""Gets a ``TranscriptEntry`` resource by entry ID. @@ -1919,8 +1976,10 @@ def sample_get_transcript_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.apps.meet_v2.types.TranscriptEntry: @@ -1978,7 +2037,7 @@ def list_transcript_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.ListTranscriptEntriesPager: r"""Lists the structured transcript entries per transcript. By default, ordered by start time and in @@ -2031,8 +2090,10 @@ def sample_list_transcript_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.apps.meet_v2.services.conference_records_service.pagers.ListTranscriptEntriesPager: diff --git a/packages/google-apps-meet/google/apps/meet_v2/services/conference_records_service/pagers.py b/packages/google-apps-meet/google/apps/meet_v2/services/conference_records_service/pagers.py index 2af1b6029038..62194fe86bfc 100644 --- a/packages/google-apps-meet/google/apps/meet_v2/services/conference_records_service/pagers.py +++ b/packages/google-apps-meet/google/apps/meet_v2/services/conference_records_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.ListConferenceRecordsRequest(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.ListConferenceRecordsRequest(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.ListParticipantsRequest(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.ListParticipantsRequest(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.ListParticipantSessionsRequest(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.ListParticipantSessionsRequest(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.ListRecordingsRequest(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.ListRecordingsRequest(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.ListTranscriptsRequest(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.ListTranscriptsRequest(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 = service.ListTranscriptEntriesRequest(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 = service.ListTranscriptEntriesRequest(request) diff --git a/packages/google-apps-meet/google/apps/meet_v2/services/conference_records_service/transports/grpc.py b/packages/google-apps-meet/google/apps/meet_v2/services/conference_records_service/transports/grpc.py index ba28204d6484..66178387f91a 100644 --- a/packages/google-apps-meet/google/apps/meet_v2/services/conference_records_service/transports/grpc.py +++ b/packages/google-apps-meet/google/apps/meet_v2/services/conference_records_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.apps.meet_v2.types import resource, service from .base import DEFAULT_CLIENT_INFO, ConferenceRecordsServiceTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + + +class _LoggingClientInterceptor(grpc.UnaryUnaryClientInterceptor): # pragma: NO COVER + def intercept_unary_unary(self, continuation, client_call_details, request): + logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ) + if logging_enabled: # pragma: NO COVER + request_metadata = client_call_details.metadata + if isinstance(request, proto.Message): + request_payload = type(request).to_json(request) + elif isinstance(request, google.protobuf.message.Message): + request_payload = MessageToJson(request) + else: + request_payload = f"{type(request).__name__}: {pickle.dumps(request)}" + + request_metadata = { + key: value.decode("utf-8") if isinstance(value, bytes) else value + for key, value in request_metadata + } + grpc_request = { + "payload": request_payload, + "requestMethod": "grpc", + "metadata": dict(request_metadata), + } + _LOGGER.debug( + f"Sending request for {client_call_details.method}", + extra={ + "serviceName": "google.apps.meet.v2.ConferenceRecordsService", + "rpcName": client_call_details.method, + "request": grpc_request, + "metadata": grpc_request["metadata"], + }, + ) + + response = continuation(client_call_details, request) + if logging_enabled: # pragma: NO COVER + response_metadata = response.trailing_metadata() + # Convert gRPC metadata `` to list of tuples + metadata = ( + dict([(k, str(v)) for k, v in response_metadata]) + if response_metadata + else None + ) + result = response.result() + if isinstance(result, proto.Message): + response_payload = type(result).to_json(result) + elif isinstance(result, google.protobuf.message.Message): + response_payload = MessageToJson(result) + else: + response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" + grpc_response = { + "payload": response_payload, + "metadata": metadata, + "status": "OK", + } + _LOGGER.debug( + f"Received response for {client_call_details.method}.", + extra={ + "serviceName": "google.apps.meet.v2.ConferenceRecordsService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ConferenceRecordsServiceGrpcTransport(ConferenceRecordsServiceTransport): """gRPC backend transport for ConferenceRecordsService. @@ -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 @@ -253,7 +339,7 @@ def get_conference_record( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_conference_record" not in self._stubs: - self._stubs["get_conference_record"] = self.grpc_channel.unary_unary( + self._stubs["get_conference_record"] = self._logged_channel.unary_unary( "/google.apps.meet.v2.ConferenceRecordsService/GetConferenceRecord", request_serializer=service.GetConferenceRecordRequest.serialize, response_deserializer=resource.ConferenceRecord.deserialize, @@ -282,7 +368,7 @@ def list_conference_records( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_conference_records" not in self._stubs: - self._stubs["list_conference_records"] = self.grpc_channel.unary_unary( + self._stubs["list_conference_records"] = self._logged_channel.unary_unary( "/google.apps.meet.v2.ConferenceRecordsService/ListConferenceRecords", request_serializer=service.ListConferenceRecordsRequest.serialize, response_deserializer=service.ListConferenceRecordsResponse.deserialize, @@ -308,7 +394,7 @@ def get_participant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_participant" not in self._stubs: - self._stubs["get_participant"] = self.grpc_channel.unary_unary( + self._stubs["get_participant"] = self._logged_channel.unary_unary( "/google.apps.meet.v2.ConferenceRecordsService/GetParticipant", request_serializer=service.GetParticipantRequest.serialize, response_deserializer=resource.Participant.deserialize, @@ -338,7 +424,7 @@ def list_participants( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_participants" not in self._stubs: - self._stubs["list_participants"] = self.grpc_channel.unary_unary( + self._stubs["list_participants"] = self._logged_channel.unary_unary( "/google.apps.meet.v2.ConferenceRecordsService/ListParticipants", request_serializer=service.ListParticipantsRequest.serialize, response_deserializer=service.ListParticipantsResponse.deserialize, @@ -364,7 +450,7 @@ def get_participant_session( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_participant_session" not in self._stubs: - self._stubs["get_participant_session"] = self.grpc_channel.unary_unary( + self._stubs["get_participant_session"] = self._logged_channel.unary_unary( "/google.apps.meet.v2.ConferenceRecordsService/GetParticipantSession", request_serializer=service.GetParticipantSessionRequest.serialize, response_deserializer=resource.ParticipantSession.deserialize, @@ -398,7 +484,7 @@ def list_participant_sessions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_participant_sessions" not in self._stubs: - self._stubs["list_participant_sessions"] = self.grpc_channel.unary_unary( + self._stubs["list_participant_sessions"] = self._logged_channel.unary_unary( "/google.apps.meet.v2.ConferenceRecordsService/ListParticipantSessions", request_serializer=service.ListParticipantSessionsRequest.serialize, response_deserializer=service.ListParticipantSessionsResponse.deserialize, @@ -424,7 +510,7 @@ def get_recording( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_recording" not in self._stubs: - self._stubs["get_recording"] = self.grpc_channel.unary_unary( + self._stubs["get_recording"] = self._logged_channel.unary_unary( "/google.apps.meet.v2.ConferenceRecordsService/GetRecording", request_serializer=service.GetRecordingRequest.serialize, response_deserializer=resource.Recording.deserialize, @@ -452,7 +538,7 @@ def list_recordings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_recordings" not in self._stubs: - self._stubs["list_recordings"] = self.grpc_channel.unary_unary( + self._stubs["list_recordings"] = self._logged_channel.unary_unary( "/google.apps.meet.v2.ConferenceRecordsService/ListRecordings", request_serializer=service.ListRecordingsRequest.serialize, response_deserializer=service.ListRecordingsResponse.deserialize, @@ -478,7 +564,7 @@ def get_transcript( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_transcript" not in self._stubs: - self._stubs["get_transcript"] = self.grpc_channel.unary_unary( + self._stubs["get_transcript"] = self._logged_channel.unary_unary( "/google.apps.meet.v2.ConferenceRecordsService/GetTranscript", request_serializer=service.GetTranscriptRequest.serialize, response_deserializer=resource.Transcript.deserialize, @@ -506,7 +592,7 @@ def list_transcripts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_transcripts" not in self._stubs: - self._stubs["list_transcripts"] = self.grpc_channel.unary_unary( + self._stubs["list_transcripts"] = self._logged_channel.unary_unary( "/google.apps.meet.v2.ConferenceRecordsService/ListTranscripts", request_serializer=service.ListTranscriptsRequest.serialize, response_deserializer=service.ListTranscriptsResponse.deserialize, @@ -537,7 +623,7 @@ def get_transcript_entry( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_transcript_entry" not in self._stubs: - self._stubs["get_transcript_entry"] = self.grpc_channel.unary_unary( + self._stubs["get_transcript_entry"] = self._logged_channel.unary_unary( "/google.apps.meet.v2.ConferenceRecordsService/GetTranscriptEntry", request_serializer=service.GetTranscriptEntryRequest.serialize, response_deserializer=resource.TranscriptEntry.deserialize, @@ -573,7 +659,7 @@ def list_transcript_entries( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_transcript_entries" not in self._stubs: - self._stubs["list_transcript_entries"] = self.grpc_channel.unary_unary( + self._stubs["list_transcript_entries"] = self._logged_channel.unary_unary( "/google.apps.meet.v2.ConferenceRecordsService/ListTranscriptEntries", request_serializer=service.ListTranscriptEntriesRequest.serialize, response_deserializer=service.ListTranscriptEntriesResponse.deserialize, @@ -581,7 +667,7 @@ def list_transcript_entries( return self._stubs["list_transcript_entries"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-apps-meet/google/apps/meet_v2/services/conference_records_service/transports/grpc_asyncio.py b/packages/google-apps-meet/google/apps/meet_v2/services/conference_records_service/transports/grpc_asyncio.py index b3e943b81bd1..2948a4d40e88 100644 --- a/packages/google-apps-meet/google/apps/meet_v2/services/conference_records_service/transports/grpc_asyncio.py +++ b/packages/google-apps-meet/google/apps/meet_v2/services/conference_records_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.apps.meet_v2.types import resource, service from .base import DEFAULT_CLIENT_INFO, ConferenceRecordsServiceTransport from .grpc import ConferenceRecordsServiceGrpcTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + + +class _LoggingClientAIOInterceptor( + grpc.aio.UnaryUnaryClientInterceptor +): # pragma: NO COVER + async def intercept_unary_unary(self, continuation, client_call_details, request): + logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ) + if logging_enabled: # pragma: NO COVER + request_metadata = client_call_details.metadata + if isinstance(request, proto.Message): + request_payload = type(request).to_json(request) + elif isinstance(request, google.protobuf.message.Message): + request_payload = MessageToJson(request) + else: + request_payload = f"{type(request).__name__}: {pickle.dumps(request)}" + + request_metadata = { + key: value.decode("utf-8") if isinstance(value, bytes) else value + for key, value in request_metadata + } + grpc_request = { + "payload": request_payload, + "requestMethod": "grpc", + "metadata": dict(request_metadata), + } + _LOGGER.debug( + f"Sending request for {client_call_details.method}", + extra={ + "serviceName": "google.apps.meet.v2.ConferenceRecordsService", + "rpcName": str(client_call_details.method), + "request": grpc_request, + "metadata": grpc_request["metadata"], + }, + ) + response = await continuation(client_call_details, request) + if logging_enabled: # pragma: NO COVER + response_metadata = await response.trailing_metadata() + # Convert gRPC metadata `` to list of tuples + metadata = ( + dict([(k, str(v)) for k, v in response_metadata]) + if response_metadata + else None + ) + result = await response + if isinstance(result, proto.Message): + response_payload = type(result).to_json(result) + elif isinstance(result, google.protobuf.message.Message): + response_payload = MessageToJson(result) + else: + response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" + grpc_response = { + "payload": response_payload, + "metadata": metadata, + "status": "OK", + } + _LOGGER.debug( + f"Received response to rpc {client_call_details.method}.", + extra={ + "serviceName": "google.apps.meet.v2.ConferenceRecordsService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ConferenceRecordsServiceGrpcAsyncIOTransport(ConferenceRecordsServiceTransport): """gRPC AsyncIO backend transport for ConferenceRecordsService. @@ -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 @@ -263,7 +348,7 @@ def get_conference_record( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_conference_record" not in self._stubs: - self._stubs["get_conference_record"] = self.grpc_channel.unary_unary( + self._stubs["get_conference_record"] = self._logged_channel.unary_unary( "/google.apps.meet.v2.ConferenceRecordsService/GetConferenceRecord", request_serializer=service.GetConferenceRecordRequest.serialize, response_deserializer=resource.ConferenceRecord.deserialize, @@ -293,7 +378,7 @@ def list_conference_records( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_conference_records" not in self._stubs: - self._stubs["list_conference_records"] = self.grpc_channel.unary_unary( + self._stubs["list_conference_records"] = self._logged_channel.unary_unary( "/google.apps.meet.v2.ConferenceRecordsService/ListConferenceRecords", request_serializer=service.ListConferenceRecordsRequest.serialize, response_deserializer=service.ListConferenceRecordsResponse.deserialize, @@ -319,7 +404,7 @@ def get_participant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_participant" not in self._stubs: - self._stubs["get_participant"] = self.grpc_channel.unary_unary( + self._stubs["get_participant"] = self._logged_channel.unary_unary( "/google.apps.meet.v2.ConferenceRecordsService/GetParticipant", request_serializer=service.GetParticipantRequest.serialize, response_deserializer=resource.Participant.deserialize, @@ -351,7 +436,7 @@ def list_participants( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_participants" not in self._stubs: - self._stubs["list_participants"] = self.grpc_channel.unary_unary( + self._stubs["list_participants"] = self._logged_channel.unary_unary( "/google.apps.meet.v2.ConferenceRecordsService/ListParticipants", request_serializer=service.ListParticipantsRequest.serialize, response_deserializer=service.ListParticipantsResponse.deserialize, @@ -379,7 +464,7 @@ def get_participant_session( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_participant_session" not in self._stubs: - self._stubs["get_participant_session"] = self.grpc_channel.unary_unary( + self._stubs["get_participant_session"] = self._logged_channel.unary_unary( "/google.apps.meet.v2.ConferenceRecordsService/GetParticipantSession", request_serializer=service.GetParticipantSessionRequest.serialize, response_deserializer=resource.ParticipantSession.deserialize, @@ -413,7 +498,7 @@ def list_participant_sessions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_participant_sessions" not in self._stubs: - self._stubs["list_participant_sessions"] = self.grpc_channel.unary_unary( + self._stubs["list_participant_sessions"] = self._logged_channel.unary_unary( "/google.apps.meet.v2.ConferenceRecordsService/ListParticipantSessions", request_serializer=service.ListParticipantSessionsRequest.serialize, response_deserializer=service.ListParticipantSessionsResponse.deserialize, @@ -439,7 +524,7 @@ def get_recording( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_recording" not in self._stubs: - self._stubs["get_recording"] = self.grpc_channel.unary_unary( + self._stubs["get_recording"] = self._logged_channel.unary_unary( "/google.apps.meet.v2.ConferenceRecordsService/GetRecording", request_serializer=service.GetRecordingRequest.serialize, response_deserializer=resource.Recording.deserialize, @@ -469,7 +554,7 @@ def list_recordings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_recordings" not in self._stubs: - self._stubs["list_recordings"] = self.grpc_channel.unary_unary( + self._stubs["list_recordings"] = self._logged_channel.unary_unary( "/google.apps.meet.v2.ConferenceRecordsService/ListRecordings", request_serializer=service.ListRecordingsRequest.serialize, response_deserializer=service.ListRecordingsResponse.deserialize, @@ -495,7 +580,7 @@ def get_transcript( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_transcript" not in self._stubs: - self._stubs["get_transcript"] = self.grpc_channel.unary_unary( + self._stubs["get_transcript"] = self._logged_channel.unary_unary( "/google.apps.meet.v2.ConferenceRecordsService/GetTranscript", request_serializer=service.GetTranscriptRequest.serialize, response_deserializer=resource.Transcript.deserialize, @@ -525,7 +610,7 @@ def list_transcripts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_transcripts" not in self._stubs: - self._stubs["list_transcripts"] = self.grpc_channel.unary_unary( + self._stubs["list_transcripts"] = self._logged_channel.unary_unary( "/google.apps.meet.v2.ConferenceRecordsService/ListTranscripts", request_serializer=service.ListTranscriptsRequest.serialize, response_deserializer=service.ListTranscriptsResponse.deserialize, @@ -558,7 +643,7 @@ def get_transcript_entry( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_transcript_entry" not in self._stubs: - self._stubs["get_transcript_entry"] = self.grpc_channel.unary_unary( + self._stubs["get_transcript_entry"] = self._logged_channel.unary_unary( "/google.apps.meet.v2.ConferenceRecordsService/GetTranscriptEntry", request_serializer=service.GetTranscriptEntryRequest.serialize, response_deserializer=resource.TranscriptEntry.deserialize, @@ -595,7 +680,7 @@ def list_transcript_entries( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_transcript_entries" not in self._stubs: - self._stubs["list_transcript_entries"] = self.grpc_channel.unary_unary( + self._stubs["list_transcript_entries"] = self._logged_channel.unary_unary( "/google.apps.meet.v2.ConferenceRecordsService/ListTranscriptEntries", request_serializer=service.ListTranscriptEntriesRequest.serialize, response_deserializer=service.ListTranscriptEntriesResponse.deserialize, @@ -781,7 +866,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-apps-meet/google/apps/meet_v2/services/conference_records_service/transports/rest.py b/packages/google-apps-meet/google/apps/meet_v2/services/conference_records_service/transports/rest.py index b4a33254d0ab..4ed223265adf 100644 --- a/packages/google-apps-meet/google/apps/meet_v2/services/conference_records_service/transports/rest.py +++ b/packages/google-apps-meet/google/apps/meet_v2/services/conference_records_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -37,6 +37,14 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = logging.getLogger(__name__) DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, @@ -165,8 +173,10 @@ def post_list_transcripts(self, response): def pre_get_conference_record( self, request: service.GetConferenceRecordRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.GetConferenceRecordRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.GetConferenceRecordRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_conference_record Override in a subclass to manipulate the request or metadata @@ -188,8 +198,8 @@ def post_get_conference_record( def pre_get_participant( self, request: service.GetParticipantRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.GetParticipantRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetParticipantRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_participant Override in a subclass to manipulate the request or metadata @@ -211,8 +221,10 @@ def post_get_participant( def pre_get_participant_session( self, request: service.GetParticipantSessionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.GetParticipantSessionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.GetParticipantSessionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_participant_session Override in a subclass to manipulate the request or metadata @@ -232,8 +244,10 @@ def post_get_participant_session( return response def pre_get_recording( - self, request: service.GetRecordingRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetRecordingRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetRecordingRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetRecordingRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_recording Override in a subclass to manipulate the request or metadata @@ -251,8 +265,10 @@ def post_get_recording(self, response: resource.Recording) -> resource.Recording return response def pre_get_transcript( - self, request: service.GetTranscriptRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetTranscriptRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetTranscriptRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetTranscriptRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_transcript Override in a subclass to manipulate the request or metadata @@ -272,8 +288,10 @@ def post_get_transcript(self, response: resource.Transcript) -> resource.Transcr def pre_get_transcript_entry( self, request: service.GetTranscriptEntryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.GetTranscriptEntryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.GetTranscriptEntryRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_transcript_entry Override in a subclass to manipulate the request or metadata @@ -295,8 +313,10 @@ def post_get_transcript_entry( def pre_list_conference_records( self, request: service.ListConferenceRecordsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.ListConferenceRecordsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.ListConferenceRecordsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_conference_records Override in a subclass to manipulate the request or metadata @@ -318,8 +338,10 @@ def post_list_conference_records( def pre_list_participants( self, request: service.ListParticipantsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.ListParticipantsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.ListParticipantsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_participants Override in a subclass to manipulate the request or metadata @@ -341,8 +363,10 @@ def post_list_participants( def pre_list_participant_sessions( self, request: service.ListParticipantSessionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.ListParticipantSessionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.ListParticipantSessionsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_participant_sessions Override in a subclass to manipulate the request or metadata @@ -364,8 +388,8 @@ def post_list_participant_sessions( def pre_list_recordings( self, request: service.ListRecordingsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.ListRecordingsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListRecordingsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_recordings Override in a subclass to manipulate the request or metadata @@ -387,8 +411,10 @@ def post_list_recordings( def pre_list_transcript_entries( self, request: service.ListTranscriptEntriesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.ListTranscriptEntriesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.ListTranscriptEntriesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_transcript_entries Override in a subclass to manipulate the request or metadata @@ -410,8 +436,8 @@ def post_list_transcript_entries( def pre_list_transcripts( self, request: service.ListTranscriptsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.ListTranscriptsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListTranscriptsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_transcripts Override in a subclass to manipulate the request or metadata @@ -552,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]]] = (), ) -> resource.ConferenceRecord: r"""Call the get conference record method over HTTP. @@ -562,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: ~.resource.ConferenceRecord: @@ -575,6 +603,7 @@ def __call__( http_options = ( _BaseConferenceRecordsServiceRestTransport._BaseGetConferenceRecord._get_http_options() ) + request, metadata = self._interceptor.pre_get_conference_record( request, metadata ) @@ -587,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.apps.meet_v2.ConferenceRecordsServiceClient.GetConferenceRecord", + extra={ + "serviceName": "google.apps.meet.v2.ConferenceRecordsService", + "rpcName": "GetConferenceRecord", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConferenceRecordsServiceRestTransport._GetConferenceRecord._get_response( self._host, @@ -607,7 +663,29 @@ def __call__( pb_resp = resource.ConferenceRecord.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_conference_record(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resource.ConferenceRecord.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.apps.meet_v2.ConferenceRecordsServiceClient.get_conference_record", + extra={ + "serviceName": "google.apps.meet.v2.ConferenceRecordsService", + "rpcName": "GetConferenceRecord", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetParticipant( @@ -645,7 +723,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.Participant: r"""Call the get participant method over HTTP. @@ -655,8 +733,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.resource.Participant: @@ -668,6 +748,7 @@ def __call__( http_options = ( _BaseConferenceRecordsServiceRestTransport._BaseGetParticipant._get_http_options() ) + request, metadata = self._interceptor.pre_get_participant(request, metadata) transcoded_request = _BaseConferenceRecordsServiceRestTransport._BaseGetParticipant._get_transcoded_request( http_options, request @@ -678,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 = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.apps.meet_v2.ConferenceRecordsServiceClient.GetParticipant", + extra={ + "serviceName": "google.apps.meet.v2.ConferenceRecordsService", + "rpcName": "GetParticipant", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ConferenceRecordsServiceRestTransport._GetParticipant._get_response( @@ -700,7 +808,29 @@ def __call__( pb_resp = resource.Participant.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_participant(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resource.Participant.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.apps.meet_v2.ConferenceRecordsServiceClient.get_participant", + extra={ + "serviceName": "google.apps.meet.v2.ConferenceRecordsService", + "rpcName": "GetParticipant", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetParticipantSession( @@ -738,7 +868,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.ParticipantSession: r"""Call the get participant session method over HTTP. @@ -748,8 +878,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.resource.ParticipantSession: @@ -768,6 +900,7 @@ def __call__( http_options = ( _BaseConferenceRecordsServiceRestTransport._BaseGetParticipantSession._get_http_options() ) + request, metadata = self._interceptor.pre_get_participant_session( request, metadata ) @@ -780,6 +913,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.apps.meet_v2.ConferenceRecordsServiceClient.GetParticipantSession", + extra={ + "serviceName": "google.apps.meet.v2.ConferenceRecordsService", + "rpcName": "GetParticipantSession", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConferenceRecordsServiceRestTransport._GetParticipantSession._get_response( self._host, @@ -800,7 +960,29 @@ def __call__( pb_resp = resource.ParticipantSession.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_participant_session(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resource.ParticipantSession.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.apps.meet_v2.ConferenceRecordsServiceClient.get_participant_session", + extra={ + "serviceName": "google.apps.meet.v2.ConferenceRecordsService", + "rpcName": "GetParticipantSession", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetRecording( @@ -838,7 +1020,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.Recording: r"""Call the get recording method over HTTP. @@ -849,8 +1031,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.resource.Recording: @@ -862,6 +1046,7 @@ def __call__( http_options = ( _BaseConferenceRecordsServiceRestTransport._BaseGetRecording._get_http_options() ) + request, metadata = self._interceptor.pre_get_recording(request, metadata) transcoded_request = _BaseConferenceRecordsServiceRestTransport._BaseGetRecording._get_transcoded_request( http_options, request @@ -872,6 +1057,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.apps.meet_v2.ConferenceRecordsServiceClient.GetRecording", + extra={ + "serviceName": "google.apps.meet.v2.ConferenceRecordsService", + "rpcName": "GetRecording", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ConferenceRecordsServiceRestTransport._GetRecording._get_response( @@ -894,7 +1106,29 @@ def __call__( pb_resp = resource.Recording.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_recording(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resource.Recording.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.apps.meet_v2.ConferenceRecordsServiceClient.get_recording", + extra={ + "serviceName": "google.apps.meet.v2.ConferenceRecordsService", + "rpcName": "GetRecording", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetTranscript( @@ -932,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]]] = (), ) -> resource.Transcript: r"""Call the get transcript method over HTTP. @@ -942,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: ~.resource.Transcript: @@ -957,6 +1193,7 @@ def __call__( http_options = ( _BaseConferenceRecordsServiceRestTransport._BaseGetTranscript._get_http_options() ) + request, metadata = self._interceptor.pre_get_transcript(request, metadata) transcoded_request = _BaseConferenceRecordsServiceRestTransport._BaseGetTranscript._get_transcoded_request( http_options, request @@ -967,6 +1204,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.apps.meet_v2.ConferenceRecordsServiceClient.GetTranscript", + extra={ + "serviceName": "google.apps.meet.v2.ConferenceRecordsService", + "rpcName": "GetTranscript", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ConferenceRecordsServiceRestTransport._GetTranscript._get_response( @@ -989,7 +1253,29 @@ def __call__( pb_resp = resource.Transcript.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_transcript(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resource.Transcript.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.apps.meet_v2.ConferenceRecordsServiceClient.get_transcript", + extra={ + "serviceName": "google.apps.meet.v2.ConferenceRecordsService", + "rpcName": "GetTranscript", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetTranscriptEntry( @@ -1027,7 +1313,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.TranscriptEntry: r"""Call the get transcript entry method over HTTP. @@ -1038,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: ~.resource.TranscriptEntry: @@ -1051,6 +1339,7 @@ def __call__( http_options = ( _BaseConferenceRecordsServiceRestTransport._BaseGetTranscriptEntry._get_http_options() ) + request, metadata = self._interceptor.pre_get_transcript_entry( request, metadata ) @@ -1063,6 +1352,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.apps.meet_v2.ConferenceRecordsServiceClient.GetTranscriptEntry", + extra={ + "serviceName": "google.apps.meet.v2.ConferenceRecordsService", + "rpcName": "GetTranscriptEntry", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ConferenceRecordsServiceRestTransport._GetTranscriptEntry._get_response( @@ -1085,7 +1401,29 @@ def __call__( pb_resp = resource.TranscriptEntry.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_transcript_entry(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resource.TranscriptEntry.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.apps.meet_v2.ConferenceRecordsServiceClient.get_transcript_entry", + extra={ + "serviceName": "google.apps.meet.v2.ConferenceRecordsService", + "rpcName": "GetTranscriptEntry", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListConferenceRecords( @@ -1123,7 +1461,7 @@ 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.ListConferenceRecordsResponse: r"""Call the list conference records method over HTTP. @@ -1134,8 +1472,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.service.ListConferenceRecordsResponse: @@ -1147,6 +1487,7 @@ def __call__( http_options = ( _BaseConferenceRecordsServiceRestTransport._BaseListConferenceRecords._get_http_options() ) + request, metadata = self._interceptor.pre_list_conference_records( request, metadata ) @@ -1159,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 google.apps.meet_v2.ConferenceRecordsServiceClient.ListConferenceRecords", + extra={ + "serviceName": "google.apps.meet.v2.ConferenceRecordsService", + "rpcName": "ListConferenceRecords", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConferenceRecordsServiceRestTransport._ListConferenceRecords._get_response( self._host, @@ -1179,7 +1547,31 @@ def __call__( pb_resp = service.ListConferenceRecordsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_conference_records(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListConferenceRecordsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.apps.meet_v2.ConferenceRecordsServiceClient.list_conference_records", + extra={ + "serviceName": "google.apps.meet.v2.ConferenceRecordsService", + "rpcName": "ListConferenceRecords", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListParticipants( @@ -1217,7 +1609,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.ListParticipantsResponse: r"""Call the list participants method over HTTP. @@ -1228,8 +1620,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.service.ListParticipantsResponse: @@ -1239,6 +1633,7 @@ def __call__( http_options = ( _BaseConferenceRecordsServiceRestTransport._BaseListParticipants._get_http_options() ) + request, metadata = self._interceptor.pre_list_participants( request, metadata ) @@ -1251,6 +1646,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.apps.meet_v2.ConferenceRecordsServiceClient.ListParticipants", + extra={ + "serviceName": "google.apps.meet.v2.ConferenceRecordsService", + "rpcName": "ListParticipants", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ConferenceRecordsServiceRestTransport._ListParticipants._get_response( @@ -1273,7 +1695,31 @@ def __call__( pb_resp = service.ListParticipantsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_participants(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListParticipantsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.apps.meet_v2.ConferenceRecordsServiceClient.list_participants", + extra={ + "serviceName": "google.apps.meet.v2.ConferenceRecordsService", + "rpcName": "ListParticipants", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListParticipantSessions( @@ -1311,7 +1757,7 @@ 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.ListParticipantSessionsResponse: r"""Call the list participant sessions method over HTTP. @@ -1323,8 +1769,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.service.ListParticipantSessionsResponse: @@ -1334,6 +1782,7 @@ def __call__( http_options = ( _BaseConferenceRecordsServiceRestTransport._BaseListParticipantSessions._get_http_options() ) + request, metadata = self._interceptor.pre_list_participant_sessions( request, metadata ) @@ -1346,6 +1795,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.apps.meet_v2.ConferenceRecordsServiceClient.ListParticipantSessions", + extra={ + "serviceName": "google.apps.meet.v2.ConferenceRecordsService", + "rpcName": "ListParticipantSessions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConferenceRecordsServiceRestTransport._ListParticipantSessions._get_response( self._host, @@ -1366,7 +1842,31 @@ def __call__( pb_resp = service.ListParticipantSessionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_participant_sessions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListParticipantSessionsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.apps.meet_v2.ConferenceRecordsServiceClient.list_participant_sessions", + extra={ + "serviceName": "google.apps.meet.v2.ConferenceRecordsService", + "rpcName": "ListParticipantSessions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListRecordings( @@ -1404,7 +1904,7 @@ 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.ListRecordingsResponse: r"""Call the list recordings method over HTTP. @@ -1414,8 +1914,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ListRecordingsResponse: @@ -1425,6 +1927,7 @@ def __call__( http_options = ( _BaseConferenceRecordsServiceRestTransport._BaseListRecordings._get_http_options() ) + request, metadata = self._interceptor.pre_list_recordings(request, metadata) transcoded_request = _BaseConferenceRecordsServiceRestTransport._BaseListRecordings._get_transcoded_request( http_options, request @@ -1435,6 +1938,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.apps.meet_v2.ConferenceRecordsServiceClient.ListRecordings", + extra={ + "serviceName": "google.apps.meet.v2.ConferenceRecordsService", + "rpcName": "ListRecordings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ConferenceRecordsServiceRestTransport._ListRecordings._get_response( @@ -1457,7 +1987,29 @@ def __call__( pb_resp = service.ListRecordingsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_recordings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListRecordingsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.apps.meet_v2.ConferenceRecordsServiceClient.list_recordings", + extra={ + "serviceName": "google.apps.meet.v2.ConferenceRecordsService", + "rpcName": "ListRecordings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTranscriptEntries( @@ -1495,7 +2047,7 @@ 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.ListTranscriptEntriesResponse: r"""Call the list transcript entries method over HTTP. @@ -1506,8 +2058,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ListTranscriptEntriesResponse: @@ -1519,6 +2073,7 @@ def __call__( http_options = ( _BaseConferenceRecordsServiceRestTransport._BaseListTranscriptEntries._get_http_options() ) + request, metadata = self._interceptor.pre_list_transcript_entries( request, metadata ) @@ -1531,6 +2086,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.apps.meet_v2.ConferenceRecordsServiceClient.ListTranscriptEntries", + extra={ + "serviceName": "google.apps.meet.v2.ConferenceRecordsService", + "rpcName": "ListTranscriptEntries", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConferenceRecordsServiceRestTransport._ListTranscriptEntries._get_response( self._host, @@ -1551,7 +2133,31 @@ def __call__( pb_resp = service.ListTranscriptEntriesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_transcript_entries(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListTranscriptEntriesResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.apps.meet_v2.ConferenceRecordsServiceClient.list_transcript_entries", + extra={ + "serviceName": "google.apps.meet.v2.ConferenceRecordsService", + "rpcName": "ListTranscriptEntries", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTranscripts( @@ -1589,7 +2195,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.ListTranscriptsResponse: r"""Call the list transcripts method over HTTP. @@ -1599,8 +2205,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ListTranscriptsResponse: @@ -1610,6 +2218,7 @@ def __call__( http_options = ( _BaseConferenceRecordsServiceRestTransport._BaseListTranscripts._get_http_options() ) + request, metadata = self._interceptor.pre_list_transcripts( request, metadata ) @@ -1622,6 +2231,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.apps.meet_v2.ConferenceRecordsServiceClient.ListTranscripts", + extra={ + "serviceName": "google.apps.meet.v2.ConferenceRecordsService", + "rpcName": "ListTranscripts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ConferenceRecordsServiceRestTransport._ListTranscripts._get_response( @@ -1644,7 +2280,29 @@ def __call__( pb_resp = service.ListTranscriptsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_transcripts(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListTranscriptsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.apps.meet_v2.ConferenceRecordsServiceClient.list_transcripts", + extra={ + "serviceName": "google.apps.meet.v2.ConferenceRecordsService", + "rpcName": "ListTranscripts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-apps-meet/google/apps/meet_v2/services/spaces_service/async_client.py b/packages/google-apps-meet/google/apps/meet_v2/services/spaces_service/async_client.py index 8ffd92ec7dd0..ae4d3a81f6fd 100644 --- a/packages/google-apps-meet/google/apps/meet_v2/services/spaces_service/async_client.py +++ b/packages/google-apps-meet/google/apps/meet_v2/services/spaces_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, @@ -50,6 +51,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, SpacesServiceTransport from .transports.grpc_asyncio import SpacesServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class SpacesServiceAsyncClient: """REST API for services dealing with spaces.""" @@ -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.apps.meet_v2.SpacesServiceAsyncClient`.", + extra={ + "serviceName": "google.apps.meet.v2.SpacesService", + "universeDomain": getattr( + self._client._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._client._transport._credentials).__module__}.{type(self._client._transport._credentials).__qualname__}", + "credentialsInfo": getattr( + self.transport._credentials, "get_cred_info", lambda: None + )(), + } + if hasattr(self._client._transport, "_credentials") + else { + "serviceName": "google.apps.meet.v2.SpacesService", + "credentialsType": None, + }, + ) + async def create_space( self, request: Optional[Union[service.CreateSpaceRequest, dict]] = None, @@ -266,7 +298,7 @@ async def create_space( space: Optional[resource.Space] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.Space: r"""Creates a space. @@ -310,8 +342,10 @@ async def sample_create_space(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2.types.Space: @@ -367,7 +401,7 @@ async def get_space( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.Space: r"""Gets a space by ``space_id`` or ``meeting_code``. @@ -408,8 +442,10 @@ async def sample_get_space(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2.types.Space: @@ -472,7 +508,7 @@ async def update_space( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.Space: r"""Updates a space. @@ -522,8 +558,10 @@ async def sample_update_space(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2.types.Space: @@ -589,7 +627,7 @@ async def end_active_conference( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Ends an active conference (if there's one). @@ -628,8 +666,10 @@ async def sample_end_active_conference(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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-apps-meet/google/apps/meet_v2/services/spaces_service/client.py b/packages/google-apps-meet/google/apps/meet_v2/services/spaces_service/client.py index 707bba6f8b1f..0f1a108b9637 100644 --- a/packages/google-apps-meet/google/apps/meet_v2/services/spaces_service/client.py +++ b/packages/google-apps-meet/google/apps/meet_v2/services/spaces_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + from google.protobuf import field_mask_pb2 # type: ignore from google.apps.meet_v2.types import resource, service @@ -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( @@ -650,6 +664,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.apps.meet_v2.SpacesServiceClient`.", + extra={ + "serviceName": "google.apps.meet.v2.SpacesService", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__module__}.{type(self._transport._credentials).__qualname__}", + "credentialsInfo": getattr( + self.transport._credentials, "get_cred_info", lambda: None + )(), + } + if hasattr(self._transport, "_credentials") + else { + "serviceName": "google.apps.meet.v2.SpacesService", + "credentialsType": None, + }, + ) + def create_space( self, request: Optional[Union[service.CreateSpaceRequest, dict]] = None, @@ -657,7 +694,7 @@ def create_space( space: Optional[resource.Space] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.Space: r"""Creates a space. @@ -701,8 +738,10 @@ def sample_create_space(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2.types.Space: @@ -755,7 +794,7 @@ def get_space( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.Space: r"""Gets a space by ``space_id`` or ``meeting_code``. @@ -796,8 +835,10 @@ def sample_get_space(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2.types.Space: @@ -857,7 +898,7 @@ def update_space( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.Space: r"""Updates a space. @@ -907,8 +948,10 @@ def sample_update_space(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2.types.Space: @@ -971,7 +1014,7 @@ def end_active_conference( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Ends an active conference (if there's one). @@ -1010,8 +1053,10 @@ def sample_end_active_conference(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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-apps-meet/google/apps/meet_v2/services/spaces_service/transports/grpc.py b/packages/google-apps-meet/google/apps/meet_v2/services/spaces_service/transports/grpc.py index ac441fd3a091..104bc6e1b50d 100644 --- a/packages/google-apps-meet/google/apps/meet_v2/services/spaces_service/transports/grpc.py +++ b/packages/google-apps-meet/google/apps/meet_v2/services/spaces_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.apps.meet_v2.types import resource, service from .base import DEFAULT_CLIENT_INFO, SpacesServiceTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + + +class _LoggingClientInterceptor(grpc.UnaryUnaryClientInterceptor): # pragma: NO COVER + def intercept_unary_unary(self, continuation, client_call_details, request): + logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ) + if logging_enabled: # pragma: NO COVER + request_metadata = client_call_details.metadata + if isinstance(request, proto.Message): + request_payload = type(request).to_json(request) + elif isinstance(request, google.protobuf.message.Message): + request_payload = MessageToJson(request) + else: + request_payload = f"{type(request).__name__}: {pickle.dumps(request)}" + + request_metadata = { + key: value.decode("utf-8") if isinstance(value, bytes) else value + for key, value in request_metadata + } + grpc_request = { + "payload": request_payload, + "requestMethod": "grpc", + "metadata": dict(request_metadata), + } + _LOGGER.debug( + f"Sending request for {client_call_details.method}", + extra={ + "serviceName": "google.apps.meet.v2.SpacesService", + "rpcName": client_call_details.method, + "request": grpc_request, + "metadata": grpc_request["metadata"], + }, + ) + + response = continuation(client_call_details, request) + if logging_enabled: # pragma: NO COVER + response_metadata = response.trailing_metadata() + # Convert gRPC metadata `` to list of tuples + metadata = ( + dict([(k, str(v)) for k, v in response_metadata]) + if response_metadata + else None + ) + result = response.result() + if isinstance(result, proto.Message): + response_payload = type(result).to_json(result) + elif isinstance(result, google.protobuf.message.Message): + response_payload = MessageToJson(result) + else: + response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" + grpc_response = { + "payload": response_payload, + "metadata": metadata, + "status": "OK", + } + _LOGGER.debug( + f"Received response for {client_call_details.method}.", + extra={ + "serviceName": "google.apps.meet.v2.SpacesService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SpacesServiceGrpcTransport(SpacesServiceTransport): """gRPC backend transport for SpacesService. @@ -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 @@ -252,7 +338,7 @@ def create_space(self) -> Callable[[service.CreateSpaceRequest], resource.Space] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_space" not in self._stubs: - self._stubs["create_space"] = self.grpc_channel.unary_unary( + self._stubs["create_space"] = self._logged_channel.unary_unary( "/google.apps.meet.v2.SpacesService/CreateSpace", request_serializer=service.CreateSpaceRequest.serialize, response_deserializer=resource.Space.deserialize, @@ -276,7 +362,7 @@ def get_space(self) -> Callable[[service.GetSpaceRequest], resource.Space]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_space" not in self._stubs: - self._stubs["get_space"] = self.grpc_channel.unary_unary( + self._stubs["get_space"] = self._logged_channel.unary_unary( "/google.apps.meet.v2.SpacesService/GetSpace", request_serializer=service.GetSpaceRequest.serialize, response_deserializer=resource.Space.deserialize, @@ -300,7 +386,7 @@ def update_space(self) -> Callable[[service.UpdateSpaceRequest], resource.Space] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_space" not in self._stubs: - self._stubs["update_space"] = self.grpc_channel.unary_unary( + self._stubs["update_space"] = self._logged_channel.unary_unary( "/google.apps.meet.v2.SpacesService/UpdateSpace", request_serializer=service.UpdateSpaceRequest.serialize, response_deserializer=resource.Space.deserialize, @@ -326,7 +412,7 @@ def end_active_conference( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "end_active_conference" not in self._stubs: - self._stubs["end_active_conference"] = self.grpc_channel.unary_unary( + self._stubs["end_active_conference"] = self._logged_channel.unary_unary( "/google.apps.meet.v2.SpacesService/EndActiveConference", request_serializer=service.EndActiveConferenceRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -334,7 +420,7 @@ def end_active_conference( return self._stubs["end_active_conference"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-apps-meet/google/apps/meet_v2/services/spaces_service/transports/grpc_asyncio.py b/packages/google-apps-meet/google/apps/meet_v2/services/spaces_service/transports/grpc_asyncio.py index 162337b1d531..5bdc968f2bb4 100644 --- a/packages/google-apps-meet/google/apps/meet_v2/services/spaces_service/transports/grpc_asyncio.py +++ b/packages/google-apps-meet/google/apps/meet_v2/services/spaces_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.apps.meet_v2.types import resource, service from .base import DEFAULT_CLIENT_INFO, SpacesServiceTransport from .grpc import SpacesServiceGrpcTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + + +class _LoggingClientAIOInterceptor( + grpc.aio.UnaryUnaryClientInterceptor +): # pragma: NO COVER + async def intercept_unary_unary(self, continuation, client_call_details, request): + logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ) + if logging_enabled: # pragma: NO COVER + request_metadata = client_call_details.metadata + if isinstance(request, proto.Message): + request_payload = type(request).to_json(request) + elif isinstance(request, google.protobuf.message.Message): + request_payload = MessageToJson(request) + else: + request_payload = f"{type(request).__name__}: {pickle.dumps(request)}" + + request_metadata = { + key: value.decode("utf-8") if isinstance(value, bytes) else value + for key, value in request_metadata + } + grpc_request = { + "payload": request_payload, + "requestMethod": "grpc", + "metadata": dict(request_metadata), + } + _LOGGER.debug( + f"Sending request for {client_call_details.method}", + extra={ + "serviceName": "google.apps.meet.v2.SpacesService", + "rpcName": str(client_call_details.method), + "request": grpc_request, + "metadata": grpc_request["metadata"], + }, + ) + response = await continuation(client_call_details, request) + if logging_enabled: # pragma: NO COVER + response_metadata = await response.trailing_metadata() + # Convert gRPC metadata `` to list of tuples + metadata = ( + dict([(k, str(v)) for k, v in response_metadata]) + if response_metadata + else None + ) + result = await response + if isinstance(result, proto.Message): + response_payload = type(result).to_json(result) + elif isinstance(result, google.protobuf.message.Message): + response_payload = MessageToJson(result) + else: + response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" + grpc_response = { + "payload": response_payload, + "metadata": metadata, + "status": "OK", + } + _LOGGER.debug( + f"Received response to rpc {client_call_details.method}.", + extra={ + "serviceName": "google.apps.meet.v2.SpacesService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SpacesServiceGrpcAsyncIOTransport(SpacesServiceTransport): """gRPC AsyncIO backend transport for SpacesService. @@ -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 @@ -262,7 +347,7 @@ def create_space( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_space" not in self._stubs: - self._stubs["create_space"] = self.grpc_channel.unary_unary( + self._stubs["create_space"] = self._logged_channel.unary_unary( "/google.apps.meet.v2.SpacesService/CreateSpace", request_serializer=service.CreateSpaceRequest.serialize, response_deserializer=resource.Space.deserialize, @@ -288,7 +373,7 @@ def get_space( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_space" not in self._stubs: - self._stubs["get_space"] = self.grpc_channel.unary_unary( + self._stubs["get_space"] = self._logged_channel.unary_unary( "/google.apps.meet.v2.SpacesService/GetSpace", request_serializer=service.GetSpaceRequest.serialize, response_deserializer=resource.Space.deserialize, @@ -314,7 +399,7 @@ def update_space( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_space" not in self._stubs: - self._stubs["update_space"] = self.grpc_channel.unary_unary( + self._stubs["update_space"] = self._logged_channel.unary_unary( "/google.apps.meet.v2.SpacesService/UpdateSpace", request_serializer=service.UpdateSpaceRequest.serialize, response_deserializer=resource.Space.deserialize, @@ -340,7 +425,7 @@ def end_active_conference( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "end_active_conference" not in self._stubs: - self._stubs["end_active_conference"] = self.grpc_channel.unary_unary( + self._stubs["end_active_conference"] = self._logged_channel.unary_unary( "/google.apps.meet.v2.SpacesService/EndActiveConference", request_serializer=service.EndActiveConferenceRequest.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-apps-meet/google/apps/meet_v2/services/spaces_service/transports/rest.py b/packages/google-apps-meet/google/apps/meet_v2/services/spaces_service/transports/rest.py index 75ee81e6b1e6..5ffeecf68bd7 100644 --- a/packages/google-apps-meet/google/apps/meet_v2/services/spaces_service/transports/rest.py +++ b/packages/google-apps-meet/google/apps/meet_v2/services/spaces_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, @@ -96,8 +104,10 @@ def post_update_space(self, response): """ def pre_create_space( - self, request: service.CreateSpaceRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.CreateSpaceRequest, Sequence[Tuple[str, str]]]: + self, + request: service.CreateSpaceRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.CreateSpaceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_space Override in a subclass to manipulate the request or metadata @@ -117,8 +127,10 @@ def post_create_space(self, response: resource.Space) -> resource.Space: def pre_end_active_conference( self, request: service.EndActiveConferenceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.EndActiveConferenceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.EndActiveConferenceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for end_active_conference Override in a subclass to manipulate the request or metadata @@ -127,8 +139,10 @@ def pre_end_active_conference( return request, metadata def pre_get_space( - self, request: service.GetSpaceRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetSpaceRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetSpaceRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetSpaceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_space Override in a subclass to manipulate the request or metadata @@ -146,8 +160,10 @@ def post_get_space(self, response: resource.Space) -> resource.Space: return response def pre_update_space( - self, request: service.UpdateSpaceRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.UpdateSpaceRequest, Sequence[Tuple[str, str]]]: + self, + request: service.UpdateSpaceRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.UpdateSpaceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_space Override in a subclass to manipulate the request or metadata @@ -286,7 +302,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.Space: r"""Call the create space method over HTTP. @@ -296,8 +312,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.resource.Space: @@ -310,6 +328,7 @@ def __call__( http_options = ( _BaseSpacesServiceRestTransport._BaseCreateSpace._get_http_options() ) + request, metadata = self._interceptor.pre_create_space(request, metadata) transcoded_request = _BaseSpacesServiceRestTransport._BaseCreateSpace._get_transcoded_request( http_options, request @@ -328,6 +347,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.apps.meet_v2.SpacesServiceClient.CreateSpace", + extra={ + "serviceName": "google.apps.meet.v2.SpacesService", + "rpcName": "CreateSpace", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpacesServiceRestTransport._CreateSpace._get_response( self._host, @@ -349,7 +395,29 @@ def __call__( pb_resp = resource.Space.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_space(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resource.Space.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.apps.meet_v2.SpacesServiceClient.create_space", + extra={ + "serviceName": "google.apps.meet.v2.SpacesService", + "rpcName": "CreateSpace", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _EndActiveConference( @@ -387,7 +455,7 @@ 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 end active conference method over HTTP. @@ -398,13 +466,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 = ( _BaseSpacesServiceRestTransport._BaseEndActiveConference._get_http_options() ) + request, metadata = self._interceptor.pre_end_active_conference( request, metadata ) @@ -421,6 +492,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.apps.meet_v2.SpacesServiceClient.EndActiveConference", + extra={ + "serviceName": "google.apps.meet.v2.SpacesService", + "rpcName": "EndActiveConference", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpacesServiceRestTransport._EndActiveConference._get_response( self._host, @@ -471,7 +569,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.Space: r"""Call the get space method over HTTP. @@ -481,8 +579,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.resource.Space: @@ -495,6 +595,7 @@ def __call__( http_options = ( _BaseSpacesServiceRestTransport._BaseGetSpace._get_http_options() ) + request, metadata = self._interceptor.pre_get_space(request, metadata) transcoded_request = ( _BaseSpacesServiceRestTransport._BaseGetSpace._get_transcoded_request( @@ -509,6 +610,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.apps.meet_v2.SpacesServiceClient.GetSpace", + extra={ + "serviceName": "google.apps.meet.v2.SpacesService", + "rpcName": "GetSpace", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpacesServiceRestTransport._GetSpace._get_response( self._host, @@ -529,7 +657,29 @@ def __call__( pb_resp = resource.Space.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_space(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resource.Space.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.apps.meet_v2.SpacesServiceClient.get_space", + extra={ + "serviceName": "google.apps.meet.v2.SpacesService", + "rpcName": "GetSpace", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSpace( @@ -567,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]]] = (), ) -> resource.Space: r"""Call the update space method over HTTP. @@ -577,8 +727,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.resource.Space: @@ -591,6 +743,7 @@ def __call__( http_options = ( _BaseSpacesServiceRestTransport._BaseUpdateSpace._get_http_options() ) + request, metadata = self._interceptor.pre_update_space(request, metadata) transcoded_request = _BaseSpacesServiceRestTransport._BaseUpdateSpace._get_transcoded_request( http_options, request @@ -609,6 +762,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.apps.meet_v2.SpacesServiceClient.UpdateSpace", + extra={ + "serviceName": "google.apps.meet.v2.SpacesService", + "rpcName": "UpdateSpace", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpacesServiceRestTransport._UpdateSpace._get_response( self._host, @@ -630,7 +810,29 @@ def __call__( pb_resp = resource.Space.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_space(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resource.Space.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.apps.meet_v2.SpacesServiceClient.update_space", + extra={ + "serviceName": "google.apps.meet.v2.SpacesService", + "rpcName": "UpdateSpace", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-apps-meet/google/apps/meet_v2beta/gapic_version.py b/packages/google-apps-meet/google/apps/meet_v2beta/gapic_version.py index 9413c3341313..558c8aab67c5 100644 --- a/packages/google-apps-meet/google/apps/meet_v2beta/gapic_version.py +++ b/packages/google-apps-meet/google/apps/meet_v2beta/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.10" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-apps-meet/google/apps/meet_v2beta/services/conference_records_service/async_client.py b/packages/google-apps-meet/google/apps/meet_v2beta/services/conference_records_service/async_client.py index a44ca33c3796..d87b689702c1 100644 --- a/packages/google-apps-meet/google/apps/meet_v2beta/services/conference_records_service/async_client.py +++ b/packages/google-apps-meet/google/apps/meet_v2beta/services/conference_records_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, ConferenceRecordsServiceTransport from .transports.grpc_asyncio import ConferenceRecordsServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class ConferenceRecordsServiceAsyncClient: """REST API for services dealing with conference records.""" @@ -296,6 +306,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.apps.meet_v2beta.ConferenceRecordsServiceAsyncClient`.", + extra={ + "serviceName": "google.apps.meet.v2beta.ConferenceRecordsService", + "universeDomain": getattr( + self._client._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._client._transport._credentials).__module__}.{type(self._client._transport._credentials).__qualname__}", + "credentialsInfo": getattr( + self.transport._credentials, "get_cred_info", lambda: None + )(), + } + if hasattr(self._client._transport, "_credentials") + else { + "serviceName": "google.apps.meet.v2beta.ConferenceRecordsService", + "credentialsType": None, + }, + ) + async def get_conference_record( self, request: Optional[Union[service.GetConferenceRecordRequest, dict]] = None, @@ -303,7 +335,7 @@ async def get_conference_record( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.ConferenceRecord: r"""`Developer Preview `__. @@ -348,8 +380,10 @@ async def sample_get_conference_record(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2beta.types.ConferenceRecord: @@ -409,7 +443,7 @@ async def list_conference_records( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListConferenceRecordsAsyncPager: r"""`Developer Preview `__. @@ -449,8 +483,10 @@ async def sample_list_conference_records(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2beta.services.conference_records_service.pagers.ListConferenceRecordsAsyncPager: @@ -505,7 +541,7 @@ async def get_participant( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.Participant: r"""`Developer Preview `__. @@ -550,8 +586,10 @@ async def sample_get_participant(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2beta.types.Participant: @@ -612,7 +650,7 @@ async def list_participants( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListParticipantsAsyncPager: r"""`Developer Preview `__. @@ -663,8 +701,10 @@ async def sample_list_participants(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2beta.services.conference_records_service.pagers.ListParticipantsAsyncPager: @@ -739,7 +779,7 @@ async def get_participant_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]]] = (), ) -> resource.ParticipantSession: r"""`Developer Preview `__. @@ -784,8 +824,10 @@ async def sample_get_participant_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.apps.meet_v2beta.types.ParticipantSession: @@ -852,7 +894,7 @@ async def list_participant_sessions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListParticipantSessionsAsyncPager: r"""`Developer Preview `__. @@ -905,8 +947,10 @@ async def sample_list_participant_sessions(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2beta.services.conference_records_service.pagers.ListParticipantSessionsAsyncPager: @@ -981,7 +1025,7 @@ async def get_recording( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.Recording: r"""`Developer Preview `__. @@ -1027,8 +1071,10 @@ async def sample_get_recording(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2beta.types.Recording: @@ -1090,7 +1136,7 @@ async def list_recordings( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListRecordingsAsyncPager: r"""`Developer Preview `__. @@ -1136,8 +1182,10 @@ async def sample_list_recordings(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2beta.services.conference_records_service.pagers.ListRecordingsAsyncPager: @@ -1212,7 +1260,7 @@ async def get_transcript( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.Transcript: r"""`Developer Preview `__. @@ -1257,8 +1305,10 @@ async def sample_get_transcript(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2beta.types.Transcript: @@ -1322,7 +1372,7 @@ async def list_transcripts( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTranscriptsAsyncPager: r"""`Developer Preview `__. @@ -1368,8 +1418,10 @@ async def sample_list_transcripts(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2beta.services.conference_records_service.pagers.ListTranscriptsAsyncPager: @@ -1444,7 +1496,7 @@ async def get_transcript_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]]] = (), ) -> resource.TranscriptEntry: r"""`Developer Preview `__. @@ -1493,8 +1545,10 @@ async def sample_get_transcript_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.apps.meet_v2beta.types.TranscriptEntry: @@ -1556,7 +1610,7 @@ async def list_transcript_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.ListTranscriptEntriesAsyncPager: r"""`Developer Preview `__. @@ -1609,8 +1663,10 @@ async def sample_list_transcript_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.apps.meet_v2beta.services.conference_records_service.pagers.ListTranscriptEntriesAsyncPager: diff --git a/packages/google-apps-meet/google/apps/meet_v2beta/services/conference_records_service/client.py b/packages/google-apps-meet/google/apps/meet_v2beta/services/conference_records_service/client.py index 05b4fac29dda..a9eeea0f72e2 100644 --- a/packages/google-apps-meet/google/apps/meet_v2beta/services/conference_records_service/client.py +++ b/packages/google-apps-meet/google/apps/meet_v2beta/services/conference_records_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.apps.meet_v2beta.services.conference_records_service import pagers @@ -702,6 +712,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( @@ -768,6 +782,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.apps.meet_v2beta.ConferenceRecordsServiceClient`.", + extra={ + "serviceName": "google.apps.meet.v2beta.ConferenceRecordsService", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__module__}.{type(self._transport._credentials).__qualname__}", + "credentialsInfo": getattr( + self.transport._credentials, "get_cred_info", lambda: None + )(), + } + if hasattr(self._transport, "_credentials") + else { + "serviceName": "google.apps.meet.v2beta.ConferenceRecordsService", + "credentialsType": None, + }, + ) + def get_conference_record( self, request: Optional[Union[service.GetConferenceRecordRequest, dict]] = None, @@ -775,7 +812,7 @@ def get_conference_record( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.ConferenceRecord: r"""`Developer Preview `__. @@ -820,8 +857,10 @@ def sample_get_conference_record(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2beta.types.ConferenceRecord: @@ -878,7 +917,7 @@ def list_conference_records( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListConferenceRecordsPager: r"""`Developer Preview `__. @@ -918,8 +957,10 @@ def sample_list_conference_records(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2beta.services.conference_records_service.pagers.ListConferenceRecordsPager: @@ -972,7 +1013,7 @@ def get_participant( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.Participant: r"""`Developer Preview `__. @@ -1017,8 +1058,10 @@ def sample_get_participant(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2beta.types.Participant: @@ -1076,7 +1119,7 @@ def list_participants( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListParticipantsPager: r"""`Developer Preview `__. @@ -1127,8 +1170,10 @@ def sample_list_participants(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2beta.services.conference_records_service.pagers.ListParticipantsPager: @@ -1200,7 +1245,7 @@ def get_participant_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]]] = (), ) -> resource.ParticipantSession: r"""`Developer Preview `__. @@ -1245,8 +1290,10 @@ def sample_get_participant_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.apps.meet_v2beta.types.ParticipantSession: @@ -1310,7 +1357,7 @@ def list_participant_sessions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListParticipantSessionsPager: r"""`Developer Preview `__. @@ -1363,8 +1410,10 @@ def sample_list_participant_sessions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2beta.services.conference_records_service.pagers.ListParticipantSessionsPager: @@ -1438,7 +1487,7 @@ def get_recording( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.Recording: r"""`Developer Preview `__. @@ -1484,8 +1533,10 @@ def sample_get_recording(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2beta.types.Recording: @@ -1544,7 +1595,7 @@ def list_recordings( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListRecordingsPager: r"""`Developer Preview `__. @@ -1590,8 +1641,10 @@ def sample_list_recordings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2beta.services.conference_records_service.pagers.ListRecordingsPager: @@ -1663,7 +1716,7 @@ def get_transcript( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.Transcript: r"""`Developer Preview `__. @@ -1708,8 +1761,10 @@ def sample_get_transcript(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2beta.types.Transcript: @@ -1770,7 +1825,7 @@ def list_transcripts( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTranscriptsPager: r"""`Developer Preview `__. @@ -1816,8 +1871,10 @@ def sample_list_transcripts(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2beta.services.conference_records_service.pagers.ListTranscriptsPager: @@ -1889,7 +1946,7 @@ def get_transcript_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]]] = (), ) -> resource.TranscriptEntry: r"""`Developer Preview `__. @@ -1938,8 +1995,10 @@ def sample_get_transcript_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.apps.meet_v2beta.types.TranscriptEntry: @@ -1998,7 +2057,7 @@ def list_transcript_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.ListTranscriptEntriesPager: r"""`Developer Preview `__. @@ -2051,8 +2110,10 @@ def sample_list_transcript_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.apps.meet_v2beta.services.conference_records_service.pagers.ListTranscriptEntriesPager: diff --git a/packages/google-apps-meet/google/apps/meet_v2beta/services/conference_records_service/pagers.py b/packages/google-apps-meet/google/apps/meet_v2beta/services/conference_records_service/pagers.py index f16533f6d18e..3b0659256e35 100644 --- a/packages/google-apps-meet/google/apps/meet_v2beta/services/conference_records_service/pagers.py +++ b/packages/google-apps-meet/google/apps/meet_v2beta/services/conference_records_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.ListConferenceRecordsRequest(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.ListConferenceRecordsRequest(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.ListParticipantsRequest(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.ListParticipantsRequest(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.ListParticipantSessionsRequest(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.ListParticipantSessionsRequest(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.ListRecordingsRequest(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.ListRecordingsRequest(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.ListTranscriptsRequest(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.ListTranscriptsRequest(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 = service.ListTranscriptEntriesRequest(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 = service.ListTranscriptEntriesRequest(request) diff --git a/packages/google-apps-meet/google/apps/meet_v2beta/services/conference_records_service/transports/grpc.py b/packages/google-apps-meet/google/apps/meet_v2beta/services/conference_records_service/transports/grpc.py index 7d4db08cf9d9..7d9245780b3d 100644 --- a/packages/google-apps-meet/google/apps/meet_v2beta/services/conference_records_service/transports/grpc.py +++ b/packages/google-apps-meet/google/apps/meet_v2beta/services/conference_records_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.apps.meet_v2beta.types import resource, service from .base import DEFAULT_CLIENT_INFO, ConferenceRecordsServiceTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + + +class _LoggingClientInterceptor(grpc.UnaryUnaryClientInterceptor): # pragma: NO COVER + def intercept_unary_unary(self, continuation, client_call_details, request): + logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ) + if logging_enabled: # pragma: NO COVER + request_metadata = client_call_details.metadata + if isinstance(request, proto.Message): + request_payload = type(request).to_json(request) + elif isinstance(request, google.protobuf.message.Message): + request_payload = MessageToJson(request) + else: + request_payload = f"{type(request).__name__}: {pickle.dumps(request)}" + + request_metadata = { + key: value.decode("utf-8") if isinstance(value, bytes) else value + for key, value in request_metadata + } + grpc_request = { + "payload": request_payload, + "requestMethod": "grpc", + "metadata": dict(request_metadata), + } + _LOGGER.debug( + f"Sending request for {client_call_details.method}", + extra={ + "serviceName": "google.apps.meet.v2beta.ConferenceRecordsService", + "rpcName": client_call_details.method, + "request": grpc_request, + "metadata": grpc_request["metadata"], + }, + ) + + response = continuation(client_call_details, request) + if logging_enabled: # pragma: NO COVER + response_metadata = response.trailing_metadata() + # Convert gRPC metadata `` to list of tuples + metadata = ( + dict([(k, str(v)) for k, v in response_metadata]) + if response_metadata + else None + ) + result = response.result() + if isinstance(result, proto.Message): + response_payload = type(result).to_json(result) + elif isinstance(result, google.protobuf.message.Message): + response_payload = MessageToJson(result) + else: + response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" + grpc_response = { + "payload": response_payload, + "metadata": metadata, + "status": "OK", + } + _LOGGER.debug( + f"Received response for {client_call_details.method}.", + extra={ + "serviceName": "google.apps.meet.v2beta.ConferenceRecordsService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ConferenceRecordsServiceGrpcTransport(ConferenceRecordsServiceTransport): """gRPC backend transport for ConferenceRecordsService. @@ -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 @@ -255,7 +341,7 @@ def get_conference_record( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_conference_record" not in self._stubs: - self._stubs["get_conference_record"] = self.grpc_channel.unary_unary( + self._stubs["get_conference_record"] = self._logged_channel.unary_unary( "/google.apps.meet.v2beta.ConferenceRecordsService/GetConferenceRecord", request_serializer=service.GetConferenceRecordRequest.serialize, response_deserializer=resource.ConferenceRecord.deserialize, @@ -286,7 +372,7 @@ def list_conference_records( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_conference_records" not in self._stubs: - self._stubs["list_conference_records"] = self.grpc_channel.unary_unary( + self._stubs["list_conference_records"] = self._logged_channel.unary_unary( "/google.apps.meet.v2beta.ConferenceRecordsService/ListConferenceRecords", request_serializer=service.ListConferenceRecordsRequest.serialize, response_deserializer=service.ListConferenceRecordsResponse.deserialize, @@ -314,7 +400,7 @@ def get_participant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_participant" not in self._stubs: - self._stubs["get_participant"] = self.grpc_channel.unary_unary( + self._stubs["get_participant"] = self._logged_channel.unary_unary( "/google.apps.meet.v2beta.ConferenceRecordsService/GetParticipant", request_serializer=service.GetParticipantRequest.serialize, response_deserializer=resource.Participant.deserialize, @@ -346,7 +432,7 @@ def list_participants( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_participants" not in self._stubs: - self._stubs["list_participants"] = self.grpc_channel.unary_unary( + self._stubs["list_participants"] = self._logged_channel.unary_unary( "/google.apps.meet.v2beta.ConferenceRecordsService/ListParticipants", request_serializer=service.ListParticipantsRequest.serialize, response_deserializer=service.ListParticipantsResponse.deserialize, @@ -374,7 +460,7 @@ def get_participant_session( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_participant_session" not in self._stubs: - self._stubs["get_participant_session"] = self.grpc_channel.unary_unary( + self._stubs["get_participant_session"] = self._logged_channel.unary_unary( "/google.apps.meet.v2beta.ConferenceRecordsService/GetParticipantSession", request_serializer=service.GetParticipantSessionRequest.serialize, response_deserializer=resource.ParticipantSession.deserialize, @@ -410,7 +496,7 @@ def list_participant_sessions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_participant_sessions" not in self._stubs: - self._stubs["list_participant_sessions"] = self.grpc_channel.unary_unary( + self._stubs["list_participant_sessions"] = self._logged_channel.unary_unary( "/google.apps.meet.v2beta.ConferenceRecordsService/ListParticipantSessions", request_serializer=service.ListParticipantSessionsRequest.serialize, response_deserializer=service.ListParticipantSessionsResponse.deserialize, @@ -438,7 +524,7 @@ def get_recording( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_recording" not in self._stubs: - self._stubs["get_recording"] = self.grpc_channel.unary_unary( + self._stubs["get_recording"] = self._logged_channel.unary_unary( "/google.apps.meet.v2beta.ConferenceRecordsService/GetRecording", request_serializer=service.GetRecordingRequest.serialize, response_deserializer=resource.Recording.deserialize, @@ -466,7 +552,7 @@ def list_recordings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_recordings" not in self._stubs: - self._stubs["list_recordings"] = self.grpc_channel.unary_unary( + self._stubs["list_recordings"] = self._logged_channel.unary_unary( "/google.apps.meet.v2beta.ConferenceRecordsService/ListRecordings", request_serializer=service.ListRecordingsRequest.serialize, response_deserializer=service.ListRecordingsResponse.deserialize, @@ -494,7 +580,7 @@ def get_transcript( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_transcript" not in self._stubs: - self._stubs["get_transcript"] = self.grpc_channel.unary_unary( + self._stubs["get_transcript"] = self._logged_channel.unary_unary( "/google.apps.meet.v2beta.ConferenceRecordsService/GetTranscript", request_serializer=service.GetTranscriptRequest.serialize, response_deserializer=resource.Transcript.deserialize, @@ -522,7 +608,7 @@ def list_transcripts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_transcripts" not in self._stubs: - self._stubs["list_transcripts"] = self.grpc_channel.unary_unary( + self._stubs["list_transcripts"] = self._logged_channel.unary_unary( "/google.apps.meet.v2beta.ConferenceRecordsService/ListTranscripts", request_serializer=service.ListTranscriptsRequest.serialize, response_deserializer=service.ListTranscriptsResponse.deserialize, @@ -555,7 +641,7 @@ def get_transcript_entry( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_transcript_entry" not in self._stubs: - self._stubs["get_transcript_entry"] = self.grpc_channel.unary_unary( + self._stubs["get_transcript_entry"] = self._logged_channel.unary_unary( "/google.apps.meet.v2beta.ConferenceRecordsService/GetTranscriptEntry", request_serializer=service.GetTranscriptEntryRequest.serialize, response_deserializer=resource.TranscriptEntry.deserialize, @@ -591,7 +677,7 @@ def list_transcript_entries( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_transcript_entries" not in self._stubs: - self._stubs["list_transcript_entries"] = self.grpc_channel.unary_unary( + self._stubs["list_transcript_entries"] = self._logged_channel.unary_unary( "/google.apps.meet.v2beta.ConferenceRecordsService/ListTranscriptEntries", request_serializer=service.ListTranscriptEntriesRequest.serialize, response_deserializer=service.ListTranscriptEntriesResponse.deserialize, @@ -599,7 +685,7 @@ def list_transcript_entries( return self._stubs["list_transcript_entries"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-apps-meet/google/apps/meet_v2beta/services/conference_records_service/transports/grpc_asyncio.py b/packages/google-apps-meet/google/apps/meet_v2beta/services/conference_records_service/transports/grpc_asyncio.py index 775f331c04eb..ecee5c67d7dd 100644 --- a/packages/google-apps-meet/google/apps/meet_v2beta/services/conference_records_service/transports/grpc_asyncio.py +++ b/packages/google-apps-meet/google/apps/meet_v2beta/services/conference_records_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.apps.meet_v2beta.types import resource, service from .base import DEFAULT_CLIENT_INFO, ConferenceRecordsServiceTransport from .grpc import ConferenceRecordsServiceGrpcTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + + +class _LoggingClientAIOInterceptor( + grpc.aio.UnaryUnaryClientInterceptor +): # pragma: NO COVER + async def intercept_unary_unary(self, continuation, client_call_details, request): + logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ) + if logging_enabled: # pragma: NO COVER + request_metadata = client_call_details.metadata + if isinstance(request, proto.Message): + request_payload = type(request).to_json(request) + elif isinstance(request, google.protobuf.message.Message): + request_payload = MessageToJson(request) + else: + request_payload = f"{type(request).__name__}: {pickle.dumps(request)}" + + request_metadata = { + key: value.decode("utf-8") if isinstance(value, bytes) else value + for key, value in request_metadata + } + grpc_request = { + "payload": request_payload, + "requestMethod": "grpc", + "metadata": dict(request_metadata), + } + _LOGGER.debug( + f"Sending request for {client_call_details.method}", + extra={ + "serviceName": "google.apps.meet.v2beta.ConferenceRecordsService", + "rpcName": str(client_call_details.method), + "request": grpc_request, + "metadata": grpc_request["metadata"], + }, + ) + response = await continuation(client_call_details, request) + if logging_enabled: # pragma: NO COVER + response_metadata = await response.trailing_metadata() + # Convert gRPC metadata `` to list of tuples + metadata = ( + dict([(k, str(v)) for k, v in response_metadata]) + if response_metadata + else None + ) + result = await response + if isinstance(result, proto.Message): + response_payload = type(result).to_json(result) + elif isinstance(result, google.protobuf.message.Message): + response_payload = MessageToJson(result) + else: + response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" + grpc_response = { + "payload": response_payload, + "metadata": metadata, + "status": "OK", + } + _LOGGER.debug( + f"Received response to rpc {client_call_details.method}.", + extra={ + "serviceName": "google.apps.meet.v2beta.ConferenceRecordsService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ConferenceRecordsServiceGrpcAsyncIOTransport(ConferenceRecordsServiceTransport): """gRPC AsyncIO backend transport for ConferenceRecordsService. @@ -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 @@ -265,7 +350,7 @@ def get_conference_record( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_conference_record" not in self._stubs: - self._stubs["get_conference_record"] = self.grpc_channel.unary_unary( + self._stubs["get_conference_record"] = self._logged_channel.unary_unary( "/google.apps.meet.v2beta.ConferenceRecordsService/GetConferenceRecord", request_serializer=service.GetConferenceRecordRequest.serialize, response_deserializer=resource.ConferenceRecord.deserialize, @@ -297,7 +382,7 @@ def list_conference_records( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_conference_records" not in self._stubs: - self._stubs["list_conference_records"] = self.grpc_channel.unary_unary( + self._stubs["list_conference_records"] = self._logged_channel.unary_unary( "/google.apps.meet.v2beta.ConferenceRecordsService/ListConferenceRecords", request_serializer=service.ListConferenceRecordsRequest.serialize, response_deserializer=service.ListConferenceRecordsResponse.deserialize, @@ -325,7 +410,7 @@ def get_participant( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_participant" not in self._stubs: - self._stubs["get_participant"] = self.grpc_channel.unary_unary( + self._stubs["get_participant"] = self._logged_channel.unary_unary( "/google.apps.meet.v2beta.ConferenceRecordsService/GetParticipant", request_serializer=service.GetParticipantRequest.serialize, response_deserializer=resource.Participant.deserialize, @@ -359,7 +444,7 @@ def list_participants( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_participants" not in self._stubs: - self._stubs["list_participants"] = self.grpc_channel.unary_unary( + self._stubs["list_participants"] = self._logged_channel.unary_unary( "/google.apps.meet.v2beta.ConferenceRecordsService/ListParticipants", request_serializer=service.ListParticipantsRequest.serialize, response_deserializer=service.ListParticipantsResponse.deserialize, @@ -389,7 +474,7 @@ def get_participant_session( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_participant_session" not in self._stubs: - self._stubs["get_participant_session"] = self.grpc_channel.unary_unary( + self._stubs["get_participant_session"] = self._logged_channel.unary_unary( "/google.apps.meet.v2beta.ConferenceRecordsService/GetParticipantSession", request_serializer=service.GetParticipantSessionRequest.serialize, response_deserializer=resource.ParticipantSession.deserialize, @@ -425,7 +510,7 @@ def list_participant_sessions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_participant_sessions" not in self._stubs: - self._stubs["list_participant_sessions"] = self.grpc_channel.unary_unary( + self._stubs["list_participant_sessions"] = self._logged_channel.unary_unary( "/google.apps.meet.v2beta.ConferenceRecordsService/ListParticipantSessions", request_serializer=service.ListParticipantSessionsRequest.serialize, response_deserializer=service.ListParticipantSessionsResponse.deserialize, @@ -453,7 +538,7 @@ def get_recording( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_recording" not in self._stubs: - self._stubs["get_recording"] = self.grpc_channel.unary_unary( + self._stubs["get_recording"] = self._logged_channel.unary_unary( "/google.apps.meet.v2beta.ConferenceRecordsService/GetRecording", request_serializer=service.GetRecordingRequest.serialize, response_deserializer=resource.Recording.deserialize, @@ -483,7 +568,7 @@ def list_recordings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_recordings" not in self._stubs: - self._stubs["list_recordings"] = self.grpc_channel.unary_unary( + self._stubs["list_recordings"] = self._logged_channel.unary_unary( "/google.apps.meet.v2beta.ConferenceRecordsService/ListRecordings", request_serializer=service.ListRecordingsRequest.serialize, response_deserializer=service.ListRecordingsResponse.deserialize, @@ -511,7 +596,7 @@ def get_transcript( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_transcript" not in self._stubs: - self._stubs["get_transcript"] = self.grpc_channel.unary_unary( + self._stubs["get_transcript"] = self._logged_channel.unary_unary( "/google.apps.meet.v2beta.ConferenceRecordsService/GetTranscript", request_serializer=service.GetTranscriptRequest.serialize, response_deserializer=resource.Transcript.deserialize, @@ -541,7 +626,7 @@ def list_transcripts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_transcripts" not in self._stubs: - self._stubs["list_transcripts"] = self.grpc_channel.unary_unary( + self._stubs["list_transcripts"] = self._logged_channel.unary_unary( "/google.apps.meet.v2beta.ConferenceRecordsService/ListTranscripts", request_serializer=service.ListTranscriptsRequest.serialize, response_deserializer=service.ListTranscriptsResponse.deserialize, @@ -576,7 +661,7 @@ def get_transcript_entry( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_transcript_entry" not in self._stubs: - self._stubs["get_transcript_entry"] = self.grpc_channel.unary_unary( + self._stubs["get_transcript_entry"] = self._logged_channel.unary_unary( "/google.apps.meet.v2beta.ConferenceRecordsService/GetTranscriptEntry", request_serializer=service.GetTranscriptEntryRequest.serialize, response_deserializer=resource.TranscriptEntry.deserialize, @@ -613,7 +698,7 @@ def list_transcript_entries( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_transcript_entries" not in self._stubs: - self._stubs["list_transcript_entries"] = self.grpc_channel.unary_unary( + self._stubs["list_transcript_entries"] = self._logged_channel.unary_unary( "/google.apps.meet.v2beta.ConferenceRecordsService/ListTranscriptEntries", request_serializer=service.ListTranscriptEntriesRequest.serialize, response_deserializer=service.ListTranscriptEntriesResponse.deserialize, @@ -799,7 +884,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-apps-meet/google/apps/meet_v2beta/services/conference_records_service/transports/rest.py b/packages/google-apps-meet/google/apps/meet_v2beta/services/conference_records_service/transports/rest.py index 066dfd5bdf26..8d2835db8005 100644 --- a/packages/google-apps-meet/google/apps/meet_v2beta/services/conference_records_service/transports/rest.py +++ b/packages/google-apps-meet/google/apps/meet_v2beta/services/conference_records_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -37,6 +37,14 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = logging.getLogger(__name__) DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, @@ -165,8 +173,10 @@ def post_list_transcripts(self, response): def pre_get_conference_record( self, request: service.GetConferenceRecordRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.GetConferenceRecordRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.GetConferenceRecordRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_conference_record Override in a subclass to manipulate the request or metadata @@ -188,8 +198,8 @@ def post_get_conference_record( def pre_get_participant( self, request: service.GetParticipantRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.GetParticipantRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetParticipantRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_participant Override in a subclass to manipulate the request or metadata @@ -211,8 +221,10 @@ def post_get_participant( def pre_get_participant_session( self, request: service.GetParticipantSessionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.GetParticipantSessionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.GetParticipantSessionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_participant_session Override in a subclass to manipulate the request or metadata @@ -232,8 +244,10 @@ def post_get_participant_session( return response def pre_get_recording( - self, request: service.GetRecordingRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetRecordingRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetRecordingRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetRecordingRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_recording Override in a subclass to manipulate the request or metadata @@ -251,8 +265,10 @@ def post_get_recording(self, response: resource.Recording) -> resource.Recording return response def pre_get_transcript( - self, request: service.GetTranscriptRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetTranscriptRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetTranscriptRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetTranscriptRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_transcript Override in a subclass to manipulate the request or metadata @@ -272,8 +288,10 @@ def post_get_transcript(self, response: resource.Transcript) -> resource.Transcr def pre_get_transcript_entry( self, request: service.GetTranscriptEntryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.GetTranscriptEntryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.GetTranscriptEntryRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_transcript_entry Override in a subclass to manipulate the request or metadata @@ -295,8 +313,10 @@ def post_get_transcript_entry( def pre_list_conference_records( self, request: service.ListConferenceRecordsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.ListConferenceRecordsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.ListConferenceRecordsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_conference_records Override in a subclass to manipulate the request or metadata @@ -318,8 +338,10 @@ def post_list_conference_records( def pre_list_participants( self, request: service.ListParticipantsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.ListParticipantsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.ListParticipantsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_participants Override in a subclass to manipulate the request or metadata @@ -341,8 +363,10 @@ def post_list_participants( def pre_list_participant_sessions( self, request: service.ListParticipantSessionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.ListParticipantSessionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.ListParticipantSessionsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_participant_sessions Override in a subclass to manipulate the request or metadata @@ -364,8 +388,8 @@ def post_list_participant_sessions( def pre_list_recordings( self, request: service.ListRecordingsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.ListRecordingsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListRecordingsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_recordings Override in a subclass to manipulate the request or metadata @@ -387,8 +411,10 @@ def post_list_recordings( def pre_list_transcript_entries( self, request: service.ListTranscriptEntriesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.ListTranscriptEntriesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.ListTranscriptEntriesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_transcript_entries Override in a subclass to manipulate the request or metadata @@ -410,8 +436,8 @@ def post_list_transcript_entries( def pre_list_transcripts( self, request: service.ListTranscriptsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.ListTranscriptsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListTranscriptsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_transcripts Override in a subclass to manipulate the request or metadata @@ -552,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]]] = (), ) -> resource.ConferenceRecord: r"""Call the get conference record method over HTTP. @@ -562,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: ~.resource.ConferenceRecord: @@ -576,6 +604,7 @@ def __call__( http_options = ( _BaseConferenceRecordsServiceRestTransport._BaseGetConferenceRecord._get_http_options() ) + request, metadata = self._interceptor.pre_get_conference_record( request, metadata ) @@ -588,6 +617,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.apps.meet_v2beta.ConferenceRecordsServiceClient.GetConferenceRecord", + extra={ + "serviceName": "google.apps.meet.v2beta.ConferenceRecordsService", + "rpcName": "GetConferenceRecord", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConferenceRecordsServiceRestTransport._GetConferenceRecord._get_response( self._host, @@ -608,7 +664,29 @@ def __call__( pb_resp = resource.ConferenceRecord.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_conference_record(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resource.ConferenceRecord.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.apps.meet_v2beta.ConferenceRecordsServiceClient.get_conference_record", + extra={ + "serviceName": "google.apps.meet.v2beta.ConferenceRecordsService", + "rpcName": "GetConferenceRecord", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetParticipant( @@ -646,7 +724,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.Participant: r"""Call the get participant method over HTTP. @@ -656,8 +734,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.resource.Participant: @@ -670,6 +750,7 @@ def __call__( http_options = ( _BaseConferenceRecordsServiceRestTransport._BaseGetParticipant._get_http_options() ) + request, metadata = self._interceptor.pre_get_participant(request, metadata) transcoded_request = _BaseConferenceRecordsServiceRestTransport._BaseGetParticipant._get_transcoded_request( http_options, request @@ -680,6 +761,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.apps.meet_v2beta.ConferenceRecordsServiceClient.GetParticipant", + extra={ + "serviceName": "google.apps.meet.v2beta.ConferenceRecordsService", + "rpcName": "GetParticipant", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ConferenceRecordsServiceRestTransport._GetParticipant._get_response( @@ -702,7 +810,29 @@ def __call__( pb_resp = resource.Participant.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_participant(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resource.Participant.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.apps.meet_v2beta.ConferenceRecordsServiceClient.get_participant", + extra={ + "serviceName": "google.apps.meet.v2beta.ConferenceRecordsService", + "rpcName": "GetParticipant", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetParticipantSession( @@ -740,7 +870,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.ParticipantSession: r"""Call the get participant session method over HTTP. @@ -750,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: ~.resource.ParticipantSession: @@ -769,6 +901,7 @@ def __call__( http_options = ( _BaseConferenceRecordsServiceRestTransport._BaseGetParticipantSession._get_http_options() ) + request, metadata = self._interceptor.pre_get_participant_session( request, metadata ) @@ -781,6 +914,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.apps.meet_v2beta.ConferenceRecordsServiceClient.GetParticipantSession", + extra={ + "serviceName": "google.apps.meet.v2beta.ConferenceRecordsService", + "rpcName": "GetParticipantSession", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConferenceRecordsServiceRestTransport._GetParticipantSession._get_response( self._host, @@ -801,7 +961,29 @@ def __call__( pb_resp = resource.ParticipantSession.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_participant_session(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resource.ParticipantSession.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.apps.meet_v2beta.ConferenceRecordsServiceClient.get_participant_session", + extra={ + "serviceName": "google.apps.meet.v2beta.ConferenceRecordsService", + "rpcName": "GetParticipantSession", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetRecording( @@ -839,7 +1021,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.Recording: r"""Call the get recording method over HTTP. @@ -850,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: ~.resource.Recording: @@ -864,6 +1048,7 @@ def __call__( http_options = ( _BaseConferenceRecordsServiceRestTransport._BaseGetRecording._get_http_options() ) + request, metadata = self._interceptor.pre_get_recording(request, metadata) transcoded_request = _BaseConferenceRecordsServiceRestTransport._BaseGetRecording._get_transcoded_request( http_options, request @@ -874,6 +1059,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.apps.meet_v2beta.ConferenceRecordsServiceClient.GetRecording", + extra={ + "serviceName": "google.apps.meet.v2beta.ConferenceRecordsService", + "rpcName": "GetRecording", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ConferenceRecordsServiceRestTransport._GetRecording._get_response( @@ -896,7 +1108,29 @@ def __call__( pb_resp = resource.Recording.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_recording(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resource.Recording.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.apps.meet_v2beta.ConferenceRecordsServiceClient.get_recording", + extra={ + "serviceName": "google.apps.meet.v2beta.ConferenceRecordsService", + "rpcName": "GetRecording", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetTranscript( @@ -934,7 +1168,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.Transcript: r"""Call the get transcript method over HTTP. @@ -944,8 +1178,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.resource.Transcript: @@ -960,6 +1196,7 @@ def __call__( http_options = ( _BaseConferenceRecordsServiceRestTransport._BaseGetTranscript._get_http_options() ) + request, metadata = self._interceptor.pre_get_transcript(request, metadata) transcoded_request = _BaseConferenceRecordsServiceRestTransport._BaseGetTranscript._get_transcoded_request( http_options, request @@ -970,6 +1207,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.apps.meet_v2beta.ConferenceRecordsServiceClient.GetTranscript", + extra={ + "serviceName": "google.apps.meet.v2beta.ConferenceRecordsService", + "rpcName": "GetTranscript", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ConferenceRecordsServiceRestTransport._GetTranscript._get_response( @@ -992,7 +1256,29 @@ def __call__( pb_resp = resource.Transcript.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_transcript(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resource.Transcript.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.apps.meet_v2beta.ConferenceRecordsServiceClient.get_transcript", + extra={ + "serviceName": "google.apps.meet.v2beta.ConferenceRecordsService", + "rpcName": "GetTranscript", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetTranscriptEntry( @@ -1030,7 +1316,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.TranscriptEntry: r"""Call the get transcript entry method over HTTP. @@ -1041,8 +1327,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.resource.TranscriptEntry: @@ -1056,6 +1344,7 @@ def __call__( http_options = ( _BaseConferenceRecordsServiceRestTransport._BaseGetTranscriptEntry._get_http_options() ) + request, metadata = self._interceptor.pre_get_transcript_entry( request, metadata ) @@ -1068,6 +1357,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.apps.meet_v2beta.ConferenceRecordsServiceClient.GetTranscriptEntry", + extra={ + "serviceName": "google.apps.meet.v2beta.ConferenceRecordsService", + "rpcName": "GetTranscriptEntry", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ConferenceRecordsServiceRestTransport._GetTranscriptEntry._get_response( @@ -1090,7 +1406,29 @@ def __call__( pb_resp = resource.TranscriptEntry.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_transcript_entry(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resource.TranscriptEntry.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.apps.meet_v2beta.ConferenceRecordsServiceClient.get_transcript_entry", + extra={ + "serviceName": "google.apps.meet.v2beta.ConferenceRecordsService", + "rpcName": "GetTranscriptEntry", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListConferenceRecords( @@ -1128,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]]] = (), ) -> service.ListConferenceRecordsResponse: r"""Call the list conference records method over HTTP. @@ -1139,8 +1477,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ListConferenceRecordsResponse: @@ -1152,6 +1492,7 @@ def __call__( http_options = ( _BaseConferenceRecordsServiceRestTransport._BaseListConferenceRecords._get_http_options() ) + request, metadata = self._interceptor.pre_list_conference_records( request, metadata ) @@ -1164,6 +1505,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.apps.meet_v2beta.ConferenceRecordsServiceClient.ListConferenceRecords", + extra={ + "serviceName": "google.apps.meet.v2beta.ConferenceRecordsService", + "rpcName": "ListConferenceRecords", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConferenceRecordsServiceRestTransport._ListConferenceRecords._get_response( self._host, @@ -1184,7 +1552,31 @@ def __call__( pb_resp = service.ListConferenceRecordsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_conference_records(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListConferenceRecordsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.apps.meet_v2beta.ConferenceRecordsServiceClient.list_conference_records", + extra={ + "serviceName": "google.apps.meet.v2beta.ConferenceRecordsService", + "rpcName": "ListConferenceRecords", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListParticipants( @@ -1222,7 +1614,7 @@ 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.ListParticipantsResponse: r"""Call the list participants method over HTTP. @@ -1233,8 +1625,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ListParticipantsResponse: @@ -1244,6 +1638,7 @@ def __call__( http_options = ( _BaseConferenceRecordsServiceRestTransport._BaseListParticipants._get_http_options() ) + request, metadata = self._interceptor.pre_list_participants( request, metadata ) @@ -1256,6 +1651,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.apps.meet_v2beta.ConferenceRecordsServiceClient.ListParticipants", + extra={ + "serviceName": "google.apps.meet.v2beta.ConferenceRecordsService", + "rpcName": "ListParticipants", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ConferenceRecordsServiceRestTransport._ListParticipants._get_response( @@ -1278,7 +1700,31 @@ def __call__( pb_resp = service.ListParticipantsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_participants(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListParticipantsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.apps.meet_v2beta.ConferenceRecordsServiceClient.list_participants", + extra={ + "serviceName": "google.apps.meet.v2beta.ConferenceRecordsService", + "rpcName": "ListParticipants", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListParticipantSessions( @@ -1316,7 +1762,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.ListParticipantSessionsResponse: r"""Call the list participant sessions method over HTTP. @@ -1328,8 +1774,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.service.ListParticipantSessionsResponse: @@ -1339,6 +1787,7 @@ def __call__( http_options = ( _BaseConferenceRecordsServiceRestTransport._BaseListParticipantSessions._get_http_options() ) + request, metadata = self._interceptor.pre_list_participant_sessions( request, metadata ) @@ -1351,6 +1800,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.apps.meet_v2beta.ConferenceRecordsServiceClient.ListParticipantSessions", + extra={ + "serviceName": "google.apps.meet.v2beta.ConferenceRecordsService", + "rpcName": "ListParticipantSessions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConferenceRecordsServiceRestTransport._ListParticipantSessions._get_response( self._host, @@ -1371,7 +1847,31 @@ def __call__( pb_resp = service.ListParticipantSessionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_participant_sessions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListParticipantSessionsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.apps.meet_v2beta.ConferenceRecordsServiceClient.list_participant_sessions", + extra={ + "serviceName": "google.apps.meet.v2beta.ConferenceRecordsService", + "rpcName": "ListParticipantSessions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListRecordings( @@ -1409,7 +1909,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.ListRecordingsResponse: r"""Call the list recordings method over HTTP. @@ -1419,8 +1919,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.service.ListRecordingsResponse: @@ -1430,6 +1932,7 @@ def __call__( http_options = ( _BaseConferenceRecordsServiceRestTransport._BaseListRecordings._get_http_options() ) + request, metadata = self._interceptor.pre_list_recordings(request, metadata) transcoded_request = _BaseConferenceRecordsServiceRestTransport._BaseListRecordings._get_transcoded_request( http_options, request @@ -1440,6 +1943,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.apps.meet_v2beta.ConferenceRecordsServiceClient.ListRecordings", + extra={ + "serviceName": "google.apps.meet.v2beta.ConferenceRecordsService", + "rpcName": "ListRecordings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ConferenceRecordsServiceRestTransport._ListRecordings._get_response( @@ -1462,7 +1992,29 @@ def __call__( pb_resp = service.ListRecordingsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_recordings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListRecordingsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.apps.meet_v2beta.ConferenceRecordsServiceClient.list_recordings", + extra={ + "serviceName": "google.apps.meet.v2beta.ConferenceRecordsService", + "rpcName": "ListRecordings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTranscriptEntries( @@ -1500,7 +2052,7 @@ 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.ListTranscriptEntriesResponse: r"""Call the list transcript entries method over HTTP. @@ -1511,8 +2063,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ListTranscriptEntriesResponse: @@ -1524,6 +2078,7 @@ def __call__( http_options = ( _BaseConferenceRecordsServiceRestTransport._BaseListTranscriptEntries._get_http_options() ) + request, metadata = self._interceptor.pre_list_transcript_entries( request, metadata ) @@ -1536,6 +2091,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.apps.meet_v2beta.ConferenceRecordsServiceClient.ListTranscriptEntries", + extra={ + "serviceName": "google.apps.meet.v2beta.ConferenceRecordsService", + "rpcName": "ListTranscriptEntries", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConferenceRecordsServiceRestTransport._ListTranscriptEntries._get_response( self._host, @@ -1556,7 +2138,31 @@ def __call__( pb_resp = service.ListTranscriptEntriesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_transcript_entries(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListTranscriptEntriesResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.apps.meet_v2beta.ConferenceRecordsServiceClient.list_transcript_entries", + extra={ + "serviceName": "google.apps.meet.v2beta.ConferenceRecordsService", + "rpcName": "ListTranscriptEntries", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTranscripts( @@ -1594,7 +2200,7 @@ 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.ListTranscriptsResponse: r"""Call the list transcripts method over HTTP. @@ -1604,8 +2210,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ListTranscriptsResponse: @@ -1615,6 +2223,7 @@ def __call__( http_options = ( _BaseConferenceRecordsServiceRestTransport._BaseListTranscripts._get_http_options() ) + request, metadata = self._interceptor.pre_list_transcripts( request, metadata ) @@ -1627,6 +2236,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.apps.meet_v2beta.ConferenceRecordsServiceClient.ListTranscripts", + extra={ + "serviceName": "google.apps.meet.v2beta.ConferenceRecordsService", + "rpcName": "ListTranscripts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ConferenceRecordsServiceRestTransport._ListTranscripts._get_response( @@ -1649,7 +2285,29 @@ def __call__( pb_resp = service.ListTranscriptsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_transcripts(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListTranscriptsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.apps.meet_v2beta.ConferenceRecordsServiceClient.list_transcripts", + extra={ + "serviceName": "google.apps.meet.v2beta.ConferenceRecordsService", + "rpcName": "ListTranscripts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-apps-meet/google/apps/meet_v2beta/services/spaces_service/async_client.py b/packages/google-apps-meet/google/apps/meet_v2beta/services/spaces_service/async_client.py index 3e1421737e28..6f69c1d7dc59 100644 --- a/packages/google-apps-meet/google/apps/meet_v2beta/services/spaces_service/async_client.py +++ b/packages/google-apps-meet/google/apps/meet_v2beta/services/spaces_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, @@ -50,6 +51,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, SpacesServiceTransport from .transports.grpc_asyncio import SpacesServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class SpacesServiceAsyncClient: """REST API for services dealing with spaces.""" @@ -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.apps.meet_v2beta.SpacesServiceAsyncClient`.", + extra={ + "serviceName": "google.apps.meet.v2beta.SpacesService", + "universeDomain": getattr( + self._client._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._client._transport._credentials).__module__}.{type(self._client._transport._credentials).__qualname__}", + "credentialsInfo": getattr( + self.transport._credentials, "get_cred_info", lambda: None + )(), + } + if hasattr(self._client._transport, "_credentials") + else { + "serviceName": "google.apps.meet.v2beta.SpacesService", + "credentialsType": None, + }, + ) + async def create_space( self, request: Optional[Union[service.CreateSpaceRequest, dict]] = None, @@ -266,7 +298,7 @@ async def create_space( space: Optional[resource.Space] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.Space: r"""`Developer Preview `__. @@ -312,8 +344,10 @@ async def sample_create_space(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2beta.types.Space: @@ -370,7 +404,7 @@ async def get_space( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.Space: r"""`Developer Preview `__. @@ -413,8 +447,10 @@ async def sample_get_space(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2beta.types.Space: @@ -478,7 +514,7 @@ async def update_space( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.Space: r"""`Developer Preview `__. @@ -530,8 +566,10 @@ async def sample_update_space(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2beta.types.Space: @@ -598,7 +636,7 @@ async def end_active_conference( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""`Developer Preview `__. @@ -639,8 +677,10 @@ async def sample_end_active_conference(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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-apps-meet/google/apps/meet_v2beta/services/spaces_service/client.py b/packages/google-apps-meet/google/apps/meet_v2beta/services/spaces_service/client.py index 4280b547792d..407004ba42b9 100644 --- a/packages/google-apps-meet/google/apps/meet_v2beta/services/spaces_service/client.py +++ b/packages/google-apps-meet/google/apps/meet_v2beta/services/spaces_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + from google.protobuf import field_mask_pb2 # type: ignore from google.apps.meet_v2beta.types import resource, service @@ -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( @@ -650,6 +664,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.apps.meet_v2beta.SpacesServiceClient`.", + extra={ + "serviceName": "google.apps.meet.v2beta.SpacesService", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__module__}.{type(self._transport._credentials).__qualname__}", + "credentialsInfo": getattr( + self.transport._credentials, "get_cred_info", lambda: None + )(), + } + if hasattr(self._transport, "_credentials") + else { + "serviceName": "google.apps.meet.v2beta.SpacesService", + "credentialsType": None, + }, + ) + def create_space( self, request: Optional[Union[service.CreateSpaceRequest, dict]] = None, @@ -657,7 +694,7 @@ def create_space( space: Optional[resource.Space] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.Space: r"""`Developer Preview `__. @@ -703,8 +740,10 @@ def sample_create_space(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2beta.types.Space: @@ -758,7 +797,7 @@ def get_space( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.Space: r"""`Developer Preview `__. @@ -801,8 +840,10 @@ def sample_get_space(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2beta.types.Space: @@ -863,7 +904,7 @@ def update_space( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.Space: r"""`Developer Preview `__. @@ -915,8 +956,10 @@ def sample_update_space(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.apps.meet_v2beta.types.Space: @@ -980,7 +1023,7 @@ def end_active_conference( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""`Developer Preview `__. @@ -1021,8 +1064,10 @@ def sample_end_active_conference(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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-apps-meet/google/apps/meet_v2beta/services/spaces_service/transports/grpc.py b/packages/google-apps-meet/google/apps/meet_v2beta/services/spaces_service/transports/grpc.py index 95889335d306..9c6a33e1355a 100644 --- a/packages/google-apps-meet/google/apps/meet_v2beta/services/spaces_service/transports/grpc.py +++ b/packages/google-apps-meet/google/apps/meet_v2beta/services/spaces_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.apps.meet_v2beta.types import resource, service from .base import DEFAULT_CLIENT_INFO, SpacesServiceTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + + +class _LoggingClientInterceptor(grpc.UnaryUnaryClientInterceptor): # pragma: NO COVER + def intercept_unary_unary(self, continuation, client_call_details, request): + logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ) + if logging_enabled: # pragma: NO COVER + request_metadata = client_call_details.metadata + if isinstance(request, proto.Message): + request_payload = type(request).to_json(request) + elif isinstance(request, google.protobuf.message.Message): + request_payload = MessageToJson(request) + else: + request_payload = f"{type(request).__name__}: {pickle.dumps(request)}" + + request_metadata = { + key: value.decode("utf-8") if isinstance(value, bytes) else value + for key, value in request_metadata + } + grpc_request = { + "payload": request_payload, + "requestMethod": "grpc", + "metadata": dict(request_metadata), + } + _LOGGER.debug( + f"Sending request for {client_call_details.method}", + extra={ + "serviceName": "google.apps.meet.v2beta.SpacesService", + "rpcName": client_call_details.method, + "request": grpc_request, + "metadata": grpc_request["metadata"], + }, + ) + + response = continuation(client_call_details, request) + if logging_enabled: # pragma: NO COVER + response_metadata = response.trailing_metadata() + # Convert gRPC metadata `` to list of tuples + metadata = ( + dict([(k, str(v)) for k, v in response_metadata]) + if response_metadata + else None + ) + result = response.result() + if isinstance(result, proto.Message): + response_payload = type(result).to_json(result) + elif isinstance(result, google.protobuf.message.Message): + response_payload = MessageToJson(result) + else: + response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" + grpc_response = { + "payload": response_payload, + "metadata": metadata, + "status": "OK", + } + _LOGGER.debug( + f"Received response for {client_call_details.method}.", + extra={ + "serviceName": "google.apps.meet.v2beta.SpacesService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SpacesServiceGrpcTransport(SpacesServiceTransport): """gRPC backend transport for SpacesService. @@ -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 @@ -254,7 +340,7 @@ def create_space(self) -> Callable[[service.CreateSpaceRequest], resource.Space] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_space" not in self._stubs: - self._stubs["create_space"] = self.grpc_channel.unary_unary( + self._stubs["create_space"] = self._logged_channel.unary_unary( "/google.apps.meet.v2beta.SpacesService/CreateSpace", request_serializer=service.CreateSpaceRequest.serialize, response_deserializer=resource.Space.deserialize, @@ -280,7 +366,7 @@ def get_space(self) -> Callable[[service.GetSpaceRequest], resource.Space]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_space" not in self._stubs: - self._stubs["get_space"] = self.grpc_channel.unary_unary( + self._stubs["get_space"] = self._logged_channel.unary_unary( "/google.apps.meet.v2beta.SpacesService/GetSpace", request_serializer=service.GetSpaceRequest.serialize, response_deserializer=resource.Space.deserialize, @@ -306,7 +392,7 @@ def update_space(self) -> Callable[[service.UpdateSpaceRequest], resource.Space] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_space" not in self._stubs: - self._stubs["update_space"] = self.grpc_channel.unary_unary( + self._stubs["update_space"] = self._logged_channel.unary_unary( "/google.apps.meet.v2beta.SpacesService/UpdateSpace", request_serializer=service.UpdateSpaceRequest.serialize, response_deserializer=resource.Space.deserialize, @@ -334,7 +420,7 @@ def end_active_conference( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "end_active_conference" not in self._stubs: - self._stubs["end_active_conference"] = self.grpc_channel.unary_unary( + self._stubs["end_active_conference"] = self._logged_channel.unary_unary( "/google.apps.meet.v2beta.SpacesService/EndActiveConference", request_serializer=service.EndActiveConferenceRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -342,7 +428,7 @@ def end_active_conference( return self._stubs["end_active_conference"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-apps-meet/google/apps/meet_v2beta/services/spaces_service/transports/grpc_asyncio.py b/packages/google-apps-meet/google/apps/meet_v2beta/services/spaces_service/transports/grpc_asyncio.py index f5dc67364511..79986cd4c0f6 100644 --- a/packages/google-apps-meet/google/apps/meet_v2beta/services/spaces_service/transports/grpc_asyncio.py +++ b/packages/google-apps-meet/google/apps/meet_v2beta/services/spaces_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.apps.meet_v2beta.types import resource, service from .base import DEFAULT_CLIENT_INFO, SpacesServiceTransport from .grpc import SpacesServiceGrpcTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + + +class _LoggingClientAIOInterceptor( + grpc.aio.UnaryUnaryClientInterceptor +): # pragma: NO COVER + async def intercept_unary_unary(self, continuation, client_call_details, request): + logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ) + if logging_enabled: # pragma: NO COVER + request_metadata = client_call_details.metadata + if isinstance(request, proto.Message): + request_payload = type(request).to_json(request) + elif isinstance(request, google.protobuf.message.Message): + request_payload = MessageToJson(request) + else: + request_payload = f"{type(request).__name__}: {pickle.dumps(request)}" + + request_metadata = { + key: value.decode("utf-8") if isinstance(value, bytes) else value + for key, value in request_metadata + } + grpc_request = { + "payload": request_payload, + "requestMethod": "grpc", + "metadata": dict(request_metadata), + } + _LOGGER.debug( + f"Sending request for {client_call_details.method}", + extra={ + "serviceName": "google.apps.meet.v2beta.SpacesService", + "rpcName": str(client_call_details.method), + "request": grpc_request, + "metadata": grpc_request["metadata"], + }, + ) + response = await continuation(client_call_details, request) + if logging_enabled: # pragma: NO COVER + response_metadata = await response.trailing_metadata() + # Convert gRPC metadata `` to list of tuples + metadata = ( + dict([(k, str(v)) for k, v in response_metadata]) + if response_metadata + else None + ) + result = await response + if isinstance(result, proto.Message): + response_payload = type(result).to_json(result) + elif isinstance(result, google.protobuf.message.Message): + response_payload = MessageToJson(result) + else: + response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" + grpc_response = { + "payload": response_payload, + "metadata": metadata, + "status": "OK", + } + _LOGGER.debug( + f"Received response to rpc {client_call_details.method}.", + extra={ + "serviceName": "google.apps.meet.v2beta.SpacesService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SpacesServiceGrpcAsyncIOTransport(SpacesServiceTransport): """gRPC AsyncIO backend transport for SpacesService. @@ -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 @@ -264,7 +349,7 @@ def create_space( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_space" not in self._stubs: - self._stubs["create_space"] = self.grpc_channel.unary_unary( + self._stubs["create_space"] = self._logged_channel.unary_unary( "/google.apps.meet.v2beta.SpacesService/CreateSpace", request_serializer=service.CreateSpaceRequest.serialize, response_deserializer=resource.Space.deserialize, @@ -292,7 +377,7 @@ def get_space( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_space" not in self._stubs: - self._stubs["get_space"] = self.grpc_channel.unary_unary( + self._stubs["get_space"] = self._logged_channel.unary_unary( "/google.apps.meet.v2beta.SpacesService/GetSpace", request_serializer=service.GetSpaceRequest.serialize, response_deserializer=resource.Space.deserialize, @@ -320,7 +405,7 @@ def update_space( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_space" not in self._stubs: - self._stubs["update_space"] = self.grpc_channel.unary_unary( + self._stubs["update_space"] = self._logged_channel.unary_unary( "/google.apps.meet.v2beta.SpacesService/UpdateSpace", request_serializer=service.UpdateSpaceRequest.serialize, response_deserializer=resource.Space.deserialize, @@ -348,7 +433,7 @@ def end_active_conference( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "end_active_conference" not in self._stubs: - self._stubs["end_active_conference"] = self.grpc_channel.unary_unary( + self._stubs["end_active_conference"] = self._logged_channel.unary_unary( "/google.apps.meet.v2beta.SpacesService/EndActiveConference", request_serializer=service.EndActiveConferenceRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -395,7 +480,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-apps-meet/google/apps/meet_v2beta/services/spaces_service/transports/rest.py b/packages/google-apps-meet/google/apps/meet_v2beta/services/spaces_service/transports/rest.py index c53a4ddf5aa5..787194df51e0 100644 --- a/packages/google-apps-meet/google/apps/meet_v2beta/services/spaces_service/transports/rest.py +++ b/packages/google-apps-meet/google/apps/meet_v2beta/services/spaces_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, @@ -96,8 +104,10 @@ def post_update_space(self, response): """ def pre_create_space( - self, request: service.CreateSpaceRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.CreateSpaceRequest, Sequence[Tuple[str, str]]]: + self, + request: service.CreateSpaceRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.CreateSpaceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_space Override in a subclass to manipulate the request or metadata @@ -117,8 +127,10 @@ def post_create_space(self, response: resource.Space) -> resource.Space: def pre_end_active_conference( self, request: service.EndActiveConferenceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.EndActiveConferenceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.EndActiveConferenceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for end_active_conference Override in a subclass to manipulate the request or metadata @@ -127,8 +139,10 @@ def pre_end_active_conference( return request, metadata def pre_get_space( - self, request: service.GetSpaceRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetSpaceRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetSpaceRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetSpaceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_space Override in a subclass to manipulate the request or metadata @@ -146,8 +160,10 @@ def post_get_space(self, response: resource.Space) -> resource.Space: return response def pre_update_space( - self, request: service.UpdateSpaceRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.UpdateSpaceRequest, Sequence[Tuple[str, str]]]: + self, + request: service.UpdateSpaceRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.UpdateSpaceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_space Override in a subclass to manipulate the request or metadata @@ -286,7 +302,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.Space: r"""Call the create space method over HTTP. @@ -296,8 +312,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.resource.Space: @@ -312,6 +330,7 @@ def __call__( http_options = ( _BaseSpacesServiceRestTransport._BaseCreateSpace._get_http_options() ) + request, metadata = self._interceptor.pre_create_space(request, metadata) transcoded_request = _BaseSpacesServiceRestTransport._BaseCreateSpace._get_transcoded_request( http_options, request @@ -330,6 +349,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.apps.meet_v2beta.SpacesServiceClient.CreateSpace", + extra={ + "serviceName": "google.apps.meet.v2beta.SpacesService", + "rpcName": "CreateSpace", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpacesServiceRestTransport._CreateSpace._get_response( self._host, @@ -351,7 +397,29 @@ def __call__( pb_resp = resource.Space.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_space(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resource.Space.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.apps.meet_v2beta.SpacesServiceClient.create_space", + extra={ + "serviceName": "google.apps.meet.v2beta.SpacesService", + "rpcName": "CreateSpace", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _EndActiveConference( @@ -389,7 +457,7 @@ 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 end active conference method over HTTP. @@ -400,13 +468,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 = ( _BaseSpacesServiceRestTransport._BaseEndActiveConference._get_http_options() ) + request, metadata = self._interceptor.pre_end_active_conference( request, metadata ) @@ -423,6 +494,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.apps.meet_v2beta.SpacesServiceClient.EndActiveConference", + extra={ + "serviceName": "google.apps.meet.v2beta.SpacesService", + "rpcName": "EndActiveConference", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpacesServiceRestTransport._EndActiveConference._get_response( self._host, @@ -473,7 +571,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.Space: r"""Call the get space method over HTTP. @@ -483,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: ~.resource.Space: @@ -499,6 +599,7 @@ def __call__( http_options = ( _BaseSpacesServiceRestTransport._BaseGetSpace._get_http_options() ) + request, metadata = self._interceptor.pre_get_space(request, metadata) transcoded_request = ( _BaseSpacesServiceRestTransport._BaseGetSpace._get_transcoded_request( @@ -513,6 +614,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.apps.meet_v2beta.SpacesServiceClient.GetSpace", + extra={ + "serviceName": "google.apps.meet.v2beta.SpacesService", + "rpcName": "GetSpace", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpacesServiceRestTransport._GetSpace._get_response( self._host, @@ -533,7 +661,29 @@ def __call__( pb_resp = resource.Space.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_space(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resource.Space.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.apps.meet_v2beta.SpacesServiceClient.get_space", + extra={ + "serviceName": "google.apps.meet.v2beta.SpacesService", + "rpcName": "GetSpace", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSpace( @@ -571,7 +721,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resource.Space: r"""Call the update space method over HTTP. @@ -581,8 +731,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.resource.Space: @@ -597,6 +749,7 @@ def __call__( http_options = ( _BaseSpacesServiceRestTransport._BaseUpdateSpace._get_http_options() ) + request, metadata = self._interceptor.pre_update_space(request, metadata) transcoded_request = _BaseSpacesServiceRestTransport._BaseUpdateSpace._get_transcoded_request( http_options, request @@ -615,6 +768,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.apps.meet_v2beta.SpacesServiceClient.UpdateSpace", + extra={ + "serviceName": "google.apps.meet.v2beta.SpacesService", + "rpcName": "UpdateSpace", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SpacesServiceRestTransport._UpdateSpace._get_response( self._host, @@ -636,7 +816,29 @@ def __call__( pb_resp = resource.Space.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_space(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resource.Space.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.apps.meet_v2beta.SpacesServiceClient.update_space", + extra={ + "serviceName": "google.apps.meet.v2beta.SpacesService", + "rpcName": "UpdateSpace", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-apps-meet/samples/generated_samples/snippet_metadata_google.apps.meet.v2.json b/packages/google-apps-meet/samples/generated_samples/snippet_metadata_google.apps.meet.v2.json index 7c2d00f3bd03..55b2797bb589 100644 --- a/packages/google-apps-meet/samples/generated_samples/snippet_metadata_google.apps.meet.v2.json +++ b/packages/google-apps-meet/samples/generated_samples/snippet_metadata_google.apps.meet.v2.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-apps-meet", - "version": "0.1.10" + "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.apps.meet_v2.types.ConferenceRecord", @@ -127,7 +127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2.types.ConferenceRecord", @@ -208,7 +208,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2.types.ParticipantSession", @@ -288,7 +288,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2.types.ParticipantSession", @@ -369,7 +369,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2.types.Participant", @@ -449,7 +449,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2.types.Participant", @@ -530,7 +530,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2.types.Recording", @@ -610,7 +610,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2.types.Recording", @@ -691,7 +691,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2.types.TranscriptEntry", @@ -771,7 +771,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2.types.TranscriptEntry", @@ -852,7 +852,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2.types.Transcript", @@ -932,7 +932,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2.types.Transcript", @@ -1009,7 +1009,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2.services.conference_records_service.pagers.ListConferenceRecordsAsyncPager", @@ -1085,7 +1085,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2.services.conference_records_service.pagers.ListConferenceRecordsPager", @@ -1166,7 +1166,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2.services.conference_records_service.pagers.ListParticipantSessionsAsyncPager", @@ -1246,7 +1246,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2.services.conference_records_service.pagers.ListParticipantSessionsPager", @@ -1327,7 +1327,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2.services.conference_records_service.pagers.ListParticipantsAsyncPager", @@ -1407,7 +1407,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2.services.conference_records_service.pagers.ListParticipantsPager", @@ -1488,7 +1488,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2.services.conference_records_service.pagers.ListRecordingsAsyncPager", @@ -1568,7 +1568,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2.services.conference_records_service.pagers.ListRecordingsPager", @@ -1649,7 +1649,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2.services.conference_records_service.pagers.ListTranscriptEntriesAsyncPager", @@ -1729,7 +1729,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2.services.conference_records_service.pagers.ListTranscriptEntriesPager", @@ -1810,7 +1810,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2.services.conference_records_service.pagers.ListTranscriptsAsyncPager", @@ -1890,7 +1890,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2.services.conference_records_service.pagers.ListTranscriptsPager", @@ -1971,7 +1971,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2.types.Space", @@ -2051,7 +2051,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2.types.Space", @@ -2132,7 +2132,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "end_active_conference" @@ -2209,7 +2209,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "end_active_conference" @@ -2287,7 +2287,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2.types.Space", @@ -2367,7 +2367,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2.types.Space", @@ -2452,7 +2452,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2.types.Space", @@ -2536,7 +2536,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2.types.Space", diff --git a/packages/google-apps-meet/samples/generated_samples/snippet_metadata_google.apps.meet.v2beta.json b/packages/google-apps-meet/samples/generated_samples/snippet_metadata_google.apps.meet.v2beta.json index 035063797335..2dc1c5553ebd 100644 --- a/packages/google-apps-meet/samples/generated_samples/snippet_metadata_google.apps.meet.v2beta.json +++ b/packages/google-apps-meet/samples/generated_samples/snippet_metadata_google.apps.meet.v2beta.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-apps-meet", - "version": "0.1.10" + "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.apps.meet_v2beta.types.ConferenceRecord", @@ -127,7 +127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2beta.types.ConferenceRecord", @@ -208,7 +208,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2beta.types.ParticipantSession", @@ -288,7 +288,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2beta.types.ParticipantSession", @@ -369,7 +369,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2beta.types.Participant", @@ -449,7 +449,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2beta.types.Participant", @@ -530,7 +530,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2beta.types.Recording", @@ -610,7 +610,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2beta.types.Recording", @@ -691,7 +691,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2beta.types.TranscriptEntry", @@ -771,7 +771,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2beta.types.TranscriptEntry", @@ -852,7 +852,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2beta.types.Transcript", @@ -932,7 +932,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2beta.types.Transcript", @@ -1009,7 +1009,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2beta.services.conference_records_service.pagers.ListConferenceRecordsAsyncPager", @@ -1085,7 +1085,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2beta.services.conference_records_service.pagers.ListConferenceRecordsPager", @@ -1166,7 +1166,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2beta.services.conference_records_service.pagers.ListParticipantSessionsAsyncPager", @@ -1246,7 +1246,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2beta.services.conference_records_service.pagers.ListParticipantSessionsPager", @@ -1327,7 +1327,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2beta.services.conference_records_service.pagers.ListParticipantsAsyncPager", @@ -1407,7 +1407,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2beta.services.conference_records_service.pagers.ListParticipantsPager", @@ -1488,7 +1488,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2beta.services.conference_records_service.pagers.ListRecordingsAsyncPager", @@ -1568,7 +1568,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2beta.services.conference_records_service.pagers.ListRecordingsPager", @@ -1649,7 +1649,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2beta.services.conference_records_service.pagers.ListTranscriptEntriesAsyncPager", @@ -1729,7 +1729,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2beta.services.conference_records_service.pagers.ListTranscriptEntriesPager", @@ -1810,7 +1810,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2beta.services.conference_records_service.pagers.ListTranscriptsAsyncPager", @@ -1890,7 +1890,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2beta.services.conference_records_service.pagers.ListTranscriptsPager", @@ -1971,7 +1971,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2beta.types.Space", @@ -2051,7 +2051,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2beta.types.Space", @@ -2132,7 +2132,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "end_active_conference" @@ -2209,7 +2209,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "end_active_conference" @@ -2287,7 +2287,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2beta.types.Space", @@ -2367,7 +2367,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2beta.types.Space", @@ -2452,7 +2452,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2beta.types.Space", @@ -2536,7 +2536,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.apps.meet_v2beta.types.Space", diff --git a/packages/google-apps-meet/tests/unit/gapic/meet_v2/test_conference_records_service.py b/packages/google-apps-meet/tests/unit/gapic/meet_v2/test_conference_records_service.py index 3a6c0733060e..664601f75754 100644 --- a/packages/google-apps-meet/tests/unit/gapic/meet_v2/test_conference_records_service.py +++ b/packages/google-apps-meet/tests/unit/gapic/meet_v2/test_conference_records_service.py @@ -6328,6 +6328,7 @@ def test_get_conference_record_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_conference_record(request) @@ -6373,6 +6374,7 @@ def test_get_conference_record_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_conference_record(**mock_args) @@ -6606,6 +6608,7 @@ def test_get_participant_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_participant(request) @@ -6651,6 +6654,7 @@ def test_get_participant_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_participant(**mock_args) @@ -6791,6 +6795,7 @@ def test_list_participants_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_participants(request) @@ -6845,6 +6850,7 @@ def test_list_participants_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_participants(**mock_args) @@ -7041,6 +7047,7 @@ def test_get_participant_session_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_participant_session(request) @@ -7088,6 +7095,7 @@ def test_get_participant_session_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_participant_session(**mock_args) @@ -7232,6 +7240,7 @@ def test_list_participant_sessions_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_participant_sessions(request) @@ -7286,6 +7295,7 @@ def test_list_participant_sessions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_participant_sessions(**mock_args) @@ -7478,6 +7488,7 @@ def test_get_recording_rest_required_fields(request_type=service.GetRecordingReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_recording(request) @@ -7523,6 +7534,7 @@ def test_get_recording_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_recording(**mock_args) @@ -7660,6 +7672,7 @@ def test_list_recordings_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_recordings(request) @@ -7713,6 +7726,7 @@ def test_list_recordings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_recordings(**mock_args) @@ -7902,6 +7916,7 @@ def test_get_transcript_rest_required_fields(request_type=service.GetTranscriptR response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_transcript(request) @@ -7947,6 +7962,7 @@ def test_get_transcript_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_transcript(**mock_args) @@ -8086,6 +8102,7 @@ def test_list_transcripts_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_transcripts(request) @@ -8139,6 +8156,7 @@ def test_list_transcripts_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_transcripts(**mock_args) @@ -8334,6 +8352,7 @@ def test_get_transcript_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_transcript_entry(request) @@ -8381,6 +8400,7 @@ def test_get_transcript_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_transcript_entry(**mock_args) @@ -8524,6 +8544,7 @@ def test_list_transcript_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_transcript_entries(request) @@ -8577,6 +8598,7 @@ def test_list_transcript_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_transcript_entries(**mock_args) @@ -9428,6 +9450,7 @@ def test_get_conference_record_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_conference_record(request) @@ -9464,6 +9487,7 @@ def test_get_conference_record_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_conference_record(request) # Establish that the response is the type that we expect. @@ -9505,6 +9529,7 @@ def test_get_conference_record_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = resource.ConferenceRecord.to_json(resource.ConferenceRecord()) req.return_value.content = return_value @@ -9549,6 +9574,7 @@ def test_list_conference_records_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_conference_records(request) @@ -9584,6 +9610,7 @@ def test_list_conference_records_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_conference_records(request) # Establish that the response is the type that we expect. @@ -9626,6 +9653,7 @@ def test_list_conference_records_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = service.ListConferenceRecordsResponse.to_json( service.ListConferenceRecordsResponse() ) @@ -9670,6 +9698,7 @@ def test_get_participant_rest_bad_request(request_type=service.GetParticipantReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_participant(request) @@ -9705,6 +9734,7 @@ def test_get_participant_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_participant(request) # Establish that the response is the type that we expect. @@ -9743,6 +9773,7 @@ def test_get_participant_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = resource.Participant.to_json(resource.Participant()) req.return_value.content = return_value @@ -9787,6 +9818,7 @@ def test_list_participants_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_participants(request) @@ -9823,6 +9855,7 @@ def test_list_participants_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_participants(request) # Establish that the response is the type that we expect. @@ -9864,6 +9897,7 @@ def test_list_participants_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = service.ListParticipantsResponse.to_json( service.ListParticipantsResponse() ) @@ -9912,6 +9946,7 @@ def test_get_participant_session_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_participant_session(request) @@ -9949,6 +9984,7 @@ def test_get_participant_session_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_participant_session(request) # Establish that the response is the type that we expect. @@ -9991,6 +10027,7 @@ def test_get_participant_session_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = resource.ParticipantSession.to_json( resource.ParticipantSession() ) @@ -10037,6 +10074,7 @@ def test_list_participant_sessions_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_participant_sessions(request) @@ -10072,6 +10110,7 @@ def test_list_participant_sessions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_participant_sessions(request) # Establish that the response is the type that we expect. @@ -10114,6 +10153,7 @@ def test_list_participant_sessions_rest_interceptors(null_interceptor): req.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.ListParticipantSessionsResponse.to_json( service.ListParticipantSessionsResponse() ) @@ -10158,6 +10198,7 @@ def test_get_recording_rest_bad_request(request_type=service.GetRecordingRequest response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_recording(request) @@ -10194,6 +10235,7 @@ def test_get_recording_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_recording(request) # Establish that the response is the type that we expect. @@ -10233,6 +10275,7 @@ def test_get_recording_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = resource.Recording.to_json(resource.Recording()) req.return_value.content = return_value @@ -10275,6 +10318,7 @@ def test_list_recordings_rest_bad_request(request_type=service.ListRecordingsReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_recordings(request) @@ -10310,6 +10354,7 @@ def test_list_recordings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_recordings(request) # Establish that the response is the type that we expect. @@ -10348,6 +10393,7 @@ def test_list_recordings_rest_interceptors(null_interceptor): req.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.ListRecordingsResponse.to_json( service.ListRecordingsResponse() ) @@ -10392,6 +10438,7 @@ def test_get_transcript_rest_bad_request(request_type=service.GetTranscriptReque response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_transcript(request) @@ -10428,6 +10475,7 @@ def test_get_transcript_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_transcript(request) # Establish that the response is the type that we expect. @@ -10467,6 +10515,7 @@ def test_get_transcript_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = resource.Transcript.to_json(resource.Transcript()) req.return_value.content = return_value @@ -10509,6 +10558,7 @@ def test_list_transcripts_rest_bad_request(request_type=service.ListTranscriptsR response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_transcripts(request) @@ -10544,6 +10594,7 @@ def test_list_transcripts_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_transcripts(request) # Establish that the response is the type that we expect. @@ -10582,6 +10633,7 @@ def test_list_transcripts_rest_interceptors(null_interceptor): req.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.ListTranscriptsResponse.to_json( service.ListTranscriptsResponse() ) @@ -10630,6 +10682,7 @@ def test_get_transcript_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_transcript_entry(request) @@ -10670,6 +10723,7 @@ def test_get_transcript_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_transcript_entry(request) # Establish that the response is the type that we expect. @@ -10713,6 +10767,7 @@ def test_get_transcript_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 = resource.TranscriptEntry.to_json(resource.TranscriptEntry()) req.return_value.content = return_value @@ -10757,6 +10812,7 @@ def test_list_transcript_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_transcript_entries(request) @@ -10792,6 +10848,7 @@ def test_list_transcript_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_transcript_entries(request) # Establish that the response is the type that we expect. @@ -10834,6 +10891,7 @@ def test_list_transcript_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 = service.ListTranscriptEntriesResponse.to_json( service.ListTranscriptEntriesResponse() ) diff --git a/packages/google-apps-meet/tests/unit/gapic/meet_v2/test_spaces_service.py b/packages/google-apps-meet/tests/unit/gapic/meet_v2/test_spaces_service.py index d9e07ca663a9..98c5ae2f6c7d 100644 --- a/packages/google-apps-meet/tests/unit/gapic/meet_v2/test_spaces_service.py +++ b/packages/google-apps-meet/tests/unit/gapic/meet_v2/test_spaces_service.py @@ -2375,6 +2375,7 @@ def test_create_space_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_space(**mock_args) @@ -2500,6 +2501,7 @@ def test_get_space_rest_required_fields(request_type=service.GetSpaceRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_space(request) @@ -2545,6 +2547,7 @@ def test_get_space_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_space(**mock_args) @@ -2670,6 +2673,7 @@ def test_update_space_rest_required_fields(request_type=service.UpdateSpaceReque response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_space(request) @@ -2716,6 +2720,7 @@ def test_update_space_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_space(**mock_args) @@ -2849,6 +2854,7 @@ def test_end_active_conference_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.end_active_conference(request) @@ -2892,6 +2898,7 @@ def test_end_active_conference_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.end_active_conference(**mock_args) @@ -3264,6 +3271,7 @@ def test_create_space_rest_bad_request(request_type=service.CreateSpaceRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_space(request) @@ -3375,6 +3383,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_space(request) # Establish that the response is the type that we expect. @@ -3415,6 +3424,7 @@ def test_create_space_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = resource.Space.to_json(resource.Space()) req.return_value.content = return_value @@ -3457,6 +3467,7 @@ def test_get_space_rest_bad_request(request_type=service.GetSpaceRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_space(request) @@ -3494,6 +3505,7 @@ def test_get_space_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_space(request) # Establish that the response is the type that we expect. @@ -3534,6 +3546,7 @@ def test_get_space_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = resource.Space.to_json(resource.Space()) req.return_value.content = return_value @@ -3576,6 +3589,7 @@ def test_update_space_rest_bad_request(request_type=service.UpdateSpaceRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_space(request) @@ -3687,6 +3701,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_space(request) # Establish that the response is the type that we expect. @@ -3727,6 +3742,7 @@ def test_update_space_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = resource.Space.to_json(resource.Space()) req.return_value.content = return_value @@ -3771,6 +3787,7 @@ def test_end_active_conference_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.end_active_conference(request) @@ -3801,6 +3818,7 @@ def test_end_active_conference_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.end_active_conference(request) # Establish that the response is the type that we expect. @@ -3837,6 +3855,7 @@ def test_end_active_conference_rest_interceptors(null_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.EndActiveConferenceRequest() metadata = [ diff --git a/packages/google-apps-meet/tests/unit/gapic/meet_v2beta/test_conference_records_service.py b/packages/google-apps-meet/tests/unit/gapic/meet_v2beta/test_conference_records_service.py index d6473b5f7155..ce682e867b8b 100644 --- a/packages/google-apps-meet/tests/unit/gapic/meet_v2beta/test_conference_records_service.py +++ b/packages/google-apps-meet/tests/unit/gapic/meet_v2beta/test_conference_records_service.py @@ -6325,6 +6325,7 @@ def test_get_conference_record_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_conference_record(request) @@ -6370,6 +6371,7 @@ def test_get_conference_record_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_conference_record(**mock_args) @@ -6603,6 +6605,7 @@ def test_get_participant_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_participant(request) @@ -6648,6 +6651,7 @@ def test_get_participant_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_participant(**mock_args) @@ -6789,6 +6793,7 @@ def test_list_participants_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_participants(request) @@ -6843,6 +6848,7 @@ def test_list_participants_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_participants(**mock_args) @@ -7040,6 +7046,7 @@ def test_get_participant_session_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_participant_session(request) @@ -7087,6 +7094,7 @@ def test_get_participant_session_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_participant_session(**mock_args) @@ -7231,6 +7239,7 @@ def test_list_participant_sessions_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_participant_sessions(request) @@ -7285,6 +7294,7 @@ def test_list_participant_sessions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_participant_sessions(**mock_args) @@ -7477,6 +7487,7 @@ def test_get_recording_rest_required_fields(request_type=service.GetRecordingReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_recording(request) @@ -7522,6 +7533,7 @@ def test_get_recording_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_recording(**mock_args) @@ -7660,6 +7672,7 @@ def test_list_recordings_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_recordings(request) @@ -7713,6 +7726,7 @@ def test_list_recordings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_recordings(**mock_args) @@ -7903,6 +7917,7 @@ def test_get_transcript_rest_required_fields(request_type=service.GetTranscriptR response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_transcript(request) @@ -7948,6 +7963,7 @@ def test_get_transcript_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_transcript(**mock_args) @@ -8088,6 +8104,7 @@ def test_list_transcripts_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_transcripts(request) @@ -8141,6 +8158,7 @@ def test_list_transcripts_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_transcripts(**mock_args) @@ -8337,6 +8355,7 @@ def test_get_transcript_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_transcript_entry(request) @@ -8384,6 +8403,7 @@ def test_get_transcript_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_transcript_entry(**mock_args) @@ -8527,6 +8547,7 @@ def test_list_transcript_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_transcript_entries(request) @@ -8580,6 +8601,7 @@ def test_list_transcript_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_transcript_entries(**mock_args) @@ -9431,6 +9453,7 @@ def test_get_conference_record_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_conference_record(request) @@ -9467,6 +9490,7 @@ def test_get_conference_record_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_conference_record(request) # Establish that the response is the type that we expect. @@ -9508,6 +9532,7 @@ def test_get_conference_record_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = resource.ConferenceRecord.to_json(resource.ConferenceRecord()) req.return_value.content = return_value @@ -9552,6 +9577,7 @@ def test_list_conference_records_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_conference_records(request) @@ -9587,6 +9613,7 @@ def test_list_conference_records_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_conference_records(request) # Establish that the response is the type that we expect. @@ -9629,6 +9656,7 @@ def test_list_conference_records_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = service.ListConferenceRecordsResponse.to_json( service.ListConferenceRecordsResponse() ) @@ -9673,6 +9701,7 @@ def test_get_participant_rest_bad_request(request_type=service.GetParticipantReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_participant(request) @@ -9708,6 +9737,7 @@ def test_get_participant_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_participant(request) # Establish that the response is the type that we expect. @@ -9746,6 +9776,7 @@ def test_get_participant_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = resource.Participant.to_json(resource.Participant()) req.return_value.content = return_value @@ -9790,6 +9821,7 @@ def test_list_participants_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_participants(request) @@ -9826,6 +9858,7 @@ def test_list_participants_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_participants(request) # Establish that the response is the type that we expect. @@ -9867,6 +9900,7 @@ def test_list_participants_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = service.ListParticipantsResponse.to_json( service.ListParticipantsResponse() ) @@ -9915,6 +9949,7 @@ def test_get_participant_session_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_participant_session(request) @@ -9952,6 +9987,7 @@ def test_get_participant_session_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_participant_session(request) # Establish that the response is the type that we expect. @@ -9994,6 +10030,7 @@ def test_get_participant_session_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = resource.ParticipantSession.to_json( resource.ParticipantSession() ) @@ -10040,6 +10077,7 @@ def test_list_participant_sessions_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_participant_sessions(request) @@ -10075,6 +10113,7 @@ def test_list_participant_sessions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_participant_sessions(request) # Establish that the response is the type that we expect. @@ -10117,6 +10156,7 @@ def test_list_participant_sessions_rest_interceptors(null_interceptor): req.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.ListParticipantSessionsResponse.to_json( service.ListParticipantSessionsResponse() ) @@ -10161,6 +10201,7 @@ def test_get_recording_rest_bad_request(request_type=service.GetRecordingRequest response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_recording(request) @@ -10197,6 +10238,7 @@ def test_get_recording_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_recording(request) # Establish that the response is the type that we expect. @@ -10236,6 +10278,7 @@ def test_get_recording_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = resource.Recording.to_json(resource.Recording()) req.return_value.content = return_value @@ -10278,6 +10321,7 @@ def test_list_recordings_rest_bad_request(request_type=service.ListRecordingsReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_recordings(request) @@ -10313,6 +10357,7 @@ def test_list_recordings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_recordings(request) # Establish that the response is the type that we expect. @@ -10351,6 +10396,7 @@ def test_list_recordings_rest_interceptors(null_interceptor): req.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.ListRecordingsResponse.to_json( service.ListRecordingsResponse() ) @@ -10395,6 +10441,7 @@ def test_get_transcript_rest_bad_request(request_type=service.GetTranscriptReque response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_transcript(request) @@ -10431,6 +10478,7 @@ def test_get_transcript_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_transcript(request) # Establish that the response is the type that we expect. @@ -10470,6 +10518,7 @@ def test_get_transcript_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = resource.Transcript.to_json(resource.Transcript()) req.return_value.content = return_value @@ -10512,6 +10561,7 @@ def test_list_transcripts_rest_bad_request(request_type=service.ListTranscriptsR response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_transcripts(request) @@ -10547,6 +10597,7 @@ def test_list_transcripts_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_transcripts(request) # Establish that the response is the type that we expect. @@ -10585,6 +10636,7 @@ def test_list_transcripts_rest_interceptors(null_interceptor): req.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.ListTranscriptsResponse.to_json( service.ListTranscriptsResponse() ) @@ -10633,6 +10685,7 @@ def test_get_transcript_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_transcript_entry(request) @@ -10673,6 +10726,7 @@ def test_get_transcript_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_transcript_entry(request) # Establish that the response is the type that we expect. @@ -10716,6 +10770,7 @@ def test_get_transcript_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 = resource.TranscriptEntry.to_json(resource.TranscriptEntry()) req.return_value.content = return_value @@ -10760,6 +10815,7 @@ def test_list_transcript_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_transcript_entries(request) @@ -10795,6 +10851,7 @@ def test_list_transcript_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_transcript_entries(request) # Establish that the response is the type that we expect. @@ -10837,6 +10894,7 @@ def test_list_transcript_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 = service.ListTranscriptEntriesResponse.to_json( service.ListTranscriptEntriesResponse() ) diff --git a/packages/google-apps-meet/tests/unit/gapic/meet_v2beta/test_spaces_service.py b/packages/google-apps-meet/tests/unit/gapic/meet_v2beta/test_spaces_service.py index 810e4251778b..b4775ce136ba 100644 --- a/packages/google-apps-meet/tests/unit/gapic/meet_v2beta/test_spaces_service.py +++ b/packages/google-apps-meet/tests/unit/gapic/meet_v2beta/test_spaces_service.py @@ -2372,6 +2372,7 @@ def test_create_space_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_space(**mock_args) @@ -2499,6 +2500,7 @@ def test_get_space_rest_required_fields(request_type=service.GetSpaceRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_space(request) @@ -2544,6 +2546,7 @@ def test_get_space_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_space(**mock_args) @@ -2669,6 +2672,7 @@ def test_update_space_rest_required_fields(request_type=service.UpdateSpaceReque response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_space(request) @@ -2715,6 +2719,7 @@ def test_update_space_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_space(**mock_args) @@ -2848,6 +2853,7 @@ def test_end_active_conference_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.end_active_conference(request) @@ -2891,6 +2897,7 @@ def test_end_active_conference_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.end_active_conference(**mock_args) @@ -3263,6 +3270,7 @@ def test_create_space_rest_bad_request(request_type=service.CreateSpaceRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_space(request) @@ -3374,6 +3382,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_space(request) # Establish that the response is the type that we expect. @@ -3414,6 +3423,7 @@ def test_create_space_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = resource.Space.to_json(resource.Space()) req.return_value.content = return_value @@ -3456,6 +3466,7 @@ def test_get_space_rest_bad_request(request_type=service.GetSpaceRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_space(request) @@ -3493,6 +3504,7 @@ def test_get_space_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_space(request) # Establish that the response is the type that we expect. @@ -3533,6 +3545,7 @@ def test_get_space_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = resource.Space.to_json(resource.Space()) req.return_value.content = return_value @@ -3575,6 +3588,7 @@ def test_update_space_rest_bad_request(request_type=service.UpdateSpaceRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_space(request) @@ -3686,6 +3700,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_space(request) # Establish that the response is the type that we expect. @@ -3726,6 +3741,7 @@ def test_update_space_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = resource.Space.to_json(resource.Space()) req.return_value.content = return_value @@ -3770,6 +3786,7 @@ def test_end_active_conference_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.end_active_conference(request) @@ -3800,6 +3817,7 @@ def test_end_active_conference_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.end_active_conference(request) # Establish that the response is the type that we expect. @@ -3836,6 +3854,7 @@ def test_end_active_conference_rest_interceptors(null_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.EndActiveConferenceRequest() metadata = [ diff --git a/packages/google-area120-tables/google/area120/tables/gapic_version.py b/packages/google-area120-tables/google/area120/tables/gapic_version.py index 082d8f13abe1..558c8aab67c5 100644 --- a/packages/google-area120-tables/google/area120/tables/gapic_version.py +++ b/packages/google-area120-tables/google/area120/tables/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.11.13" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-area120-tables/google/area120/tables_v1alpha1/gapic_version.py b/packages/google-area120-tables/google/area120/tables_v1alpha1/gapic_version.py index 082d8f13abe1..558c8aab67c5 100644 --- a/packages/google-area120-tables/google/area120/tables_v1alpha1/gapic_version.py +++ b/packages/google-area120-tables/google/area120/tables_v1alpha1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.11.13" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_service/async_client.py b/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_service/async_client.py index 5a27331668c0..43ac7e3d35e1 100644 --- a/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_service/async_client.py +++ b/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_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, TablesServiceTransport from .transports.grpc_asyncio import TablesServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class TablesServiceAsyncClient: """The Tables Service provides an API for reading and updating tables. @@ -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.area120.tables_v1alpha1.TablesServiceAsyncClient`.", + extra={ + "serviceName": "google.area120.tables.v1alpha1.TablesService", + "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.area120.tables.v1alpha1.TablesService", + "credentialsType": None, + }, + ) + async def get_table( self, request: Optional[Union[tables.GetTableRequest, dict]] = None, @@ -281,7 +313,7 @@ async def get_table( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tables.Table: r"""Gets a table. Returns NOT_FOUND if the table does not exist. @@ -325,8 +357,10 @@ async def sample_get_table(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.area120.tables_v1alpha1.types.Table: @@ -384,7 +418,7 @@ async def list_tables( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTablesAsyncPager: r"""Lists tables for the user. @@ -421,8 +455,10 @@ async def sample_list_tables(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.area120.tables_v1alpha1.services.tables_service.pagers.ListTablesAsyncPager: @@ -477,7 +513,7 @@ async def get_workspace( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tables.Workspace: r"""Gets a workspace. Returns NOT_FOUND if the workspace does not exist. @@ -523,8 +559,10 @@ async def sample_get_workspace(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.area120.tables_v1alpha1.types.Workspace: @@ -582,7 +620,7 @@ async def list_workspaces( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListWorkspacesAsyncPager: r"""Lists workspaces for the user. @@ -619,8 +657,10 @@ async def sample_list_workspaces(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.area120.tables_v1alpha1.services.tables_service.pagers.ListWorkspacesAsyncPager: @@ -675,7 +715,7 @@ async def get_row( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tables.Row: r"""Gets a row. Returns NOT_FOUND if the row does not exist in the table. @@ -721,8 +761,10 @@ async def sample_get_row(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.area120.tables_v1alpha1.types.Row: @@ -779,7 +821,7 @@ async def list_rows( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListRowsAsyncPager: r"""Lists rows in a table. Returns NOT_FOUND if the table does not exist. @@ -825,8 +867,10 @@ async def sample_list_rows(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.area120.tables_v1alpha1.services.tables_service.pagers.ListRowsAsyncPager: @@ -902,7 +946,7 @@ async def create_row( row: Optional[tables.Row] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tables.Row: r"""Creates a row. @@ -952,8 +996,10 @@ async def sample_create_row(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.area120.tables_v1alpha1.types.Row: @@ -1013,7 +1059,7 @@ async def batch_create_rows( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tables.BatchCreateRowsResponse: r"""Creates multiple rows. @@ -1054,8 +1100,10 @@ async def sample_batch_create_rows(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.area120.tables_v1alpha1.types.BatchCreateRowsResponse: @@ -1103,7 +1151,7 @@ async def update_row( 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]]] = (), ) -> tables.Row: r"""Updates a row. @@ -1149,8 +1197,10 @@ async def sample_update_row(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.area120.tables_v1alpha1.types.Row: @@ -1210,7 +1260,7 @@ async def batch_update_rows( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tables.BatchUpdateRowsResponse: r"""Updates multiple rows. @@ -1247,8 +1297,10 @@ async def sample_batch_update_rows(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.area120.tables_v1alpha1.types.BatchUpdateRowsResponse: @@ -1295,7 +1347,7 @@ async def delete_row( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 row. @@ -1337,8 +1389,10 @@ async def sample_delete_row(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -1389,7 +1443,7 @@ async def batch_delete_rows( *, retry: OptionalRetry = gapic_v1.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 multiple rows. @@ -1424,8 +1478,10 @@ async def sample_batch_delete_rows(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 diff --git a/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_service/client.py b/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_service/client.py index 3da7cb1d546b..7bd8ef7f2863 100644 --- a/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_service/client.py +++ b/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + from google.protobuf import field_mask_pb2 # type: ignore from google.area120.tables_v1alpha1.services.tables_service import pagers @@ -617,6 +627,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( @@ -682,6 +696,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.area120.tables_v1alpha1.TablesServiceClient`.", + extra={ + "serviceName": "google.area120.tables.v1alpha1.TablesService", + "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.area120.tables.v1alpha1.TablesService", + "credentialsType": None, + }, + ) + def get_table( self, request: Optional[Union[tables.GetTableRequest, dict]] = None, @@ -689,7 +726,7 @@ def get_table( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tables.Table: r"""Gets a table. Returns NOT_FOUND if the table does not exist. @@ -733,8 +770,10 @@ def sample_get_table(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.area120.tables_v1alpha1.types.Table: @@ -789,7 +828,7 @@ def list_tables( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTablesPager: r"""Lists tables for the user. @@ -826,8 +865,10 @@ def sample_list_tables(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.area120.tables_v1alpha1.services.tables_service.pagers.ListTablesPager: @@ -880,7 +921,7 @@ def get_workspace( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tables.Workspace: r"""Gets a workspace. Returns NOT_FOUND if the workspace does not exist. @@ -926,8 +967,10 @@ def sample_get_workspace(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.area120.tables_v1alpha1.types.Workspace: @@ -982,7 +1025,7 @@ def list_workspaces( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListWorkspacesPager: r"""Lists workspaces for the user. @@ -1019,8 +1062,10 @@ def sample_list_workspaces(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.area120.tables_v1alpha1.services.tables_service.pagers.ListWorkspacesPager: @@ -1073,7 +1118,7 @@ def get_row( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tables.Row: r"""Gets a row. Returns NOT_FOUND if the row does not exist in the table. @@ -1119,8 +1164,10 @@ def sample_get_row(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.area120.tables_v1alpha1.types.Row: @@ -1176,7 +1223,7 @@ def list_rows( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListRowsPager: r"""Lists rows in a table. Returns NOT_FOUND if the table does not exist. @@ -1222,8 +1269,10 @@ def sample_list_rows(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.area120.tables_v1alpha1.services.tables_service.pagers.ListRowsPager: @@ -1296,7 +1345,7 @@ def create_row( row: Optional[tables.Row] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tables.Row: r"""Creates a row. @@ -1346,8 +1395,10 @@ def sample_create_row(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.area120.tables_v1alpha1.types.Row: @@ -1404,7 +1455,7 @@ def batch_create_rows( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tables.BatchCreateRowsResponse: r"""Creates multiple rows. @@ -1445,8 +1496,10 @@ def sample_batch_create_rows(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.area120.tables_v1alpha1.types.BatchCreateRowsResponse: @@ -1492,7 +1545,7 @@ def update_row( 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]]] = (), ) -> tables.Row: r"""Updates a row. @@ -1538,8 +1591,10 @@ def sample_update_row(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.area120.tables_v1alpha1.types.Row: @@ -1596,7 +1651,7 @@ def batch_update_rows( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tables.BatchUpdateRowsResponse: r"""Updates multiple rows. @@ -1633,8 +1688,10 @@ def sample_batch_update_rows(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.area120.tables_v1alpha1.types.BatchUpdateRowsResponse: @@ -1679,7 +1736,7 @@ def delete_row( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 row. @@ -1721,8 +1778,10 @@ def sample_delete_row(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -1770,7 +1829,7 @@ def batch_delete_rows( *, retry: OptionalRetry = gapic_v1.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 multiple rows. @@ -1805,8 +1864,10 @@ def sample_batch_delete_rows(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 diff --git a/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_service/pagers.py b/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_service/pagers.py index b1f8b5a83c96..66813ea7186f 100644 --- a/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_service/pagers.py +++ b/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_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 = tables.ListTablesRequest(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 = tables.ListTablesRequest(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 = tables.ListWorkspacesRequest(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 = tables.ListWorkspacesRequest(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 = tables.ListRowsRequest(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 = tables.ListRowsRequest(request) diff --git a/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_service/transports/grpc.py b/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_service/transports/grpc.py index a9ac04d8e317..38dc8aa730e5 100644 --- a/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_service/transports/grpc.py +++ b/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_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.area120.tables_v1alpha1.types import tables from .base import DEFAULT_CLIENT_INFO, TablesServiceTransport +try: + from google.api_core import client_logging # 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.area120.tables.v1alpha1.TablesService", + "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.area120.tables.v1alpha1.TablesService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TablesServiceGrpcTransport(TablesServiceTransport): """gRPC backend transport for TablesService. @@ -193,7 +274,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientInterceptor() + self._logged_channel = grpc.intercept_channel( + self._grpc_channel, self._interceptor + ) + + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @classmethod @@ -265,7 +351,7 @@ def get_table(self) -> Callable[[tables.GetTableRequest], tables.Table]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_table" not in self._stubs: - self._stubs["get_table"] = self.grpc_channel.unary_unary( + self._stubs["get_table"] = self._logged_channel.unary_unary( "/google.area120.tables.v1alpha1.TablesService/GetTable", request_serializer=tables.GetTableRequest.serialize, response_deserializer=tables.Table.deserialize, @@ -291,7 +377,7 @@ def list_tables( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_tables" not in self._stubs: - self._stubs["list_tables"] = self.grpc_channel.unary_unary( + self._stubs["list_tables"] = self._logged_channel.unary_unary( "/google.area120.tables.v1alpha1.TablesService/ListTables", request_serializer=tables.ListTablesRequest.serialize, response_deserializer=tables.ListTablesResponse.deserialize, @@ -316,7 +402,7 @@ def get_workspace(self) -> Callable[[tables.GetWorkspaceRequest], tables.Workspa # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workspace" not in self._stubs: - self._stubs["get_workspace"] = self.grpc_channel.unary_unary( + self._stubs["get_workspace"] = self._logged_channel.unary_unary( "/google.area120.tables.v1alpha1.TablesService/GetWorkspace", request_serializer=tables.GetWorkspaceRequest.serialize, response_deserializer=tables.Workspace.deserialize, @@ -342,7 +428,7 @@ def list_workspaces( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workspaces" not in self._stubs: - self._stubs["list_workspaces"] = self.grpc_channel.unary_unary( + self._stubs["list_workspaces"] = self._logged_channel.unary_unary( "/google.area120.tables.v1alpha1.TablesService/ListWorkspaces", request_serializer=tables.ListWorkspacesRequest.serialize, response_deserializer=tables.ListWorkspacesResponse.deserialize, @@ -367,7 +453,7 @@ def get_row(self) -> Callable[[tables.GetRowRequest], tables.Row]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_row" not in self._stubs: - self._stubs["get_row"] = self.grpc_channel.unary_unary( + self._stubs["get_row"] = self._logged_channel.unary_unary( "/google.area120.tables.v1alpha1.TablesService/GetRow", request_serializer=tables.GetRowRequest.serialize, response_deserializer=tables.Row.deserialize, @@ -392,7 +478,7 @@ def list_rows(self) -> Callable[[tables.ListRowsRequest], tables.ListRowsRespons # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_rows" not in self._stubs: - self._stubs["list_rows"] = self.grpc_channel.unary_unary( + self._stubs["list_rows"] = self._logged_channel.unary_unary( "/google.area120.tables.v1alpha1.TablesService/ListRows", request_serializer=tables.ListRowsRequest.serialize, response_deserializer=tables.ListRowsResponse.deserialize, @@ -416,7 +502,7 @@ def create_row(self) -> Callable[[tables.CreateRowRequest], tables.Row]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_row" not in self._stubs: - self._stubs["create_row"] = self.grpc_channel.unary_unary( + self._stubs["create_row"] = self._logged_channel.unary_unary( "/google.area120.tables.v1alpha1.TablesService/CreateRow", request_serializer=tables.CreateRowRequest.serialize, response_deserializer=tables.Row.deserialize, @@ -442,7 +528,7 @@ def batch_create_rows( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_create_rows" not in self._stubs: - self._stubs["batch_create_rows"] = self.grpc_channel.unary_unary( + self._stubs["batch_create_rows"] = self._logged_channel.unary_unary( "/google.area120.tables.v1alpha1.TablesService/BatchCreateRows", request_serializer=tables.BatchCreateRowsRequest.serialize, response_deserializer=tables.BatchCreateRowsResponse.deserialize, @@ -466,7 +552,7 @@ def update_row(self) -> Callable[[tables.UpdateRowRequest], tables.Row]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_row" not in self._stubs: - self._stubs["update_row"] = self.grpc_channel.unary_unary( + self._stubs["update_row"] = self._logged_channel.unary_unary( "/google.area120.tables.v1alpha1.TablesService/UpdateRow", request_serializer=tables.UpdateRowRequest.serialize, response_deserializer=tables.Row.deserialize, @@ -492,7 +578,7 @@ def batch_update_rows( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_update_rows" not in self._stubs: - self._stubs["batch_update_rows"] = self.grpc_channel.unary_unary( + self._stubs["batch_update_rows"] = self._logged_channel.unary_unary( "/google.area120.tables.v1alpha1.TablesService/BatchUpdateRows", request_serializer=tables.BatchUpdateRowsRequest.serialize, response_deserializer=tables.BatchUpdateRowsResponse.deserialize, @@ -516,7 +602,7 @@ def delete_row(self) -> Callable[[tables.DeleteRowRequest], empty_pb2.Empty]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_row" not in self._stubs: - self._stubs["delete_row"] = self.grpc_channel.unary_unary( + self._stubs["delete_row"] = self._logged_channel.unary_unary( "/google.area120.tables.v1alpha1.TablesService/DeleteRow", request_serializer=tables.DeleteRowRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -542,7 +628,7 @@ def batch_delete_rows( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_delete_rows" not in self._stubs: - self._stubs["batch_delete_rows"] = self.grpc_channel.unary_unary( + self._stubs["batch_delete_rows"] = self._logged_channel.unary_unary( "/google.area120.tables.v1alpha1.TablesService/BatchDeleteRows", request_serializer=tables.BatchDeleteRowsRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -550,7 +636,7 @@ def batch_delete_rows( return self._stubs["batch_delete_rows"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_service/transports/grpc_asyncio.py b/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_service/transports/grpc_asyncio.py index bcc3044d83f2..ecf64d7f8a56 100644 --- a/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_service/transports/grpc_asyncio.py +++ b/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_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.area120.tables_v1alpha1.types import tables from .base import DEFAULT_CLIENT_INFO, TablesServiceTransport from .grpc import TablesServiceGrpcTransport +try: + from google.api_core import client_logging # 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.area120.tables.v1alpha1.TablesService", + "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.area120.tables.v1alpha1.TablesService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TablesServiceGrpcAsyncIOTransport(TablesServiceTransport): """gRPC AsyncIO backend transport for TablesService. @@ -240,10 +322,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientAIOInterceptor() + self._grpc_channel._unary_unary_interceptors.append(self._interceptor) + self._logged_channel = self._grpc_channel self._wrap_with_kind = ( "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters ) + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @property @@ -273,7 +358,7 @@ def get_table(self) -> Callable[[tables.GetTableRequest], Awaitable[tables.Table # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_table" not in self._stubs: - self._stubs["get_table"] = self.grpc_channel.unary_unary( + self._stubs["get_table"] = self._logged_channel.unary_unary( "/google.area120.tables.v1alpha1.TablesService/GetTable", request_serializer=tables.GetTableRequest.serialize, response_deserializer=tables.Table.deserialize, @@ -299,7 +384,7 @@ def list_tables( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_tables" not in self._stubs: - self._stubs["list_tables"] = self.grpc_channel.unary_unary( + self._stubs["list_tables"] = self._logged_channel.unary_unary( "/google.area120.tables.v1alpha1.TablesService/ListTables", request_serializer=tables.ListTablesRequest.serialize, response_deserializer=tables.ListTablesResponse.deserialize, @@ -326,7 +411,7 @@ def get_workspace( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workspace" not in self._stubs: - self._stubs["get_workspace"] = self.grpc_channel.unary_unary( + self._stubs["get_workspace"] = self._logged_channel.unary_unary( "/google.area120.tables.v1alpha1.TablesService/GetWorkspace", request_serializer=tables.GetWorkspaceRequest.serialize, response_deserializer=tables.Workspace.deserialize, @@ -354,7 +439,7 @@ def list_workspaces( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workspaces" not in self._stubs: - self._stubs["list_workspaces"] = self.grpc_channel.unary_unary( + self._stubs["list_workspaces"] = self._logged_channel.unary_unary( "/google.area120.tables.v1alpha1.TablesService/ListWorkspaces", request_serializer=tables.ListWorkspacesRequest.serialize, response_deserializer=tables.ListWorkspacesResponse.deserialize, @@ -379,7 +464,7 @@ def get_row(self) -> Callable[[tables.GetRowRequest], Awaitable[tables.Row]]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_row" not in self._stubs: - self._stubs["get_row"] = self.grpc_channel.unary_unary( + self._stubs["get_row"] = self._logged_channel.unary_unary( "/google.area120.tables.v1alpha1.TablesService/GetRow", request_serializer=tables.GetRowRequest.serialize, response_deserializer=tables.Row.deserialize, @@ -406,7 +491,7 @@ def list_rows( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_rows" not in self._stubs: - self._stubs["list_rows"] = self.grpc_channel.unary_unary( + self._stubs["list_rows"] = self._logged_channel.unary_unary( "/google.area120.tables.v1alpha1.TablesService/ListRows", request_serializer=tables.ListRowsRequest.serialize, response_deserializer=tables.ListRowsResponse.deserialize, @@ -430,7 +515,7 @@ def create_row(self) -> Callable[[tables.CreateRowRequest], Awaitable[tables.Row # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_row" not in self._stubs: - self._stubs["create_row"] = self.grpc_channel.unary_unary( + self._stubs["create_row"] = self._logged_channel.unary_unary( "/google.area120.tables.v1alpha1.TablesService/CreateRow", request_serializer=tables.CreateRowRequest.serialize, response_deserializer=tables.Row.deserialize, @@ -458,7 +543,7 @@ def batch_create_rows( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_create_rows" not in self._stubs: - self._stubs["batch_create_rows"] = self.grpc_channel.unary_unary( + self._stubs["batch_create_rows"] = self._logged_channel.unary_unary( "/google.area120.tables.v1alpha1.TablesService/BatchCreateRows", request_serializer=tables.BatchCreateRowsRequest.serialize, response_deserializer=tables.BatchCreateRowsResponse.deserialize, @@ -482,7 +567,7 @@ def update_row(self) -> Callable[[tables.UpdateRowRequest], Awaitable[tables.Row # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_row" not in self._stubs: - self._stubs["update_row"] = self.grpc_channel.unary_unary( + self._stubs["update_row"] = self._logged_channel.unary_unary( "/google.area120.tables.v1alpha1.TablesService/UpdateRow", request_serializer=tables.UpdateRowRequest.serialize, response_deserializer=tables.Row.deserialize, @@ -510,7 +595,7 @@ def batch_update_rows( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_update_rows" not in self._stubs: - self._stubs["batch_update_rows"] = self.grpc_channel.unary_unary( + self._stubs["batch_update_rows"] = self._logged_channel.unary_unary( "/google.area120.tables.v1alpha1.TablesService/BatchUpdateRows", request_serializer=tables.BatchUpdateRowsRequest.serialize, response_deserializer=tables.BatchUpdateRowsResponse.deserialize, @@ -536,7 +621,7 @@ def delete_row( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_row" not in self._stubs: - self._stubs["delete_row"] = self.grpc_channel.unary_unary( + self._stubs["delete_row"] = self._logged_channel.unary_unary( "/google.area120.tables.v1alpha1.TablesService/DeleteRow", request_serializer=tables.DeleteRowRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -562,7 +647,7 @@ def batch_delete_rows( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_delete_rows" not in self._stubs: - self._stubs["batch_delete_rows"] = self.grpc_channel.unary_unary( + self._stubs["batch_delete_rows"] = self._logged_channel.unary_unary( "/google.area120.tables.v1alpha1.TablesService/BatchDeleteRows", request_serializer=tables.BatchDeleteRowsRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -640,7 +725,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-area120-tables/google/area120/tables_v1alpha1/services/tables_service/transports/rest.py b/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_service/transports/rest.py index 4797cacd12c1..deb037e7c0af 100644 --- a/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_service/transports/rest.py +++ b/packages/google-area120-tables/google/area120/tables_v1alpha1/services/tables_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, @@ -158,8 +166,8 @@ def post_update_row(self, response): def pre_batch_create_rows( self, request: tables.BatchCreateRowsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[tables.BatchCreateRowsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[tables.BatchCreateRowsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for batch_create_rows Override in a subclass to manipulate the request or metadata @@ -181,8 +189,8 @@ def post_batch_create_rows( def pre_batch_delete_rows( self, request: tables.BatchDeleteRowsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[tables.BatchDeleteRowsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[tables.BatchDeleteRowsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for batch_delete_rows Override in a subclass to manipulate the request or metadata @@ -193,8 +201,8 @@ def pre_batch_delete_rows( def pre_batch_update_rows( self, request: tables.BatchUpdateRowsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[tables.BatchUpdateRowsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[tables.BatchUpdateRowsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for batch_update_rows Override in a subclass to manipulate the request or metadata @@ -214,8 +222,10 @@ def post_batch_update_rows( return response def pre_create_row( - self, request: tables.CreateRowRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[tables.CreateRowRequest, Sequence[Tuple[str, str]]]: + self, + request: tables.CreateRowRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[tables.CreateRowRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_row Override in a subclass to manipulate the request or metadata @@ -233,8 +243,10 @@ def post_create_row(self, response: tables.Row) -> tables.Row: return response def pre_delete_row( - self, request: tables.DeleteRowRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[tables.DeleteRowRequest, Sequence[Tuple[str, str]]]: + self, + request: tables.DeleteRowRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[tables.DeleteRowRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_row Override in a subclass to manipulate the request or metadata @@ -243,8 +255,10 @@ def pre_delete_row( return request, metadata def pre_get_row( - self, request: tables.GetRowRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[tables.GetRowRequest, Sequence[Tuple[str, str]]]: + self, + request: tables.GetRowRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[tables.GetRowRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_row Override in a subclass to manipulate the request or metadata @@ -262,8 +276,10 @@ def post_get_row(self, response: tables.Row) -> tables.Row: return response def pre_get_table( - self, request: tables.GetTableRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[tables.GetTableRequest, Sequence[Tuple[str, str]]]: + self, + request: tables.GetTableRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[tables.GetTableRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_table Override in a subclass to manipulate the request or metadata @@ -281,8 +297,10 @@ def post_get_table(self, response: tables.Table) -> tables.Table: return response def pre_get_workspace( - self, request: tables.GetWorkspaceRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[tables.GetWorkspaceRequest, Sequence[Tuple[str, str]]]: + self, + request: tables.GetWorkspaceRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[tables.GetWorkspaceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_workspace Override in a subclass to manipulate the request or metadata @@ -300,8 +318,10 @@ def post_get_workspace(self, response: tables.Workspace) -> tables.Workspace: return response def pre_list_rows( - self, request: tables.ListRowsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[tables.ListRowsRequest, Sequence[Tuple[str, str]]]: + self, + request: tables.ListRowsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[tables.ListRowsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_rows Override in a subclass to manipulate the request or metadata @@ -321,8 +341,10 @@ def post_list_rows( return response def pre_list_tables( - self, request: tables.ListTablesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[tables.ListTablesRequest, Sequence[Tuple[str, str]]]: + self, + request: tables.ListTablesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[tables.ListTablesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_tables Override in a subclass to manipulate the request or metadata @@ -342,8 +364,10 @@ def post_list_tables( return response def pre_list_workspaces( - self, request: tables.ListWorkspacesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[tables.ListWorkspacesRequest, Sequence[Tuple[str, str]]]: + self, + request: tables.ListWorkspacesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[tables.ListWorkspacesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_workspaces Override in a subclass to manipulate the request or metadata @@ -363,8 +387,10 @@ def post_list_workspaces( return response def pre_update_row( - self, request: tables.UpdateRowRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[tables.UpdateRowRequest, Sequence[Tuple[str, str]]]: + self, + request: tables.UpdateRowRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[tables.UpdateRowRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_row Override in a subclass to manipulate the request or metadata @@ -516,7 +542,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tables.BatchCreateRowsResponse: r"""Call the batch create rows method over HTTP. @@ -527,8 +553,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.tables.BatchCreateRowsResponse: @@ -540,6 +568,7 @@ def __call__( http_options = ( _BaseTablesServiceRestTransport._BaseBatchCreateRows._get_http_options() ) + request, metadata = self._interceptor.pre_batch_create_rows( request, metadata ) @@ -556,6 +585,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.area120.tables_v1alpha1.TablesServiceClient.BatchCreateRows", + extra={ + "serviceName": "google.area120.tables.v1alpha1.TablesService", + "rpcName": "BatchCreateRows", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TablesServiceRestTransport._BatchCreateRows._get_response( self._host, @@ -577,7 +633,29 @@ def __call__( pb_resp = tables.BatchCreateRowsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_create_rows(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = tables.BatchCreateRowsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.area120.tables_v1alpha1.TablesServiceClient.batch_create_rows", + extra={ + "serviceName": "google.area120.tables.v1alpha1.TablesService", + "rpcName": "BatchCreateRows", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchDeleteRows( @@ -615,7 +693,7 @@ 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 delete rows method over HTTP. @@ -626,13 +704,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 = ( _BaseTablesServiceRestTransport._BaseBatchDeleteRows._get_http_options() ) + request, metadata = self._interceptor.pre_batch_delete_rows( request, metadata ) @@ -649,6 +730,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.area120.tables_v1alpha1.TablesServiceClient.BatchDeleteRows", + extra={ + "serviceName": "google.area120.tables.v1alpha1.TablesService", + "rpcName": "BatchDeleteRows", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TablesServiceRestTransport._BatchDeleteRows._get_response( self._host, @@ -700,7 +808,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tables.BatchUpdateRowsResponse: r"""Call the batch update rows method over HTTP. @@ -711,8 +819,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.tables.BatchUpdateRowsResponse: @@ -724,6 +834,7 @@ def __call__( http_options = ( _BaseTablesServiceRestTransport._BaseBatchUpdateRows._get_http_options() ) + request, metadata = self._interceptor.pre_batch_update_rows( request, metadata ) @@ -740,6 +851,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.area120.tables_v1alpha1.TablesServiceClient.BatchUpdateRows", + extra={ + "serviceName": "google.area120.tables.v1alpha1.TablesService", + "rpcName": "BatchUpdateRows", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TablesServiceRestTransport._BatchUpdateRows._get_response( self._host, @@ -761,7 +899,29 @@ def __call__( pb_resp = tables.BatchUpdateRowsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_update_rows(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = tables.BatchUpdateRowsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.area120.tables_v1alpha1.TablesServiceClient.batch_update_rows", + extra={ + "serviceName": "google.area120.tables.v1alpha1.TablesService", + "rpcName": "BatchUpdateRows", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateRow( @@ -799,7 +959,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tables.Row: r"""Call the create row method over HTTP. @@ -810,8 +970,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.tables.Row: @@ -821,6 +983,7 @@ def __call__( http_options = ( _BaseTablesServiceRestTransport._BaseCreateRow._get_http_options() ) + request, metadata = self._interceptor.pre_create_row(request, metadata) transcoded_request = ( _BaseTablesServiceRestTransport._BaseCreateRow._get_transcoded_request( @@ -841,6 +1004,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.area120.tables_v1alpha1.TablesServiceClient.CreateRow", + extra={ + "serviceName": "google.area120.tables.v1alpha1.TablesService", + "rpcName": "CreateRow", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TablesServiceRestTransport._CreateRow._get_response( self._host, @@ -862,7 +1052,29 @@ def __call__( pb_resp = tables.Row.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_row(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = tables.Row.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.area120.tables_v1alpha1.TablesServiceClient.create_row", + extra={ + "serviceName": "google.area120.tables.v1alpha1.TablesService", + "rpcName": "CreateRow", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteRow( @@ -899,7 +1111,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete row method over HTTP. @@ -910,13 +1122,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 = ( _BaseTablesServiceRestTransport._BaseDeleteRow._get_http_options() ) + request, metadata = self._interceptor.pre_delete_row(request, metadata) transcoded_request = ( _BaseTablesServiceRestTransport._BaseDeleteRow._get_transcoded_request( @@ -931,6 +1146,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.area120.tables_v1alpha1.TablesServiceClient.DeleteRow", + extra={ + "serviceName": "google.area120.tables.v1alpha1.TablesService", + "rpcName": "DeleteRow", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TablesServiceRestTransport._DeleteRow._get_response( self._host, @@ -978,7 +1220,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tables.Row: r"""Call the get row method over HTTP. @@ -989,8 +1231,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.tables.Row: @@ -1000,6 +1244,7 @@ def __call__( http_options = ( _BaseTablesServiceRestTransport._BaseGetRow._get_http_options() ) + request, metadata = self._interceptor.pre_get_row(request, metadata) transcoded_request = ( _BaseTablesServiceRestTransport._BaseGetRow._get_transcoded_request( @@ -1014,6 +1259,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.area120.tables_v1alpha1.TablesServiceClient.GetRow", + extra={ + "serviceName": "google.area120.tables.v1alpha1.TablesService", + "rpcName": "GetRow", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TablesServiceRestTransport._GetRow._get_response( self._host, @@ -1034,7 +1306,29 @@ def __call__( pb_resp = tables.Row.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_row(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = tables.Row.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.area120.tables_v1alpha1.TablesServiceClient.get_row", + extra={ + "serviceName": "google.area120.tables.v1alpha1.TablesService", + "rpcName": "GetRow", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetTable( @@ -1071,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]]] = (), ) -> tables.Table: r"""Call the get table method over HTTP. @@ -1082,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: ~.tables.Table: @@ -1093,6 +1389,7 @@ def __call__( http_options = ( _BaseTablesServiceRestTransport._BaseGetTable._get_http_options() ) + request, metadata = self._interceptor.pre_get_table(request, metadata) transcoded_request = ( _BaseTablesServiceRestTransport._BaseGetTable._get_transcoded_request( @@ -1107,6 +1404,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.area120.tables_v1alpha1.TablesServiceClient.GetTable", + extra={ + "serviceName": "google.area120.tables.v1alpha1.TablesService", + "rpcName": "GetTable", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TablesServiceRestTransport._GetTable._get_response( self._host, @@ -1127,7 +1451,29 @@ def __call__( pb_resp = tables.Table.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_table(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = tables.Table.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.area120.tables_v1alpha1.TablesServiceClient.get_table", + extra={ + "serviceName": "google.area120.tables.v1alpha1.TablesService", + "rpcName": "GetTable", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetWorkspace( @@ -1164,7 +1510,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tables.Workspace: r"""Call the get workspace method over HTTP. @@ -1175,8 +1521,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.tables.Workspace: @@ -1186,6 +1534,7 @@ def __call__( http_options = ( _BaseTablesServiceRestTransport._BaseGetWorkspace._get_http_options() ) + request, metadata = self._interceptor.pre_get_workspace(request, metadata) transcoded_request = _BaseTablesServiceRestTransport._BaseGetWorkspace._get_transcoded_request( http_options, request @@ -1196,6 +1545,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.area120.tables_v1alpha1.TablesServiceClient.GetWorkspace", + extra={ + "serviceName": "google.area120.tables.v1alpha1.TablesService", + "rpcName": "GetWorkspace", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TablesServiceRestTransport._GetWorkspace._get_response( self._host, @@ -1216,7 +1592,29 @@ def __call__( pb_resp = tables.Workspace.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_workspace(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = tables.Workspace.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.area120.tables_v1alpha1.TablesServiceClient.get_workspace", + extra={ + "serviceName": "google.area120.tables.v1alpha1.TablesService", + "rpcName": "GetWorkspace", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListRows( @@ -1253,7 +1651,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tables.ListRowsResponse: r"""Call the list rows method over HTTP. @@ -1264,8 +1662,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.tables.ListRowsResponse: @@ -1277,6 +1677,7 @@ def __call__( http_options = ( _BaseTablesServiceRestTransport._BaseListRows._get_http_options() ) + request, metadata = self._interceptor.pre_list_rows(request, metadata) transcoded_request = ( _BaseTablesServiceRestTransport._BaseListRows._get_transcoded_request( @@ -1291,6 +1692,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.area120.tables_v1alpha1.TablesServiceClient.ListRows", + extra={ + "serviceName": "google.area120.tables.v1alpha1.TablesService", + "rpcName": "ListRows", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TablesServiceRestTransport._ListRows._get_response( self._host, @@ -1311,7 +1739,29 @@ def __call__( pb_resp = tables.ListRowsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_rows(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = tables.ListRowsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.area120.tables_v1alpha1.TablesServiceClient.list_rows", + extra={ + "serviceName": "google.area120.tables.v1alpha1.TablesService", + "rpcName": "ListRows", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTables( @@ -1348,7 +1798,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tables.ListTablesResponse: r"""Call the list tables method over HTTP. @@ -1359,8 +1809,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.tables.ListTablesResponse: @@ -1372,6 +1824,7 @@ def __call__( http_options = ( _BaseTablesServiceRestTransport._BaseListTables._get_http_options() ) + request, metadata = self._interceptor.pre_list_tables(request, metadata) transcoded_request = ( _BaseTablesServiceRestTransport._BaseListTables._get_transcoded_request( @@ -1386,6 +1839,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.area120.tables_v1alpha1.TablesServiceClient.ListTables", + extra={ + "serviceName": "google.area120.tables.v1alpha1.TablesService", + "rpcName": "ListTables", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TablesServiceRestTransport._ListTables._get_response( self._host, @@ -1406,7 +1886,29 @@ def __call__( pb_resp = tables.ListTablesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_tables(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = tables.ListTablesResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.area120.tables_v1alpha1.TablesServiceClient.list_tables", + extra={ + "serviceName": "google.area120.tables.v1alpha1.TablesService", + "rpcName": "ListTables", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListWorkspaces( @@ -1443,7 +1945,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tables.ListWorkspacesResponse: r"""Call the list workspaces method over HTTP. @@ -1454,8 +1956,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.tables.ListWorkspacesResponse: @@ -1467,6 +1971,7 @@ def __call__( http_options = ( _BaseTablesServiceRestTransport._BaseListWorkspaces._get_http_options() ) + request, metadata = self._interceptor.pre_list_workspaces(request, metadata) transcoded_request = _BaseTablesServiceRestTransport._BaseListWorkspaces._get_transcoded_request( http_options, request @@ -1477,6 +1982,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.area120.tables_v1alpha1.TablesServiceClient.ListWorkspaces", + extra={ + "serviceName": "google.area120.tables.v1alpha1.TablesService", + "rpcName": "ListWorkspaces", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TablesServiceRestTransport._ListWorkspaces._get_response( self._host, @@ -1497,7 +2029,29 @@ def __call__( pb_resp = tables.ListWorkspacesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_workspaces(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = tables.ListWorkspacesResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.area120.tables_v1alpha1.TablesServiceClient.list_workspaces", + extra={ + "serviceName": "google.area120.tables.v1alpha1.TablesService", + "rpcName": "ListWorkspaces", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateRow( @@ -1535,7 +2089,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tables.Row: r"""Call the update row method over HTTP. @@ -1546,8 +2100,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.tables.Row: @@ -1557,6 +2113,7 @@ def __call__( http_options = ( _BaseTablesServiceRestTransport._BaseUpdateRow._get_http_options() ) + request, metadata = self._interceptor.pre_update_row(request, metadata) transcoded_request = ( _BaseTablesServiceRestTransport._BaseUpdateRow._get_transcoded_request( @@ -1577,6 +2134,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.area120.tables_v1alpha1.TablesServiceClient.UpdateRow", + extra={ + "serviceName": "google.area120.tables.v1alpha1.TablesService", + "rpcName": "UpdateRow", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = TablesServiceRestTransport._UpdateRow._get_response( self._host, @@ -1598,7 +2182,29 @@ def __call__( pb_resp = tables.Row.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_row(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = tables.Row.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.area120.tables_v1alpha1.TablesServiceClient.update_row", + extra={ + "serviceName": "google.area120.tables.v1alpha1.TablesService", + "rpcName": "UpdateRow", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-area120-tables/samples/generated_samples/snippet_metadata_google.area120.tables.v1alpha1.json b/packages/google-area120-tables/samples/generated_samples/snippet_metadata_google.area120.tables.v1alpha1.json index a436ed8a890c..5a5c20778494 100644 --- a/packages/google-area120-tables/samples/generated_samples/snippet_metadata_google.area120.tables.v1alpha1.json +++ b/packages/google-area120-tables/samples/generated_samples/snippet_metadata_google.area120.tables.v1alpha1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-area120-tables", - "version": "0.11.13" + "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.area120.tables_v1alpha1.types.BatchCreateRowsResponse", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.area120.tables_v1alpha1.types.BatchCreateRowsResponse", @@ -196,7 +196,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "batch_delete_rows" @@ -269,7 +269,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "batch_delete_rows" @@ -343,7 +343,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.area120.tables_v1alpha1.types.BatchUpdateRowsResponse", @@ -419,7 +419,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.area120.tables_v1alpha1.types.BatchUpdateRowsResponse", @@ -504,7 +504,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.area120.tables_v1alpha1.types.Row", @@ -588,7 +588,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.area120.tables_v1alpha1.types.Row", @@ -669,7 +669,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_row" @@ -746,7 +746,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_row" @@ -824,7 +824,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.area120.tables_v1alpha1.types.Row", @@ -904,7 +904,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.area120.tables_v1alpha1.types.Row", @@ -985,7 +985,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.area120.tables_v1alpha1.types.Table", @@ -1065,7 +1065,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.area120.tables_v1alpha1.types.Table", @@ -1146,7 +1146,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.area120.tables_v1alpha1.types.Workspace", @@ -1226,7 +1226,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.area120.tables_v1alpha1.types.Workspace", @@ -1307,7 +1307,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.area120.tables_v1alpha1.services.tables_service.pagers.ListRowsAsyncPager", @@ -1387,7 +1387,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.area120.tables_v1alpha1.services.tables_service.pagers.ListRowsPager", @@ -1464,7 +1464,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.area120.tables_v1alpha1.services.tables_service.pagers.ListTablesAsyncPager", @@ -1540,7 +1540,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.area120.tables_v1alpha1.services.tables_service.pagers.ListTablesPager", @@ -1617,7 +1617,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.area120.tables_v1alpha1.services.tables_service.pagers.ListWorkspacesAsyncPager", @@ -1693,7 +1693,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.area120.tables_v1alpha1.services.tables_service.pagers.ListWorkspacesPager", @@ -1778,7 +1778,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.area120.tables_v1alpha1.types.Row", @@ -1862,7 +1862,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.area120.tables_v1alpha1.types.Row", diff --git a/packages/google-area120-tables/tests/unit/gapic/tables_v1alpha1/test_tables_service.py b/packages/google-area120-tables/tests/unit/gapic/tables_v1alpha1/test_tables_service.py index d1015f86f246..42cb49517258 100644 --- a/packages/google-area120-tables/tests/unit/gapic/tables_v1alpha1/test_tables_service.py +++ b/packages/google-area120-tables/tests/unit/gapic/tables_v1alpha1/test_tables_service.py @@ -5083,6 +5083,7 @@ def test_get_table_rest_required_fields(request_type=tables.GetTableRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_table(request) @@ -5128,6 +5129,7 @@ def test_get_table_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_table(**mock_args) @@ -5352,6 +5354,7 @@ def test_get_workspace_rest_required_fields(request_type=tables.GetWorkspaceRequ response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_workspace(request) @@ -5397,6 +5400,7 @@ def test_get_workspace_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_workspace(**mock_args) @@ -5623,6 +5627,7 @@ def test_get_row_rest_required_fields(request_type=tables.GetRowRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_row(request) @@ -5668,6 +5673,7 @@ def test_get_row_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_row(**mock_args) @@ -5804,6 +5810,7 @@ def test_list_rows_rest_required_fields(request_type=tables.ListRowsRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_rows(request) @@ -5859,6 +5866,7 @@ def test_list_rows_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_rows(**mock_args) @@ -6050,6 +6058,7 @@ def test_create_row_rest_required_fields(request_type=tables.CreateRowRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_row(request) @@ -6104,6 +6113,7 @@ def test_create_row_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_row(**mock_args) @@ -6237,6 +6247,7 @@ def test_batch_create_rows_rest_required_fields( response_value._content = json_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_rows(request) @@ -6365,6 +6376,7 @@ def test_update_row_rest_required_fields(request_type=tables.UpdateRowRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_row(request) @@ -6419,6 +6431,7 @@ def test_update_row_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_row(**mock_args) @@ -6552,6 +6565,7 @@ def test_batch_update_rows_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.batch_update_rows(request) @@ -6674,6 +6688,7 @@ def test_delete_row_rest_required_fields(request_type=tables.DeleteRowRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_row(request) @@ -6717,6 +6732,7 @@ def test_delete_row_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_row(**mock_args) @@ -6850,6 +6866,7 @@ def test_batch_delete_rows_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.batch_delete_rows(request) @@ -7599,6 +7616,7 @@ def test_get_table_rest_bad_request(request_type=tables.GetTableRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_table(request) @@ -7635,6 +7653,7 @@ def test_get_table_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_table(request) # Establish that the response is the type that we expect. @@ -7674,6 +7693,7 @@ def test_get_table_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = tables.Table.to_json(tables.Table()) req.return_value.content = return_value @@ -7716,6 +7736,7 @@ def test_list_tables_rest_bad_request(request_type=tables.ListTablesRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_tables(request) @@ -7751,6 +7772,7 @@ def test_list_tables_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_tables(request) # Establish that the response is the type that we expect. @@ -7789,6 +7811,7 @@ def test_list_tables_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = tables.ListTablesResponse.to_json(tables.ListTablesResponse()) req.return_value.content = return_value @@ -7831,6 +7854,7 @@ def test_get_workspace_rest_bad_request(request_type=tables.GetWorkspaceRequest) response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_workspace(request) @@ -7867,6 +7891,7 @@ def test_get_workspace_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_workspace(request) # Establish that the response is the type that we expect. @@ -7906,6 +7931,7 @@ def test_get_workspace_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = tables.Workspace.to_json(tables.Workspace()) req.return_value.content = return_value @@ -7948,6 +7974,7 @@ def test_list_workspaces_rest_bad_request(request_type=tables.ListWorkspacesRequ response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_workspaces(request) @@ -7983,6 +8010,7 @@ def test_list_workspaces_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_workspaces(request) # Establish that the response is the type that we expect. @@ -8021,6 +8049,7 @@ def test_list_workspaces_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = tables.ListWorkspacesResponse.to_json( tables.ListWorkspacesResponse() ) @@ -8065,6 +8094,7 @@ def test_get_row_rest_bad_request(request_type=tables.GetRowRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_row(request) @@ -8100,6 +8130,7 @@ def test_get_row_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_row(request) # Establish that the response is the type that we expect. @@ -8138,6 +8169,7 @@ def test_get_row_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = tables.Row.to_json(tables.Row()) req.return_value.content = return_value @@ -8180,6 +8212,7 @@ def test_list_rows_rest_bad_request(request_type=tables.ListRowsRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_rows(request) @@ -8215,6 +8248,7 @@ def test_list_rows_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_rows(request) # Establish that the response is the type that we expect. @@ -8253,6 +8287,7 @@ def test_list_rows_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = tables.ListRowsResponse.to_json(tables.ListRowsResponse()) req.return_value.content = return_value @@ -8295,6 +8330,7 @@ def test_create_row_rest_bad_request(request_type=tables.CreateRowRequest): response_value.status_code = 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_row(request) @@ -8398,6 +8434,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_row(request) # Establish that the response is the type that we expect. @@ -8436,6 +8473,7 @@ def test_create_row_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = tables.Row.to_json(tables.Row()) req.return_value.content = return_value @@ -8478,6 +8516,7 @@ def test_batch_create_rows_rest_bad_request(request_type=tables.BatchCreateRowsR response_value.status_code = 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_rows(request) @@ -8511,6 +8550,7 @@ def test_batch_create_rows_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_rows(request) # Establish that the response is the type that we expect. @@ -8548,6 +8588,7 @@ def test_batch_create_rows_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = tables.BatchCreateRowsResponse.to_json( tables.BatchCreateRowsResponse() ) @@ -8592,6 +8633,7 @@ def test_update_row_rest_bad_request(request_type=tables.UpdateRowRequest): response_value.status_code = 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_row(request) @@ -8695,6 +8737,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_row(request) # Establish that the response is the type that we expect. @@ -8733,6 +8776,7 @@ def test_update_row_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = tables.Row.to_json(tables.Row()) req.return_value.content = return_value @@ -8775,6 +8819,7 @@ def test_batch_update_rows_rest_bad_request(request_type=tables.BatchUpdateRowsR response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.batch_update_rows(request) @@ -8808,6 +8853,7 @@ def test_batch_update_rows_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.batch_update_rows(request) # Establish that the response is the type that we expect. @@ -8845,6 +8891,7 @@ def test_batch_update_rows_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = tables.BatchUpdateRowsResponse.to_json( tables.BatchUpdateRowsResponse() ) @@ -8889,6 +8936,7 @@ def test_delete_row_rest_bad_request(request_type=tables.DeleteRowRequest): response_value.status_code = 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_row(request) @@ -8919,6 +8967,7 @@ def test_delete_row_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_row(request) # Establish that the response is the type that we expect. @@ -8953,6 +9002,7 @@ def test_delete_row_rest_interceptors(null_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 = tables.DeleteRowRequest() metadata = [ @@ -8991,6 +9041,7 @@ def test_batch_delete_rows_rest_bad_request(request_type=tables.BatchDeleteRowsR response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.batch_delete_rows(request) @@ -9021,6 +9072,7 @@ def test_batch_delete_rows_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_delete_rows(request) # Establish that the response is the type that we expect. @@ -9055,6 +9107,7 @@ def test_batch_delete_rows_rest_interceptors(null_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 = tables.BatchDeleteRowsRequest() metadata = [ diff --git a/packages/google-cloud-access-approval/google/cloud/accessapproval/gapic_version.py b/packages/google-cloud-access-approval/google/cloud/accessapproval/gapic_version.py index 231f5cf041ff..558c8aab67c5 100644 --- a/packages/google-cloud-access-approval/google/cloud/accessapproval/gapic_version.py +++ b/packages/google-cloud-access-approval/google/cloud/accessapproval/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-access-approval/google/cloud/accessapproval_v1/gapic_version.py b/packages/google-cloud-access-approval/google/cloud/accessapproval_v1/gapic_version.py index 231f5cf041ff..558c8aab67c5 100644 --- a/packages/google-cloud-access-approval/google/cloud/accessapproval_v1/gapic_version.py +++ b/packages/google-cloud-access-approval/google/cloud/accessapproval_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-access-approval/google/cloud/accessapproval_v1/services/access_approval/async_client.py b/packages/google-cloud-access-approval/google/cloud/accessapproval_v1/services/access_approval/async_client.py index 2adcbbec15b4..10accb698594 100644 --- a/packages/google-cloud-access-approval/google/cloud/accessapproval_v1/services/access_approval/async_client.py +++ b/packages/google-cloud-access-approval/google/cloud/accessapproval_v1/services/access_approval/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, AccessApprovalTransport from .transports.grpc_asyncio import AccessApprovalGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class AccessApprovalAsyncClient: """This API allows a customer to manage accesses to cloud resources by @@ -306,6 +316,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.accessapproval_v1.AccessApprovalAsyncClient`.", + extra={ + "serviceName": "google.cloud.accessapproval.v1.AccessApproval", + "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.accessapproval.v1.AccessApproval", + "credentialsType": None, + }, + ) + async def list_approval_requests( self, request: Optional[ @@ -315,7 +347,7 @@ async def list_approval_requests( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListApprovalRequestsAsyncPager: r"""Lists approval requests associated with a project, folder, or organization. Approval requests can be @@ -363,8 +395,10 @@ async def sample_list_approval_requests(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.accessapproval_v1.services.access_approval.pagers.ListApprovalRequestsAsyncPager: @@ -439,7 +473,7 @@ async def get_approval_request( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> accessapproval.ApprovalRequest: r"""Gets an approval request. Returns NOT_FOUND if the request does not exist. @@ -482,8 +516,10 @@ async def sample_get_approval_request(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.accessapproval_v1.types.ApprovalRequest: @@ -545,7 +581,7 @@ async def approve_approval_request( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> accessapproval.ApprovalRequest: r"""Approves a request and returns the updated ApprovalRequest. @@ -585,8 +621,10 @@ async def sample_approve_approval_request(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.accessapproval_v1.types.ApprovalRequest: @@ -634,7 +672,7 @@ async def dismiss_approval_request( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> accessapproval.ApprovalRequest: r"""Dismisses a request. Returns the updated ApprovalRequest. @@ -679,8 +717,10 @@ async def sample_dismiss_approval_request(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.accessapproval_v1.types.ApprovalRequest: @@ -728,7 +768,7 @@ async def invalidate_approval_request( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> accessapproval.ApprovalRequest: r"""Invalidates an existing ApprovalRequest. Returns the updated ApprovalRequest. @@ -772,8 +812,10 @@ async def sample_invalidate_approval_request(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.accessapproval_v1.types.ApprovalRequest: @@ -822,7 +864,7 @@ async def get_access_approval_settings( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> accessapproval.AccessApprovalSettings: r"""Gets the settings associated with a project, folder, or organization. @@ -867,8 +909,10 @@ async def sample_get_access_approval_settings(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.accessapproval_v1.types.AccessApprovalSettings: @@ -933,7 +977,7 @@ async def update_access_approval_settings( 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]]] = (), ) -> accessapproval.AccessApprovalSettings: r"""Updates the settings associated with a project, folder, or organization. Settings to update are determined by the value of @@ -992,8 +1036,10 @@ async def sample_update_access_approval_settings(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.accessapproval_v1.types.AccessApprovalSettings: @@ -1061,7 +1107,7 @@ async def delete_access_approval_settings( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 settings associated with a project, folder, or organization. This will have the effect of @@ -1108,8 +1154,10 @@ async def sample_delete_access_approval_settings(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -1163,7 +1211,7 @@ async def get_access_approval_service_account( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> accessapproval.AccessApprovalServiceAccount: r"""Retrieves the service account that is used by Access Approval to access KMS keys for signing approved @@ -1209,8 +1257,10 @@ async def sample_get_access_approval_service_account(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.accessapproval_v1.types.AccessApprovalServiceAccount: diff --git a/packages/google-cloud-access-approval/google/cloud/accessapproval_v1/services/access_approval/client.py b/packages/google-cloud-access-approval/google/cloud/accessapproval_v1/services/access_approval/client.py index 73acca6528d2..118cb667f0e3 100644 --- a/packages/google-cloud-access-approval/google/cloud/accessapproval_v1/services/access_approval/client.py +++ b/packages/google-cloud-access-approval/google/cloud/accessapproval_v1/services/access_approval/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 @@ -644,6 +654,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( @@ -709,6 +723,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.accessapproval_v1.AccessApprovalClient`.", + extra={ + "serviceName": "google.cloud.accessapproval.v1.AccessApproval", + "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.accessapproval.v1.AccessApproval", + "credentialsType": None, + }, + ) + def list_approval_requests( self, request: Optional[ @@ -718,7 +755,7 @@ def list_approval_requests( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListApprovalRequestsPager: r"""Lists approval requests associated with a project, folder, or organization. Approval requests can be @@ -766,8 +803,10 @@ def sample_list_approval_requests(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.accessapproval_v1.services.access_approval.pagers.ListApprovalRequestsPager: @@ -839,7 +878,7 @@ def get_approval_request( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> accessapproval.ApprovalRequest: r"""Gets an approval request. Returns NOT_FOUND if the request does not exist. @@ -882,8 +921,10 @@ def sample_get_approval_request(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.accessapproval_v1.types.ApprovalRequest: @@ -942,7 +983,7 @@ def approve_approval_request( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> accessapproval.ApprovalRequest: r"""Approves a request and returns the updated ApprovalRequest. @@ -982,8 +1023,10 @@ def sample_approve_approval_request(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.accessapproval_v1.types.ApprovalRequest: @@ -1029,7 +1072,7 @@ def dismiss_approval_request( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> accessapproval.ApprovalRequest: r"""Dismisses a request. Returns the updated ApprovalRequest. @@ -1074,8 +1117,10 @@ def sample_dismiss_approval_request(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.accessapproval_v1.types.ApprovalRequest: @@ -1121,7 +1166,7 @@ def invalidate_approval_request( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> accessapproval.ApprovalRequest: r"""Invalidates an existing ApprovalRequest. Returns the updated ApprovalRequest. @@ -1165,8 +1210,10 @@ def sample_invalidate_approval_request(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.accessapproval_v1.types.ApprovalRequest: @@ -1215,7 +1262,7 @@ def get_access_approval_settings( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> accessapproval.AccessApprovalSettings: r"""Gets the settings associated with a project, folder, or organization. @@ -1260,8 +1307,10 @@ def sample_get_access_approval_settings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.accessapproval_v1.types.AccessApprovalSettings: @@ -1325,7 +1374,7 @@ def update_access_approval_settings( 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]]] = (), ) -> accessapproval.AccessApprovalSettings: r"""Updates the settings associated with a project, folder, or organization. Settings to update are determined by the value of @@ -1384,8 +1433,10 @@ def sample_update_access_approval_settings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.accessapproval_v1.types.AccessApprovalSettings: @@ -1452,7 +1503,7 @@ def delete_access_approval_settings( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 settings associated with a project, folder, or organization. This will have the effect of @@ -1499,8 +1550,10 @@ def sample_delete_access_approval_settings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -1553,7 +1606,7 @@ def get_access_approval_service_account( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> accessapproval.AccessApprovalServiceAccount: r"""Retrieves the service account that is used by Access Approval to access KMS keys for signing approved @@ -1599,8 +1652,10 @@ def sample_get_access_approval_service_account(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.accessapproval_v1.types.AccessApprovalServiceAccount: diff --git a/packages/google-cloud-access-approval/google/cloud/accessapproval_v1/services/access_approval/pagers.py b/packages/google-cloud-access-approval/google/cloud/accessapproval_v1/services/access_approval/pagers.py index 558252806192..336376b6a190 100644 --- a/packages/google-cloud-access-approval/google/cloud/accessapproval_v1/services/access_approval/pagers.py +++ b/packages/google-cloud-access-approval/google/cloud/accessapproval_v1/services/access_approval/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 = accessapproval.ListApprovalRequestsMessage(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 = accessapproval.ListApprovalRequestsMessage(request) diff --git a/packages/google-cloud-access-approval/google/cloud/accessapproval_v1/services/access_approval/transports/grpc.py b/packages/google-cloud-access-approval/google/cloud/accessapproval_v1/services/access_approval/transports/grpc.py index 05273b69663b..a626ea3ad7ea 100644 --- a/packages/google-cloud-access-approval/google/cloud/accessapproval_v1/services/access_approval/transports/grpc.py +++ b/packages/google-cloud-access-approval/google/cloud/accessapproval_v1/services/access_approval/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.accessapproval_v1.types import accessapproval from .base import DEFAULT_CLIENT_INFO, AccessApprovalTransport +try: + from google.api_core import client_logging # 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.accessapproval.v1.AccessApproval", + "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.accessapproval.v1.AccessApproval", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AccessApprovalGrpcTransport(AccessApprovalTransport): """gRPC backend transport for AccessApproval. @@ -214,7 +295,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 @@ -294,7 +380,7 @@ def list_approval_requests( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_approval_requests" not in self._stubs: - self._stubs["list_approval_requests"] = self.grpc_channel.unary_unary( + self._stubs["list_approval_requests"] = self._logged_channel.unary_unary( "/google.cloud.accessapproval.v1.AccessApproval/ListApprovalRequests", request_serializer=accessapproval.ListApprovalRequestsMessage.serialize, response_deserializer=accessapproval.ListApprovalRequestsResponse.deserialize, @@ -323,7 +409,7 @@ def get_approval_request( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_approval_request" not in self._stubs: - self._stubs["get_approval_request"] = self.grpc_channel.unary_unary( + self._stubs["get_approval_request"] = self._logged_channel.unary_unary( "/google.cloud.accessapproval.v1.AccessApproval/GetApprovalRequest", request_serializer=accessapproval.GetApprovalRequestMessage.serialize, response_deserializer=accessapproval.ApprovalRequest.deserialize, @@ -355,7 +441,7 @@ def approve_approval_request( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "approve_approval_request" not in self._stubs: - self._stubs["approve_approval_request"] = self.grpc_channel.unary_unary( + self._stubs["approve_approval_request"] = self._logged_channel.unary_unary( "/google.cloud.accessapproval.v1.AccessApproval/ApproveApprovalRequest", request_serializer=accessapproval.ApproveApprovalRequestMessage.serialize, response_deserializer=accessapproval.ApprovalRequest.deserialize, @@ -392,7 +478,7 @@ def dismiss_approval_request( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "dismiss_approval_request" not in self._stubs: - self._stubs["dismiss_approval_request"] = self.grpc_channel.unary_unary( + self._stubs["dismiss_approval_request"] = self._logged_channel.unary_unary( "/google.cloud.accessapproval.v1.AccessApproval/DismissApprovalRequest", request_serializer=accessapproval.DismissApprovalRequestMessage.serialize, response_deserializer=accessapproval.ApprovalRequest.deserialize, @@ -429,7 +515,9 @@ def invalidate_approval_request( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "invalidate_approval_request" not in self._stubs: - self._stubs["invalidate_approval_request"] = self.grpc_channel.unary_unary( + self._stubs[ + "invalidate_approval_request" + ] = self._logged_channel.unary_unary( "/google.cloud.accessapproval.v1.AccessApproval/InvalidateApprovalRequest", request_serializer=accessapproval.InvalidateApprovalRequestMessage.serialize, response_deserializer=accessapproval.ApprovalRequest.deserialize, @@ -459,7 +547,9 @@ def get_access_approval_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_access_approval_settings" not in self._stubs: - self._stubs["get_access_approval_settings"] = self.grpc_channel.unary_unary( + self._stubs[ + "get_access_approval_settings" + ] = self._logged_channel.unary_unary( "/google.cloud.accessapproval.v1.AccessApproval/GetAccessApprovalSettings", request_serializer=accessapproval.GetAccessApprovalSettingsMessage.serialize, response_deserializer=accessapproval.AccessApprovalSettings.deserialize, @@ -493,7 +583,7 @@ def update_access_approval_settings( if "update_access_approval_settings" not in self._stubs: self._stubs[ "update_access_approval_settings" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.accessapproval.v1.AccessApproval/UpdateAccessApprovalSettings", request_serializer=accessapproval.UpdateAccessApprovalSettingsMessage.serialize, response_deserializer=accessapproval.AccessApprovalSettings.deserialize, @@ -531,7 +621,7 @@ def delete_access_approval_settings( if "delete_access_approval_settings" not in self._stubs: self._stubs[ "delete_access_approval_settings" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.accessapproval.v1.AccessApproval/DeleteAccessApprovalSettings", request_serializer=accessapproval.DeleteAccessApprovalSettingsMessage.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -565,7 +655,7 @@ def get_access_approval_service_account( if "get_access_approval_service_account" not in self._stubs: self._stubs[ "get_access_approval_service_account" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.accessapproval.v1.AccessApproval/GetAccessApprovalServiceAccount", request_serializer=accessapproval.GetAccessApprovalServiceAccountMessage.serialize, response_deserializer=accessapproval.AccessApprovalServiceAccount.deserialize, @@ -573,7 +663,7 @@ def get_access_approval_service_account( return self._stubs["get_access_approval_service_account"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-access-approval/google/cloud/accessapproval_v1/services/access_approval/transports/grpc_asyncio.py b/packages/google-cloud-access-approval/google/cloud/accessapproval_v1/services/access_approval/transports/grpc_asyncio.py index 0b7aad07f43f..8909474df827 100644 --- a/packages/google-cloud-access-approval/google/cloud/accessapproval_v1/services/access_approval/transports/grpc_asyncio.py +++ b/packages/google-cloud-access-approval/google/cloud/accessapproval_v1/services/access_approval/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.accessapproval_v1.types import accessapproval from .base import DEFAULT_CLIENT_INFO, AccessApprovalTransport from .grpc import AccessApprovalGrpcTransport +try: + from google.api_core import client_logging # 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.accessapproval.v1.AccessApproval", + "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.accessapproval.v1.AccessApproval", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AccessApprovalGrpcAsyncIOTransport(AccessApprovalTransport): """gRPC AsyncIO backend transport for AccessApproval. @@ -261,10 +343,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 @@ -302,7 +387,7 @@ def list_approval_requests( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_approval_requests" not in self._stubs: - self._stubs["list_approval_requests"] = self.grpc_channel.unary_unary( + self._stubs["list_approval_requests"] = self._logged_channel.unary_unary( "/google.cloud.accessapproval.v1.AccessApproval/ListApprovalRequests", request_serializer=accessapproval.ListApprovalRequestsMessage.serialize, response_deserializer=accessapproval.ListApprovalRequestsResponse.deserialize, @@ -332,7 +417,7 @@ def get_approval_request( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_approval_request" not in self._stubs: - self._stubs["get_approval_request"] = self.grpc_channel.unary_unary( + self._stubs["get_approval_request"] = self._logged_channel.unary_unary( "/google.cloud.accessapproval.v1.AccessApproval/GetApprovalRequest", request_serializer=accessapproval.GetApprovalRequestMessage.serialize, response_deserializer=accessapproval.ApprovalRequest.deserialize, @@ -365,7 +450,7 @@ def approve_approval_request( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "approve_approval_request" not in self._stubs: - self._stubs["approve_approval_request"] = self.grpc_channel.unary_unary( + self._stubs["approve_approval_request"] = self._logged_channel.unary_unary( "/google.cloud.accessapproval.v1.AccessApproval/ApproveApprovalRequest", request_serializer=accessapproval.ApproveApprovalRequestMessage.serialize, response_deserializer=accessapproval.ApprovalRequest.deserialize, @@ -403,7 +488,7 @@ def dismiss_approval_request( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "dismiss_approval_request" not in self._stubs: - self._stubs["dismiss_approval_request"] = self.grpc_channel.unary_unary( + self._stubs["dismiss_approval_request"] = self._logged_channel.unary_unary( "/google.cloud.accessapproval.v1.AccessApproval/DismissApprovalRequest", request_serializer=accessapproval.DismissApprovalRequestMessage.serialize, response_deserializer=accessapproval.ApprovalRequest.deserialize, @@ -440,7 +525,9 @@ def invalidate_approval_request( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "invalidate_approval_request" not in self._stubs: - self._stubs["invalidate_approval_request"] = self.grpc_channel.unary_unary( + self._stubs[ + "invalidate_approval_request" + ] = self._logged_channel.unary_unary( "/google.cloud.accessapproval.v1.AccessApproval/InvalidateApprovalRequest", request_serializer=accessapproval.InvalidateApprovalRequestMessage.serialize, response_deserializer=accessapproval.ApprovalRequest.deserialize, @@ -470,7 +557,9 @@ def get_access_approval_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_access_approval_settings" not in self._stubs: - self._stubs["get_access_approval_settings"] = self.grpc_channel.unary_unary( + self._stubs[ + "get_access_approval_settings" + ] = self._logged_channel.unary_unary( "/google.cloud.accessapproval.v1.AccessApproval/GetAccessApprovalSettings", request_serializer=accessapproval.GetAccessApprovalSettingsMessage.serialize, response_deserializer=accessapproval.AccessApprovalSettings.deserialize, @@ -504,7 +593,7 @@ def update_access_approval_settings( if "update_access_approval_settings" not in self._stubs: self._stubs[ "update_access_approval_settings" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.accessapproval.v1.AccessApproval/UpdateAccessApprovalSettings", request_serializer=accessapproval.UpdateAccessApprovalSettingsMessage.serialize, response_deserializer=accessapproval.AccessApprovalSettings.deserialize, @@ -542,7 +631,7 @@ def delete_access_approval_settings( if "delete_access_approval_settings" not in self._stubs: self._stubs[ "delete_access_approval_settings" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.accessapproval.v1.AccessApproval/DeleteAccessApprovalSettings", request_serializer=accessapproval.DeleteAccessApprovalSettingsMessage.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -576,7 +665,7 @@ def get_access_approval_service_account( if "get_access_approval_service_account" not in self._stubs: self._stubs[ "get_access_approval_service_account" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.accessapproval.v1.AccessApproval/GetAccessApprovalServiceAccount", request_serializer=accessapproval.GetAccessApprovalServiceAccountMessage.serialize, response_deserializer=accessapproval.AccessApprovalServiceAccount.deserialize, @@ -666,7 +755,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-access-approval/google/cloud/accessapproval_v1/services/access_approval/transports/rest.py b/packages/google-cloud-access-approval/google/cloud/accessapproval_v1/services/access_approval/transports/rest.py index ffdd721f89c6..3b84b1ddbf03 100644 --- a/packages/google-cloud-access-approval/google/cloud/accessapproval_v1/services/access_approval/transports/rest.py +++ b/packages/google-cloud-access-approval/google/cloud/accessapproval_v1/services/access_approval/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, @@ -138,8 +146,11 @@ def post_update_access_approval_settings(self, response): def pre_approve_approval_request( self, request: accessapproval.ApproveApprovalRequestMessage, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[accessapproval.ApproveApprovalRequestMessage, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + accessapproval.ApproveApprovalRequestMessage, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for approve_approval_request Override in a subclass to manipulate the request or metadata @@ -161,9 +172,10 @@ def post_approve_approval_request( def pre_delete_access_approval_settings( self, request: accessapproval.DeleteAccessApprovalSettingsMessage, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - accessapproval.DeleteAccessApprovalSettingsMessage, Sequence[Tuple[str, str]] + accessapproval.DeleteAccessApprovalSettingsMessage, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_access_approval_settings @@ -175,8 +187,11 @@ def pre_delete_access_approval_settings( def pre_dismiss_approval_request( self, request: accessapproval.DismissApprovalRequestMessage, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[accessapproval.DismissApprovalRequestMessage, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + accessapproval.DismissApprovalRequestMessage, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for dismiss_approval_request Override in a subclass to manipulate the request or metadata @@ -198,9 +213,10 @@ def post_dismiss_approval_request( def pre_get_access_approval_service_account( self, request: accessapproval.GetAccessApprovalServiceAccountMessage, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - accessapproval.GetAccessApprovalServiceAccountMessage, Sequence[Tuple[str, str]] + accessapproval.GetAccessApprovalServiceAccountMessage, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_access_approval_service_account @@ -223,9 +239,10 @@ def post_get_access_approval_service_account( def pre_get_access_approval_settings( self, request: accessapproval.GetAccessApprovalSettingsMessage, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - accessapproval.GetAccessApprovalSettingsMessage, Sequence[Tuple[str, str]] + accessapproval.GetAccessApprovalSettingsMessage, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_access_approval_settings @@ -248,8 +265,11 @@ def post_get_access_approval_settings( def pre_get_approval_request( self, request: accessapproval.GetApprovalRequestMessage, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[accessapproval.GetApprovalRequestMessage, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + accessapproval.GetApprovalRequestMessage, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_approval_request Override in a subclass to manipulate the request or metadata @@ -271,9 +291,10 @@ def post_get_approval_request( def pre_invalidate_approval_request( self, request: accessapproval.InvalidateApprovalRequestMessage, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - accessapproval.InvalidateApprovalRequestMessage, Sequence[Tuple[str, str]] + accessapproval.InvalidateApprovalRequestMessage, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for invalidate_approval_request @@ -296,8 +317,11 @@ def post_invalidate_approval_request( def pre_list_approval_requests( self, request: accessapproval.ListApprovalRequestsMessage, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[accessapproval.ListApprovalRequestsMessage, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + accessapproval.ListApprovalRequestsMessage, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_approval_requests Override in a subclass to manipulate the request or metadata @@ -319,9 +343,10 @@ def post_list_approval_requests( def pre_update_access_approval_settings( self, request: accessapproval.UpdateAccessApprovalSettingsMessage, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - accessapproval.UpdateAccessApprovalSettingsMessage, Sequence[Tuple[str, str]] + accessapproval.UpdateAccessApprovalSettingsMessage, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_access_approval_settings @@ -498,7 +523,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> accessapproval.ApprovalRequest: r"""Call the approve approval request method over HTTP. @@ -509,8 +534,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.accessapproval.ApprovalRequest: @@ -522,6 +549,7 @@ def __call__( http_options = ( _BaseAccessApprovalRestTransport._BaseApproveApprovalRequest._get_http_options() ) + request, metadata = self._interceptor.pre_approve_approval_request( request, metadata ) @@ -538,6 +566,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.accessapproval_v1.AccessApprovalClient.ApproveApprovalRequest", + extra={ + "serviceName": "google.cloud.accessapproval.v1.AccessApproval", + "rpcName": "ApproveApprovalRequest", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AccessApprovalRestTransport._ApproveApprovalRequest._get_response( @@ -561,7 +616,29 @@ def __call__( pb_resp = accessapproval.ApprovalRequest.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_approve_approval_request(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = accessapproval.ApprovalRequest.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.accessapproval_v1.AccessApprovalClient.approve_approval_request", + extra={ + "serviceName": "google.cloud.accessapproval.v1.AccessApproval", + "rpcName": "ApproveApprovalRequest", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteAccessApprovalSettings( @@ -599,7 +676,7 @@ 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 access approval settings method over HTTP. @@ -611,13 +688,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 = ( _BaseAccessApprovalRestTransport._BaseDeleteAccessApprovalSettings._get_http_options() ) + request, metadata = self._interceptor.pre_delete_access_approval_settings( request, metadata ) @@ -630,6 +710,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.accessapproval_v1.AccessApprovalClient.DeleteAccessApprovalSettings", + extra={ + "serviceName": "google.cloud.accessapproval.v1.AccessApproval", + "rpcName": "DeleteAccessApprovalSettings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AccessApprovalRestTransport._DeleteAccessApprovalSettings._get_response( @@ -683,7 +790,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> accessapproval.ApprovalRequest: r"""Call the dismiss approval request method over HTTP. @@ -694,8 +801,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.accessapproval.ApprovalRequest: @@ -707,6 +816,7 @@ def __call__( http_options = ( _BaseAccessApprovalRestTransport._BaseDismissApprovalRequest._get_http_options() ) + request, metadata = self._interceptor.pre_dismiss_approval_request( request, metadata ) @@ -723,6 +833,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.accessapproval_v1.AccessApprovalClient.DismissApprovalRequest", + extra={ + "serviceName": "google.cloud.accessapproval.v1.AccessApproval", + "rpcName": "DismissApprovalRequest", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AccessApprovalRestTransport._DismissApprovalRequest._get_response( @@ -746,7 +883,29 @@ def __call__( pb_resp = accessapproval.ApprovalRequest.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_dismiss_approval_request(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = accessapproval.ApprovalRequest.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.accessapproval_v1.AccessApprovalClient.dismiss_approval_request", + extra={ + "serviceName": "google.cloud.accessapproval.v1.AccessApproval", + "rpcName": "DismissApprovalRequest", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAccessApprovalServiceAccount( @@ -784,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]]] = (), ) -> accessapproval.AccessApprovalServiceAccount: r"""Call the get access approval service account method over HTTP. @@ -796,8 +955,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.accessapproval.AccessApprovalServiceAccount: @@ -810,6 +971,7 @@ def __call__( http_options = ( _BaseAccessApprovalRestTransport._BaseGetAccessApprovalServiceAccount._get_http_options() ) + ( request, metadata, @@ -825,6 +987,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.accessapproval_v1.AccessApprovalClient.GetAccessApprovalServiceAccount", + extra={ + "serviceName": "google.cloud.accessapproval.v1.AccessApproval", + "rpcName": "GetAccessApprovalServiceAccount", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AccessApprovalRestTransport._GetAccessApprovalServiceAccount._get_response( self._host, @@ -845,7 +1034,31 @@ def __call__( pb_resp = accessapproval.AccessApprovalServiceAccount.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_access_approval_service_account(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + accessapproval.AccessApprovalServiceAccount.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.accessapproval_v1.AccessApprovalClient.get_access_approval_service_account", + extra={ + "serviceName": "google.cloud.accessapproval.v1.AccessApproval", + "rpcName": "GetAccessApprovalServiceAccount", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAccessApprovalSettings( @@ -883,7 +1096,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> accessapproval.AccessApprovalSettings: r"""Call the get access approval settings method over HTTP. @@ -895,8 +1108,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.accessapproval.AccessApprovalSettings: @@ -909,6 +1124,7 @@ def __call__( http_options = ( _BaseAccessApprovalRestTransport._BaseGetAccessApprovalSettings._get_http_options() ) + request, metadata = self._interceptor.pre_get_access_approval_settings( request, metadata ) @@ -921,6 +1137,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.accessapproval_v1.AccessApprovalClient.GetAccessApprovalSettings", + extra={ + "serviceName": "google.cloud.accessapproval.v1.AccessApproval", + "rpcName": "GetAccessApprovalSettings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AccessApprovalRestTransport._GetAccessApprovalSettings._get_response( @@ -943,7 +1186,31 @@ def __call__( pb_resp = accessapproval.AccessApprovalSettings.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_access_approval_settings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = accessapproval.AccessApprovalSettings.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.accessapproval_v1.AccessApprovalClient.get_access_approval_settings", + extra={ + "serviceName": "google.cloud.accessapproval.v1.AccessApproval", + "rpcName": "GetAccessApprovalSettings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetApprovalRequest( @@ -980,7 +1247,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> accessapproval.ApprovalRequest: r"""Call the get approval request method over HTTP. @@ -990,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: ~.accessapproval.ApprovalRequest: @@ -1003,6 +1272,7 @@ def __call__( http_options = ( _BaseAccessApprovalRestTransport._BaseGetApprovalRequest._get_http_options() ) + request, metadata = self._interceptor.pre_get_approval_request( request, metadata ) @@ -1015,6 +1285,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.accessapproval_v1.AccessApprovalClient.GetApprovalRequest", + extra={ + "serviceName": "google.cloud.accessapproval.v1.AccessApproval", + "rpcName": "GetApprovalRequest", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AccessApprovalRestTransport._GetApprovalRequest._get_response( self._host, @@ -1035,7 +1332,29 @@ def __call__( pb_resp = accessapproval.ApprovalRequest.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_approval_request(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = accessapproval.ApprovalRequest.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.accessapproval_v1.AccessApprovalClient.get_approval_request", + extra={ + "serviceName": "google.cloud.accessapproval.v1.AccessApproval", + "rpcName": "GetApprovalRequest", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _InvalidateApprovalRequest( @@ -1074,7 +1393,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> accessapproval.ApprovalRequest: r"""Call the invalidate approval request method over HTTP. @@ -1086,8 +1405,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.accessapproval.ApprovalRequest: @@ -1099,6 +1420,7 @@ def __call__( http_options = ( _BaseAccessApprovalRestTransport._BaseInvalidateApprovalRequest._get_http_options() ) + request, metadata = self._interceptor.pre_invalidate_approval_request( request, metadata ) @@ -1115,6 +1437,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.accessapproval_v1.AccessApprovalClient.InvalidateApprovalRequest", + extra={ + "serviceName": "google.cloud.accessapproval.v1.AccessApproval", + "rpcName": "InvalidateApprovalRequest", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AccessApprovalRestTransport._InvalidateApprovalRequest._get_response( @@ -1138,7 +1487,29 @@ def __call__( pb_resp = accessapproval.ApprovalRequest.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_invalidate_approval_request(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = accessapproval.ApprovalRequest.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.accessapproval_v1.AccessApprovalClient.invalidate_approval_request", + extra={ + "serviceName": "google.cloud.accessapproval.v1.AccessApproval", + "rpcName": "InvalidateApprovalRequest", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListApprovalRequests( @@ -1176,7 +1547,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> accessapproval.ListApprovalRequestsResponse: r"""Call the list approval requests method over HTTP. @@ -1186,8 +1557,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.accessapproval.ListApprovalRequestsResponse: @@ -1199,6 +1572,7 @@ def __call__( http_options = ( _BaseAccessApprovalRestTransport._BaseListApprovalRequests._get_http_options() ) + request, metadata = self._interceptor.pre_list_approval_requests( request, metadata ) @@ -1211,6 +1585,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.accessapproval_v1.AccessApprovalClient.ListApprovalRequests", + extra={ + "serviceName": "google.cloud.accessapproval.v1.AccessApproval", + "rpcName": "ListApprovalRequests", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AccessApprovalRestTransport._ListApprovalRequests._get_response( self._host, @@ -1231,7 +1632,31 @@ def __call__( pb_resp = accessapproval.ListApprovalRequestsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_approval_requests(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + accessapproval.ListApprovalRequestsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.accessapproval_v1.AccessApprovalClient.list_approval_requests", + extra={ + "serviceName": "google.cloud.accessapproval.v1.AccessApproval", + "rpcName": "ListApprovalRequests", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateAccessApprovalSettings( @@ -1270,7 +1695,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> accessapproval.AccessApprovalSettings: r"""Call the update access approval settings method over HTTP. @@ -1282,8 +1707,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.accessapproval.AccessApprovalSettings: @@ -1296,6 +1723,7 @@ def __call__( http_options = ( _BaseAccessApprovalRestTransport._BaseUpdateAccessApprovalSettings._get_http_options() ) + request, metadata = self._interceptor.pre_update_access_approval_settings( request, metadata ) @@ -1312,6 +1740,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.accessapproval_v1.AccessApprovalClient.UpdateAccessApprovalSettings", + extra={ + "serviceName": "google.cloud.accessapproval.v1.AccessApproval", + "rpcName": "UpdateAccessApprovalSettings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AccessApprovalRestTransport._UpdateAccessApprovalSettings._get_response( @@ -1335,7 +1790,31 @@ def __call__( pb_resp = accessapproval.AccessApprovalSettings.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_access_approval_settings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = accessapproval.AccessApprovalSettings.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.accessapproval_v1.AccessApprovalClient.update_access_approval_settings", + extra={ + "serviceName": "google.cloud.accessapproval.v1.AccessApproval", + "rpcName": "UpdateAccessApprovalSettings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-access-approval/samples/generated_samples/snippet_metadata_google.cloud.accessapproval.v1.json b/packages/google-cloud-access-approval/samples/generated_samples/snippet_metadata_google.cloud.accessapproval.v1.json index 2daa4d5daa12..b3ec8896db77 100644 --- a/packages/google-cloud-access-approval/samples/generated_samples/snippet_metadata_google.cloud.accessapproval.v1.json +++ b/packages/google-cloud-access-approval/samples/generated_samples/snippet_metadata_google.cloud.accessapproval.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-access-approval", - "version": "1.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": "google.cloud.accessapproval_v1.types.ApprovalRequest", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.accessapproval_v1.types.ApprovalRequest", @@ -200,7 +200,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_access_approval_settings" @@ -277,7 +277,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_access_approval_settings" @@ -351,7 +351,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.accessapproval_v1.types.ApprovalRequest", @@ -427,7 +427,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.accessapproval_v1.types.ApprovalRequest", @@ -508,7 +508,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.accessapproval_v1.types.AccessApprovalServiceAccount", @@ -588,7 +588,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.accessapproval_v1.types.AccessApprovalServiceAccount", @@ -669,7 +669,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.accessapproval_v1.types.AccessApprovalSettings", @@ -749,7 +749,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.accessapproval_v1.types.AccessApprovalSettings", @@ -830,7 +830,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.accessapproval_v1.types.ApprovalRequest", @@ -910,7 +910,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.accessapproval_v1.types.ApprovalRequest", @@ -987,7 +987,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.accessapproval_v1.types.ApprovalRequest", @@ -1063,7 +1063,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.accessapproval_v1.types.ApprovalRequest", @@ -1144,7 +1144,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.accessapproval_v1.services.access_approval.pagers.ListApprovalRequestsAsyncPager", @@ -1224,7 +1224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.accessapproval_v1.services.access_approval.pagers.ListApprovalRequestsPager", @@ -1309,7 +1309,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.accessapproval_v1.types.AccessApprovalSettings", @@ -1393,7 +1393,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.accessapproval_v1.types.AccessApprovalSettings", diff --git a/packages/google-cloud-access-approval/tests/unit/gapic/accessapproval_v1/test_access_approval.py b/packages/google-cloud-access-approval/tests/unit/gapic/accessapproval_v1/test_access_approval.py index 47aabbb3b84e..f81e6a845b87 100644 --- a/packages/google-cloud-access-approval/tests/unit/gapic/accessapproval_v1/test_access_approval.py +++ b/packages/google-cloud-access-approval/tests/unit/gapic/accessapproval_v1/test_access_approval.py @@ -4219,6 +4219,7 @@ def test_list_approval_requests_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_approval_requests(**mock_args) @@ -4378,6 +4379,7 @@ def test_get_approval_request_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_approval_request(**mock_args) @@ -4598,6 +4600,7 @@ def test_get_access_approval_settings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_access_approval_settings(**mock_args) @@ -4698,6 +4701,7 @@ def test_update_access_approval_settings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_access_approval_settings(**mock_args) @@ -4795,6 +4799,7 @@ def test_delete_access_approval_settings_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_access_approval_settings(**mock_args) @@ -4892,6 +4897,7 @@ def test_get_access_approval_service_account_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_access_approval_service_account(**mock_args) @@ -5548,6 +5554,7 @@ def test_list_approval_requests_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_approval_requests(request) @@ -5583,6 +5590,7 @@ def test_list_approval_requests_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_approval_requests(request) # Establish that the response is the type that we expect. @@ -5623,6 +5631,7 @@ def test_list_approval_requests_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = accessapproval.ListApprovalRequestsResponse.to_json( accessapproval.ListApprovalRequestsResponse() ) @@ -5669,6 +5678,7 @@ def test_get_approval_request_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_approval_request(request) @@ -5705,6 +5715,7 @@ def test_get_approval_request_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_approval_request(request) # Establish that the response is the type that we expect. @@ -5746,6 +5757,7 @@ def test_get_approval_request_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = accessapproval.ApprovalRequest.to_json( accessapproval.ApprovalRequest() ) @@ -5792,6 +5804,7 @@ def test_approve_approval_request_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.approve_approval_request(request) @@ -5828,6 +5841,7 @@ def test_approve_approval_request_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.approve_approval_request(request) # Establish that the response is the type that we expect. @@ -5869,6 +5883,7 @@ def test_approve_approval_request_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = accessapproval.ApprovalRequest.to_json( accessapproval.ApprovalRequest() ) @@ -5915,6 +5930,7 @@ def test_dismiss_approval_request_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.dismiss_approval_request(request) @@ -5951,6 +5967,7 @@ def test_dismiss_approval_request_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.dismiss_approval_request(request) # Establish that the response is the type that we expect. @@ -5992,6 +6009,7 @@ def test_dismiss_approval_request_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = accessapproval.ApprovalRequest.to_json( accessapproval.ApprovalRequest() ) @@ -6038,6 +6056,7 @@ def test_invalidate_approval_request_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.invalidate_approval_request(request) @@ -6074,6 +6093,7 @@ def test_invalidate_approval_request_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.invalidate_approval_request(request) # Establish that the response is the type that we expect. @@ -6115,6 +6135,7 @@ def test_invalidate_approval_request_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = accessapproval.ApprovalRequest.to_json( accessapproval.ApprovalRequest() ) @@ -6161,6 +6182,7 @@ def test_get_access_approval_settings_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_access_approval_settings(request) @@ -6201,6 +6223,7 @@ def test_get_access_approval_settings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_access_approval_settings(request) # Establish that the response is the type that we expect. @@ -6246,6 +6269,7 @@ def test_get_access_approval_settings_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = accessapproval.AccessApprovalSettings.to_json( accessapproval.AccessApprovalSettings() ) @@ -6292,6 +6316,7 @@ def test_update_access_approval_settings_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_access_approval_settings(request) @@ -6415,6 +6440,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_access_approval_settings(request) # Establish that the response is the type that we expect. @@ -6460,6 +6486,7 @@ def test_update_access_approval_settings_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = accessapproval.AccessApprovalSettings.to_json( accessapproval.AccessApprovalSettings() ) @@ -6506,6 +6533,7 @@ def test_delete_access_approval_settings_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_access_approval_settings(request) @@ -6536,6 +6564,7 @@ def test_delete_access_approval_settings_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_access_approval_settings(request) # Establish that the response is the type that we expect. @@ -6572,6 +6601,7 @@ def test_delete_access_approval_settings_rest_interceptors(null_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 = accessapproval.DeleteAccessApprovalSettingsMessage() metadata = [ @@ -6612,6 +6642,7 @@ def test_get_access_approval_service_account_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_access_approval_service_account(request) @@ -6648,6 +6679,7 @@ def test_get_access_approval_service_account_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_access_approval_service_account(request) # Establish that the response is the type that we expect. @@ -6691,6 +6723,7 @@ def test_get_access_approval_service_account_rest_interceptors(null_interceptor) req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = accessapproval.AccessApprovalServiceAccount.to_json( accessapproval.AccessApprovalServiceAccount() ) diff --git a/packages/google-cloud-advisorynotifications/google/cloud/advisorynotifications/gapic_version.py b/packages/google-cloud-advisorynotifications/google/cloud/advisorynotifications/gapic_version.py index ab68833be4be..558c8aab67c5 100644 --- a/packages/google-cloud-advisorynotifications/google/cloud/advisorynotifications/gapic_version.py +++ b/packages/google-cloud-advisorynotifications/google/cloud/advisorynotifications/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.3.12" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-advisorynotifications/google/cloud/advisorynotifications_v1/gapic_version.py b/packages/google-cloud-advisorynotifications/google/cloud/advisorynotifications_v1/gapic_version.py index ab68833be4be..558c8aab67c5 100644 --- a/packages/google-cloud-advisorynotifications/google/cloud/advisorynotifications_v1/gapic_version.py +++ b/packages/google-cloud-advisorynotifications/google/cloud/advisorynotifications_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.12" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-advisorynotifications/google/cloud/advisorynotifications_v1/services/advisory_notifications_service/async_client.py b/packages/google-cloud-advisorynotifications/google/cloud/advisorynotifications_v1/services/advisory_notifications_service/async_client.py index 0de083efd228..7ac515948e4b 100644 --- a/packages/google-cloud-advisorynotifications/google/cloud/advisorynotifications_v1/services/advisory_notifications_service/async_client.py +++ b/packages/google-cloud-advisorynotifications/google/cloud/advisorynotifications_v1/services/advisory_notifications_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, AdvisoryNotificationsServiceTransport from .transports.grpc_asyncio import AdvisoryNotificationsServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class AdvisoryNotificationsServiceAsyncClient: """Service to manage Security and Privacy Notifications.""" @@ -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.advisorynotifications_v1.AdvisoryNotificationsServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.advisorynotifications.v1.AdvisoryNotificationsService", + "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.advisorynotifications.v1.AdvisoryNotificationsService", + "credentialsType": None, + }, + ) + async def list_notifications( self, request: Optional[Union[service.ListNotificationsRequest, dict]] = None, @@ -285,7 +317,7 @@ async def list_notifications( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListNotificationsAsyncPager: r"""Lists notifications under a given parent. @@ -334,8 +366,10 @@ async def sample_list_notifications(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.advisorynotifications_v1.services.advisory_notifications_service.pagers.ListNotificationsAsyncPager: @@ -410,7 +444,7 @@ async def get_notification( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.Notification: r"""Gets a notification. @@ -457,8 +491,10 @@ async def sample_get_notification(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.advisorynotifications_v1.types.Notification: @@ -520,7 +556,7 @@ async def get_settings( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.Settings: r"""Get notification settings. @@ -567,8 +603,10 @@ async def sample_get_settings(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.advisorynotifications_v1.types.Settings: @@ -627,7 +665,7 @@ async def update_settings( settings: Optional[service.Settings] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.Settings: r"""Update notification settings. @@ -671,8 +709,10 @@ async def sample_update_settings(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.advisorynotifications_v1.types.Settings: diff --git a/packages/google-cloud-advisorynotifications/google/cloud/advisorynotifications_v1/services/advisory_notifications_service/client.py b/packages/google-cloud-advisorynotifications/google/cloud/advisorynotifications_v1/services/advisory_notifications_service/client.py index 9c15dcb41216..d07a0bfcddd5 100644 --- a/packages/google-cloud-advisorynotifications/google/cloud/advisorynotifications_v1/services/advisory_notifications_service/client.py +++ b/packages/google-cloud-advisorynotifications/google/cloud/advisorynotifications_v1/services/advisory_notifications_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.cloud.advisorynotifications_v1.services.advisory_notifications_service import ( @@ -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( @@ -684,6 +698,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.advisorynotifications_v1.AdvisoryNotificationsServiceClient`.", + extra={ + "serviceName": "google.cloud.advisorynotifications.v1.AdvisoryNotificationsService", + "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.advisorynotifications.v1.AdvisoryNotificationsService", + "credentialsType": None, + }, + ) + def list_notifications( self, request: Optional[Union[service.ListNotificationsRequest, dict]] = None, @@ -691,7 +728,7 @@ def list_notifications( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListNotificationsPager: r"""Lists notifications under a given parent. @@ -740,8 +777,10 @@ def sample_list_notifications(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.advisorynotifications_v1.services.advisory_notifications_service.pagers.ListNotificationsPager: @@ -813,7 +852,7 @@ def get_notification( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.Notification: r"""Gets a notification. @@ -860,8 +899,10 @@ def sample_get_notification(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.advisorynotifications_v1.types.Notification: @@ -920,7 +961,7 @@ def get_settings( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.Settings: r"""Get notification settings. @@ -967,8 +1008,10 @@ def sample_get_settings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.advisorynotifications_v1.types.Settings: @@ -1024,7 +1067,7 @@ def update_settings( settings: Optional[service.Settings] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.Settings: r"""Update notification settings. @@ -1068,8 +1111,10 @@ def sample_update_settings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.advisorynotifications_v1.types.Settings: diff --git a/packages/google-cloud-advisorynotifications/google/cloud/advisorynotifications_v1/services/advisory_notifications_service/pagers.py b/packages/google-cloud-advisorynotifications/google/cloud/advisorynotifications_v1/services/advisory_notifications_service/pagers.py index 0f258bcee5f9..12701f54acee 100644 --- a/packages/google-cloud-advisorynotifications/google/cloud/advisorynotifications_v1/services/advisory_notifications_service/pagers.py +++ b/packages/google-cloud-advisorynotifications/google/cloud/advisorynotifications_v1/services/advisory_notifications_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.ListNotificationsRequest(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.ListNotificationsRequest(request) diff --git a/packages/google-cloud-advisorynotifications/google/cloud/advisorynotifications_v1/services/advisory_notifications_service/transports/grpc.py b/packages/google-cloud-advisorynotifications/google/cloud/advisorynotifications_v1/services/advisory_notifications_service/transports/grpc.py index 7208a5d153a5..80042f13e380 100644 --- a/packages/google-cloud-advisorynotifications/google/cloud/advisorynotifications_v1/services/advisory_notifications_service/transports/grpc.py +++ b/packages/google-cloud-advisorynotifications/google/cloud/advisorynotifications_v1/services/advisory_notifications_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.advisorynotifications_v1.types import service from .base import DEFAULT_CLIENT_INFO, AdvisoryNotificationsServiceTransport +try: + from google.api_core import client_logging # 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.advisorynotifications.v1.AdvisoryNotificationsService", + "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.advisorynotifications.v1.AdvisoryNotificationsService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AdvisoryNotificationsServiceGrpcTransport(AdvisoryNotificationsServiceTransport): """gRPC backend transport for AdvisoryNotificationsService. @@ -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 @@ -255,7 +341,7 @@ def list_notifications( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_notifications" not in self._stubs: - self._stubs["list_notifications"] = self.grpc_channel.unary_unary( + self._stubs["list_notifications"] = self._logged_channel.unary_unary( "/google.cloud.advisorynotifications.v1.AdvisoryNotificationsService/ListNotifications", request_serializer=service.ListNotificationsRequest.serialize, response_deserializer=service.ListNotificationsResponse.deserialize, @@ -281,7 +367,7 @@ def get_notification( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_notification" not in self._stubs: - self._stubs["get_notification"] = self.grpc_channel.unary_unary( + self._stubs["get_notification"] = self._logged_channel.unary_unary( "/google.cloud.advisorynotifications.v1.AdvisoryNotificationsService/GetNotification", request_serializer=service.GetNotificationRequest.serialize, response_deserializer=service.Notification.deserialize, @@ -305,7 +391,7 @@ def get_settings(self) -> Callable[[service.GetSettingsRequest], service.Setting # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_settings" not in self._stubs: - self._stubs["get_settings"] = self.grpc_channel.unary_unary( + self._stubs["get_settings"] = self._logged_channel.unary_unary( "/google.cloud.advisorynotifications.v1.AdvisoryNotificationsService/GetSettings", request_serializer=service.GetSettingsRequest.serialize, response_deserializer=service.Settings.deserialize, @@ -331,7 +417,7 @@ def update_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_settings" not in self._stubs: - self._stubs["update_settings"] = self.grpc_channel.unary_unary( + self._stubs["update_settings"] = self._logged_channel.unary_unary( "/google.cloud.advisorynotifications.v1.AdvisoryNotificationsService/UpdateSettings", request_serializer=service.UpdateSettingsRequest.serialize, response_deserializer=service.Settings.deserialize, @@ -339,7 +425,7 @@ def update_settings( return self._stubs["update_settings"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-advisorynotifications/google/cloud/advisorynotifications_v1/services/advisory_notifications_service/transports/grpc_asyncio.py b/packages/google-cloud-advisorynotifications/google/cloud/advisorynotifications_v1/services/advisory_notifications_service/transports/grpc_asyncio.py index 84929f9beb84..aa2b0984018f 100644 --- a/packages/google-cloud-advisorynotifications/google/cloud/advisorynotifications_v1/services/advisory_notifications_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-advisorynotifications/google/cloud/advisorynotifications_v1/services/advisory_notifications_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.advisorynotifications_v1.types import service from .base import DEFAULT_CLIENT_INFO, AdvisoryNotificationsServiceTransport from .grpc import AdvisoryNotificationsServiceGrpcTransport +try: + from google.api_core import client_logging # 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.advisorynotifications.v1.AdvisoryNotificationsService", + "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.advisorynotifications.v1.AdvisoryNotificationsService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AdvisoryNotificationsServiceGrpcAsyncIOTransport( AdvisoryNotificationsServiceTransport @@ -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 @@ -265,7 +350,7 @@ def list_notifications( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_notifications" not in self._stubs: - self._stubs["list_notifications"] = self.grpc_channel.unary_unary( + self._stubs["list_notifications"] = self._logged_channel.unary_unary( "/google.cloud.advisorynotifications.v1.AdvisoryNotificationsService/ListNotifications", request_serializer=service.ListNotificationsRequest.serialize, response_deserializer=service.ListNotificationsResponse.deserialize, @@ -291,7 +376,7 @@ def get_notification( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_notification" not in self._stubs: - self._stubs["get_notification"] = self.grpc_channel.unary_unary( + self._stubs["get_notification"] = self._logged_channel.unary_unary( "/google.cloud.advisorynotifications.v1.AdvisoryNotificationsService/GetNotification", request_serializer=service.GetNotificationRequest.serialize, response_deserializer=service.Notification.deserialize, @@ -317,7 +402,7 @@ def get_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_settings" not in self._stubs: - self._stubs["get_settings"] = self.grpc_channel.unary_unary( + self._stubs["get_settings"] = self._logged_channel.unary_unary( "/google.cloud.advisorynotifications.v1.AdvisoryNotificationsService/GetSettings", request_serializer=service.GetSettingsRequest.serialize, response_deserializer=service.Settings.deserialize, @@ -343,7 +428,7 @@ def update_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_settings" not in self._stubs: - self._stubs["update_settings"] = self.grpc_channel.unary_unary( + self._stubs["update_settings"] = self._logged_channel.unary_unary( "/google.cloud.advisorynotifications.v1.AdvisoryNotificationsService/UpdateSettings", request_serializer=service.UpdateSettingsRequest.serialize, response_deserializer=service.Settings.deserialize, @@ -399,7 +484,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-advisorynotifications/google/cloud/advisorynotifications_v1/services/advisory_notifications_service/transports/rest.py b/packages/google-cloud-advisorynotifications/google/cloud/advisorynotifications_v1/services/advisory_notifications_service/transports/rest.py index 6a7d0a11e5ef..6cb2747c75b4 100644 --- a/packages/google-cloud-advisorynotifications/google/cloud/advisorynotifications_v1/services/advisory_notifications_service/transports/rest.py +++ b/packages/google-cloud-advisorynotifications/google/cloud/advisorynotifications_v1/services/advisory_notifications_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -37,6 +37,14 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = logging.getLogger(__name__) DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, @@ -101,8 +109,8 @@ def post_update_settings(self, response): def pre_get_notification( self, request: service.GetNotificationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.GetNotificationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetNotificationRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_notification Override in a subclass to manipulate the request or metadata @@ -122,8 +130,10 @@ def post_get_notification( return response def pre_get_settings( - self, request: service.GetSettingsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetSettingsRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetSettingsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetSettingsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_settings Override in a subclass to manipulate the request or metadata @@ -143,8 +153,10 @@ def post_get_settings(self, response: service.Settings) -> service.Settings: def pre_list_notifications( self, request: service.ListNotificationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.ListNotificationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.ListNotificationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_notifications Override in a subclass to manipulate the request or metadata @@ -166,8 +178,8 @@ def post_list_notifications( def pre_update_settings( self, request: service.UpdateSettingsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.UpdateSettingsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.UpdateSettingsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_settings Override in a subclass to manipulate the request or metadata @@ -308,7 +320,7 @@ 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.Notification: r"""Call the get notification method over HTTP. @@ -318,8 +330,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.service.Notification: @@ -332,6 +346,7 @@ def __call__( http_options = ( _BaseAdvisoryNotificationsServiceRestTransport._BaseGetNotification._get_http_options() ) + request, metadata = self._interceptor.pre_get_notification( request, metadata ) @@ -344,6 +359,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.advisorynotifications_v1.AdvisoryNotificationsServiceClient.GetNotification", + extra={ + "serviceName": "google.cloud.advisorynotifications.v1.AdvisoryNotificationsService", + "rpcName": "GetNotification", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AdvisoryNotificationsServiceRestTransport._GetNotification._get_response( self._host, @@ -364,7 +406,29 @@ def __call__( pb_resp = service.Notification.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_notification(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.Notification.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.advisorynotifications_v1.AdvisoryNotificationsServiceClient.get_notification", + extra={ + "serviceName": "google.cloud.advisorynotifications.v1.AdvisoryNotificationsService", + "rpcName": "GetNotification", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSettings( @@ -402,7 +466,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.Settings: r"""Call the get settings method over HTTP. @@ -412,8 +476,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.Settings: @@ -423,6 +489,7 @@ def __call__( http_options = ( _BaseAdvisoryNotificationsServiceRestTransport._BaseGetSettings._get_http_options() ) + request, metadata = self._interceptor.pre_get_settings(request, metadata) transcoded_request = _BaseAdvisoryNotificationsServiceRestTransport._BaseGetSettings._get_transcoded_request( http_options, request @@ -433,6 +500,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.advisorynotifications_v1.AdvisoryNotificationsServiceClient.GetSettings", + extra={ + "serviceName": "google.cloud.advisorynotifications.v1.AdvisoryNotificationsService", + "rpcName": "GetSettings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AdvisoryNotificationsServiceRestTransport._GetSettings._get_response( @@ -455,7 +549,29 @@ def __call__( pb_resp = service.Settings.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_settings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.Settings.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.advisorynotifications_v1.AdvisoryNotificationsServiceClient.get_settings", + extra={ + "serviceName": "google.cloud.advisorynotifications.v1.AdvisoryNotificationsService", + "rpcName": "GetSettings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListNotifications( @@ -493,7 +609,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.ListNotificationsResponse: r"""Call the list notifications method over HTTP. @@ -504,8 +620,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ListNotificationsResponse: @@ -517,6 +635,7 @@ def __call__( http_options = ( _BaseAdvisoryNotificationsServiceRestTransport._BaseListNotifications._get_http_options() ) + request, metadata = self._interceptor.pre_list_notifications( request, metadata ) @@ -529,6 +648,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.advisorynotifications_v1.AdvisoryNotificationsServiceClient.ListNotifications", + extra={ + "serviceName": "google.cloud.advisorynotifications.v1.AdvisoryNotificationsService", + "rpcName": "ListNotifications", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AdvisoryNotificationsServiceRestTransport._ListNotifications._get_response( self._host, @@ -549,7 +695,31 @@ def __call__( pb_resp = service.ListNotificationsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_notifications(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListNotificationsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.advisorynotifications_v1.AdvisoryNotificationsServiceClient.list_notifications", + extra={ + "serviceName": "google.cloud.advisorynotifications.v1.AdvisoryNotificationsService", + "rpcName": "ListNotifications", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSettings( @@ -588,7 +758,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.Settings: r"""Call the update settings method over HTTP. @@ -598,8 +768,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.Settings: @@ -609,6 +781,7 @@ def __call__( http_options = ( _BaseAdvisoryNotificationsServiceRestTransport._BaseUpdateSettings._get_http_options() ) + request, metadata = self._interceptor.pre_update_settings(request, metadata) transcoded_request = _BaseAdvisoryNotificationsServiceRestTransport._BaseUpdateSettings._get_transcoded_request( http_options, request @@ -623,6 +796,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.advisorynotifications_v1.AdvisoryNotificationsServiceClient.UpdateSettings", + extra={ + "serviceName": "google.cloud.advisorynotifications.v1.AdvisoryNotificationsService", + "rpcName": "UpdateSettings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AdvisoryNotificationsServiceRestTransport._UpdateSettings._get_response( @@ -646,7 +846,29 @@ def __call__( pb_resp = service.Settings.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_settings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.Settings.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.advisorynotifications_v1.AdvisoryNotificationsServiceClient.update_settings", + extra={ + "serviceName": "google.cloud.advisorynotifications.v1.AdvisoryNotificationsService", + "rpcName": "UpdateSettings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-advisorynotifications/samples/generated_samples/snippet_metadata_google.cloud.advisorynotifications.v1.json b/packages/google-cloud-advisorynotifications/samples/generated_samples/snippet_metadata_google.cloud.advisorynotifications.v1.json index ef66fef02aae..6c6bd1f36550 100644 --- a/packages/google-cloud-advisorynotifications/samples/generated_samples/snippet_metadata_google.cloud.advisorynotifications.v1.json +++ b/packages/google-cloud-advisorynotifications/samples/generated_samples/snippet_metadata_google.cloud.advisorynotifications.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-advisorynotifications", - "version": "0.3.12" + "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.advisorynotifications_v1.types.Notification", @@ -127,7 +127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.advisorynotifications_v1.types.Notification", @@ -208,7 +208,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.advisorynotifications_v1.types.Settings", @@ -288,7 +288,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.advisorynotifications_v1.types.Settings", @@ -369,7 +369,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.advisorynotifications_v1.services.advisory_notifications_service.pagers.ListNotificationsAsyncPager", @@ -449,7 +449,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.advisorynotifications_v1.services.advisory_notifications_service.pagers.ListNotificationsPager", @@ -530,7 +530,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.advisorynotifications_v1.types.Settings", @@ -610,7 +610,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.advisorynotifications_v1.types.Settings", diff --git a/packages/google-cloud-advisorynotifications/tests/unit/gapic/advisorynotifications_v1/test_advisory_notifications_service.py b/packages/google-cloud-advisorynotifications/tests/unit/gapic/advisorynotifications_v1/test_advisory_notifications_service.py index d86d398f7521..f910f0508058 100644 --- a/packages/google-cloud-advisorynotifications/tests/unit/gapic/advisorynotifications_v1/test_advisory_notifications_service.py +++ b/packages/google-cloud-advisorynotifications/tests/unit/gapic/advisorynotifications_v1/test_advisory_notifications_service.py @@ -2790,6 +2790,7 @@ def test_list_notifications_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_notifications(request) @@ -2845,6 +2846,7 @@ def test_list_notifications_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_notifications(**mock_args) @@ -3041,6 +3043,7 @@ def test_get_notification_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_notification(request) @@ -3088,6 +3091,7 @@ def test_get_notification_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_notification(**mock_args) @@ -3217,6 +3221,7 @@ def test_get_settings_rest_required_fields(request_type=service.GetSettingsReque response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_settings(request) @@ -3262,6 +3267,7 @@ def test_get_settings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_settings(**mock_args) @@ -3389,6 +3395,7 @@ def test_update_settings_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_settings(request) @@ -3436,6 +3443,7 @@ def test_update_settings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_settings(**mock_args) @@ -3813,6 +3821,7 @@ def test_list_notifications_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_notifications(request) @@ -3849,6 +3858,7 @@ def test_list_notifications_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_notifications(request) # Establish that the response is the type that we expect. @@ -3891,6 +3901,7 @@ def test_list_notifications_rest_interceptors(null_interceptor): req.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.ListNotificationsResponse.to_json( service.ListNotificationsResponse() ) @@ -3937,6 +3948,7 @@ def test_get_notification_rest_bad_request(request_type=service.GetNotificationR response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_notification(request) @@ -3975,6 +3987,7 @@ def test_get_notification_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_notification(request) # Establish that the response is the type that we expect. @@ -4017,6 +4030,7 @@ def test_get_notification_rest_interceptors(null_interceptor): req.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.Notification.to_json(service.Notification()) req.return_value.content = return_value @@ -4059,6 +4073,7 @@ def test_get_settings_rest_bad_request(request_type=service.GetSettingsRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_settings(request) @@ -4095,6 +4110,7 @@ def test_get_settings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_settings(request) # Establish that the response is the type that we expect. @@ -4134,6 +4150,7 @@ def test_get_settings_rest_interceptors(null_interceptor): req.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.Settings.to_json(service.Settings()) req.return_value.content = return_value @@ -4178,6 +4195,7 @@ def test_update_settings_rest_bad_request(request_type=service.UpdateSettingsReq response_value.status_code = 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_settings(request) @@ -4288,6 +4306,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_settings(request) # Establish that the response is the type that we expect. @@ -4327,6 +4346,7 @@ def test_update_settings_rest_interceptors(null_interceptor): req.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.Settings.to_json(service.Settings()) req.return_value.content = return_value diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb/gapic_version.py b/packages/google-cloud-alloydb/google/cloud/alloydb/gapic_version.py index 386ddb96d97f..558c8aab67c5 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb/gapic_version.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.4.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1/gapic_version.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1/gapic_version.py index 386ddb96d97f..558c8aab67c5 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1/gapic_version.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.4.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_db_admin/async_client.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_db_admin/async_client.py index 9555b58b4ea2..8b7054bdeaac 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_db_admin/async_client.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_db_admin/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, AlloyDBAdminTransport from .transports.grpc_asyncio import AlloyDBAdminGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class AlloyDBAdminAsyncClient: """Service describing handlers for resources""" @@ -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.alloydb_v1.AlloyDBAdminAsyncClient`.", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "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.alloydb.v1.AlloyDBAdmin", + "credentialsType": None, + }, + ) + async def list_clusters( self, request: Optional[Union[service.ListClustersRequest, dict]] = None, @@ -291,7 +323,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. @@ -341,8 +373,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.alloydb_v1.services.alloy_db_admin.pagers.ListClustersAsyncPager: @@ -417,7 +451,7 @@ async def get_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Cluster: r"""Gets details of a single Cluster. @@ -461,8 +495,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.alloydb_v1.types.Cluster: @@ -529,7 +565,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. @@ -596,8 +632,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: @@ -675,7 +713,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. @@ -735,8 +773,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: @@ -813,7 +853,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. @@ -861,8 +901,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: @@ -941,7 +983,7 @@ async def promote_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"""Promotes a SECONDARY cluster. This turns down replication from the PRIMARY cluster and promotes a @@ -992,8 +1034,10 @@ async def sample_promote_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: @@ -1066,7 +1110,7 @@ async def switchover_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"""Switches the roles of PRIMARY and SECONDARY clusters without any data loss. This promotes the SECONDARY @@ -1118,8 +1162,10 @@ async def sample_switchover_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: @@ -1191,7 +1237,7 @@ async def restore_cluster( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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, with a volume restored from the provided @@ -1246,8 +1292,10 @@ async def sample_restore_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: @@ -1308,7 +1356,7 @@ async def create_secondary_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 cluster of type SECONDARY in the given location using the primary cluster as the source. @@ -1378,8 +1426,10 @@ async def sample_create_secondary_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: @@ -1456,7 +1506,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. @@ -1507,8 +1557,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.alloydb_v1.services.alloy_db_admin.pagers.ListInstancesAsyncPager: @@ -1583,7 +1635,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]]] = (), ) -> resources.Instance: r"""Gets details of a single Instance. @@ -1627,8 +1679,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.alloydb_v1.types.Instance: @@ -1693,7 +1747,7 @@ async def create_instance( instance_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new Instance in a given project and location. @@ -1759,8 +1813,10 @@ async def sample_create_instance(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -1837,7 +1893,7 @@ async def create_secondary_instance( instance_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new SECONDARY Instance in a given project and location. @@ -1904,8 +1960,10 @@ async def sample_create_secondary_instance(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -1979,7 +2037,7 @@ async def batch_create_instances( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 new instances under the given project, location and cluster. There can be only one primary @@ -2038,8 +2096,10 @@ async def sample_batch_create_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: @@ -2098,7 +2158,7 @@ async def update_instance( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single Instance. @@ -2157,8 +2217,10 @@ async def sample_update_instance(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -2233,7 +2295,7 @@ async def delete_instance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single Instance. @@ -2281,8 +2343,10 @@ async def sample_delete_instance(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -2361,7 +2425,7 @@ async def failover_instance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Forces a Failover for a highly available instance. Failover promotes the HA standby instance as the new @@ -2412,8 +2476,10 @@ async def sample_failover_instance(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -2485,7 +2551,7 @@ async def inject_fault( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Injects fault in an instance. Imperative only. @@ -2543,8 +2609,10 @@ async def sample_inject_fault(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -2617,7 +2685,7 @@ async def restart_instance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Restart an Instance in a cluster. Imperative only. @@ -2666,8 +2734,10 @@ async def sample_restart_instance(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -2742,7 +2812,7 @@ async def execute_sql( password: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.ExecuteSqlResponse: r"""Executes a SQL statement in a database inside an AlloyDB instance. @@ -2826,8 +2896,10 @@ async def sample_execute_sql(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1.types.ExecuteSqlResponse: @@ -2894,7 +2966,7 @@ async def list_backups( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListBackupsAsyncPager: r"""Lists Backups in a given project and location. @@ -2939,8 +3011,10 @@ async def sample_list_backups(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1.services.alloy_db_admin.pagers.ListBackupsAsyncPager: @@ -3015,7 +3089,7 @@ async def get_backup( name: Optional[str] = None, retry: OptionalRetry = 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.Backup: r"""Gets details of a single Backup. @@ -3056,8 +3130,10 @@ async def sample_get_backup(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1.types.Backup: @@ -3118,7 +3194,7 @@ async def create_backup( backup_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 Backup in a given project and location. @@ -3180,8 +3256,10 @@ async def sample_create_backup(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -3258,7 +3336,7 @@ async def update_backup( 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 Backup. @@ -3317,8 +3395,10 @@ async def sample_update_backup(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -3394,7 +3474,7 @@ async def delete_backup( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 Backup. @@ -3442,8 +3522,10 @@ async def sample_delete_backup(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -3524,7 +3606,7 @@ async def list_supported_database_flags( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSupportedDatabaseFlagsAsyncPager: r"""Lists SupportedDatabaseFlags for a given project and location. @@ -3577,8 +3659,10 @@ async def sample_list_supported_database_flags(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1.services.alloy_db_admin.pagers.ListSupportedDatabaseFlagsAsyncPager: @@ -3653,7 +3737,7 @@ async def generate_client_certificate( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.GenerateClientCertificateResponse: r"""Generate a client certificate signed by a Cluster CA. The sole purpose of this endpoint is to support AlloyDB @@ -3706,8 +3790,10 @@ async def sample_generate_client_certificate(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1.types.GenerateClientCertificateResponse: @@ -3768,7 +3854,7 @@ async def get_connection_info( parent: Optional[str] = None, retry: OptionalRetry = 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.ConnectionInfo: r"""Get instance metadata used for a connection. @@ -3813,8 +3899,10 @@ async def sample_get_connection_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.alloydb_v1.types.ConnectionInfo: @@ -3875,7 +3963,7 @@ async def list_users( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListUsersAsyncPager: r"""Lists Users in a given project and location. @@ -3919,8 +4007,10 @@ async def sample_list_users(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1.services.alloy_db_admin.pagers.ListUsersAsyncPager: @@ -3995,7 +4085,7 @@ async def get_user( name: Optional[str] = None, retry: OptionalRetry = 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.User: r"""Gets details of a single User. @@ -4039,8 +4129,10 @@ async def sample_get_user(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1.types.User: @@ -4099,7 +4191,7 @@ async def create_user( user_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.User: r"""Creates a new User in a given project, location, and cluster. @@ -4154,8 +4246,10 @@ async def sample_create_user(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1.types.User: @@ -4219,7 +4313,7 @@ async def update_user( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.User: r"""Updates the parameters of a single User. @@ -4270,8 +4364,10 @@ async def sample_update_user(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1.types.User: @@ -4334,7 +4430,7 @@ async def delete_user( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 User. @@ -4375,8 +4471,10 @@ async def sample_delete_user(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -4428,7 +4526,7 @@ async def list_databases( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDatabasesAsyncPager: r"""Lists Databases in a given project and location. @@ -4473,8 +4571,10 @@ async def sample_list_databases(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1.services.alloy_db_admin.pagers.ListDatabasesAsyncPager: @@ -4548,7 +4648,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. @@ -4559,8 +4659,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. @@ -4601,7 +4703,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. @@ -4612,8 +4714,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. @@ -4654,7 +4758,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. @@ -4670,8 +4774,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 """ @@ -4708,7 +4814,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. @@ -4723,8 +4829,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 """ @@ -4761,7 +4869,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. @@ -4772,8 +4880,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. @@ -4814,7 +4924,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. @@ -4825,8 +4935,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-alloydb/google/cloud/alloydb_v1/services/alloy_db_admin/client.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_db_admin/client.py index 6b93cfa2f619..9af3a0a32780 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_db_admin/client.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_db_admin/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 @@ -771,6 +781,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -833,6 +847,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.alloydb_v1.AlloyDBAdminClient`.", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "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.alloydb.v1.AlloyDBAdmin", + "credentialsType": None, + }, + ) + def list_clusters( self, request: Optional[Union[service.ListClustersRequest, dict]] = None, @@ -840,7 +877,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. @@ -890,8 +927,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.alloydb_v1.services.alloy_db_admin.pagers.ListClustersPager: @@ -963,7 +1002,7 @@ def get_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Cluster: r"""Gets details of a single Cluster. @@ -1007,8 +1046,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.alloydb_v1.types.Cluster: @@ -1072,7 +1113,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. @@ -1139,8 +1180,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: @@ -1215,7 +1258,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. @@ -1275,8 +1318,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: @@ -1350,7 +1395,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. @@ -1398,8 +1443,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: @@ -1475,7 +1522,7 @@ def promote_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"""Promotes a SECONDARY cluster. This turns down replication from the PRIMARY cluster and promotes a @@ -1526,8 +1573,10 @@ def sample_promote_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: @@ -1597,7 +1646,7 @@ def switchover_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"""Switches the roles of PRIMARY and SECONDARY clusters without any data loss. This promotes the SECONDARY @@ -1649,8 +1698,10 @@ def sample_switchover_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: @@ -1719,7 +1770,7 @@ def restore_cluster( *, retry: OptionalRetry = gapic_v1.method.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, with a volume restored from the provided @@ -1774,8 +1825,10 @@ def sample_restore_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: @@ -1834,7 +1887,7 @@ def create_secondary_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 cluster of type SECONDARY in the given location using the primary cluster as the source. @@ -1904,8 +1957,10 @@ def sample_create_secondary_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: @@ -1979,7 +2034,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. @@ -2030,8 +2085,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.alloydb_v1.services.alloy_db_admin.pagers.ListInstancesPager: @@ -2103,7 +2160,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]]] = (), ) -> resources.Instance: r"""Gets details of a single Instance. @@ -2147,8 +2204,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.alloydb_v1.types.Instance: @@ -2210,7 +2269,7 @@ def create_instance( instance_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new Instance in a given project and location. @@ -2276,8 +2335,10 @@ def sample_create_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -2351,7 +2412,7 @@ def create_secondary_instance( instance_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new SECONDARY Instance in a given project and location. @@ -2418,8 +2479,10 @@ def sample_create_secondary_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -2492,7 +2555,7 @@ def batch_create_instances( *, retry: OptionalRetry = gapic_v1.method.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 new instances under the given project, location and cluster. There can be only one primary @@ -2551,8 +2614,10 @@ def sample_batch_create_instances(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -2609,7 +2674,7 @@ def update_instance( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the parameters of a single Instance. @@ -2668,8 +2733,10 @@ def sample_update_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -2741,7 +2808,7 @@ def delete_instance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single Instance. @@ -2789,8 +2856,10 @@ def sample_delete_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -2866,7 +2935,7 @@ def failover_instance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Forces a Failover for a highly available instance. Failover promotes the HA standby instance as the new @@ -2917,8 +2986,10 @@ def sample_failover_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -2987,7 +3058,7 @@ def inject_fault( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Injects fault in an instance. Imperative only. @@ -3045,8 +3116,10 @@ def sample_inject_fault(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -3116,7 +3189,7 @@ def restart_instance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Restart an Instance in a cluster. Imperative only. @@ -3165,8 +3238,10 @@ def sample_restart_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -3238,7 +3313,7 @@ def execute_sql( password: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.ExecuteSqlResponse: r"""Executes a SQL statement in a database inside an AlloyDB instance. @@ -3322,8 +3397,10 @@ def sample_execute_sql(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1.types.ExecuteSqlResponse: @@ -3387,7 +3464,7 @@ def list_backups( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListBackupsPager: r"""Lists Backups in a given project and location. @@ -3432,8 +3509,10 @@ def sample_list_backups(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1.services.alloy_db_admin.pagers.ListBackupsPager: @@ -3505,7 +3584,7 @@ def get_backup( name: Optional[str] = None, retry: OptionalRetry = 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.Backup: r"""Gets details of a single Backup. @@ -3546,8 +3625,10 @@ def sample_get_backup(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1.types.Backup: @@ -3605,7 +3686,7 @@ def create_backup( backup_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 Backup in a given project and location. @@ -3667,8 +3748,10 @@ def sample_create_backup(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -3742,7 +3825,7 @@ def update_backup( 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 Backup. @@ -3801,8 +3884,10 @@ def sample_update_backup(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -3875,7 +3960,7 @@ def delete_backup( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 Backup. @@ -3923,8 +4008,10 @@ def sample_delete_backup(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -4002,7 +4089,7 @@ def list_supported_database_flags( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSupportedDatabaseFlagsPager: r"""Lists SupportedDatabaseFlags for a given project and location. @@ -4055,8 +4142,10 @@ def sample_list_supported_database_flags(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1.services.alloy_db_admin.pagers.ListSupportedDatabaseFlagsPager: @@ -4130,7 +4219,7 @@ def generate_client_certificate( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.GenerateClientCertificateResponse: r"""Generate a client certificate signed by a Cluster CA. The sole purpose of this endpoint is to support AlloyDB @@ -4183,8 +4272,10 @@ def sample_generate_client_certificate(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1.types.GenerateClientCertificateResponse: @@ -4244,7 +4335,7 @@ def get_connection_info( parent: Optional[str] = None, retry: OptionalRetry = 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.ConnectionInfo: r"""Get instance metadata used for a connection. @@ -4289,8 +4380,10 @@ def sample_get_connection_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.alloydb_v1.types.ConnectionInfo: @@ -4348,7 +4441,7 @@ def list_users( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListUsersPager: r"""Lists Users in a given project and location. @@ -4392,8 +4485,10 @@ def sample_list_users(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1.services.alloy_db_admin.pagers.ListUsersPager: @@ -4465,7 +4560,7 @@ def get_user( name: Optional[str] = None, retry: OptionalRetry = 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.User: r"""Gets details of a single User. @@ -4509,8 +4604,10 @@ def sample_get_user(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1.types.User: @@ -4568,7 +4665,7 @@ def create_user( user_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.User: r"""Creates a new User in a given project, location, and cluster. @@ -4623,8 +4720,10 @@ def sample_create_user(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1.types.User: @@ -4685,7 +4784,7 @@ def update_user( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.User: r"""Updates the parameters of a single User. @@ -4736,8 +4835,10 @@ def sample_update_user(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1.types.User: @@ -4797,7 +4898,7 @@ def delete_user( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 User. @@ -4838,8 +4939,10 @@ def sample_delete_user(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -4888,7 +4991,7 @@ def list_databases( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDatabasesPager: r"""Lists Databases in a given project and location. @@ -4933,8 +5036,10 @@ def sample_list_databases(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1.services.alloy_db_admin.pagers.ListDatabasesPager: @@ -5018,7 +5123,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. @@ -5029,8 +5134,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. @@ -5071,7 +5178,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. @@ -5082,8 +5189,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. @@ -5124,7 +5233,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. @@ -5140,8 +5249,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 """ @@ -5178,7 +5289,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. @@ -5193,8 +5304,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 """ @@ -5231,7 +5344,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. @@ -5242,8 +5355,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. @@ -5284,7 +5399,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. @@ -5295,8 +5410,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-alloydb/google/cloud/alloydb_v1/services/alloy_db_admin/pagers.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_db_admin/pagers.py index a5eb030b63d5..34c20b33de40 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_db_admin/pagers.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_db_admin/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.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 = 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 = service.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 = service.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 = service.ListBackupsRequest(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.ListBackupsRequest(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.ListSupportedDatabaseFlagsRequest(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.ListSupportedDatabaseFlagsRequest(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.ListUsersRequest(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.ListUsersRequest(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 = service.ListDatabasesRequest(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 = service.ListDatabasesRequest(request) diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_db_admin/transports/grpc.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_db_admin/transports/grpc.py index 9ea88e57200b..fb75dd4dd78f 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_db_admin/transports/grpc.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_db_admin/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.alloydb_v1.types import resources, service from .base import DEFAULT_CLIENT_INFO, AlloyDBAdminTransport +try: + from google.api_core import client_logging # 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.alloydb.v1.AlloyDBAdmin", + "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.alloydb.v1.AlloyDBAdmin", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AlloyDBAdminGrpcTransport(AlloyDBAdminTransport): """gRPC backend transport for AlloyDBAdmin. @@ -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 @@ -273,7 +361,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.alloydb.v1.AlloyDBAdmin/ListClusters", request_serializer=service.ListClustersRequest.serialize, response_deserializer=service.ListClustersResponse.deserialize, @@ -297,7 +385,7 @@ def get_cluster(self) -> Callable[[service.GetClusterRequest], resources.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.alloydb.v1.AlloyDBAdmin/GetCluster", request_serializer=service.GetClusterRequest.serialize, response_deserializer=resources.Cluster.deserialize, @@ -324,7 +412,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.alloydb.v1.AlloyDBAdmin/CreateCluster", request_serializer=service.CreateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -350,7 +438,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.alloydb.v1.AlloyDBAdmin/UpdateCluster", request_serializer=service.UpdateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -376,7 +464,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.alloydb.v1.AlloyDBAdmin/DeleteCluster", request_serializer=service.DeleteClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -405,7 +493,7 @@ def promote_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "promote_cluster" not in self._stubs: - self._stubs["promote_cluster"] = self.grpc_channel.unary_unary( + self._stubs["promote_cluster"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/PromoteCluster", request_serializer=service.PromoteClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -434,7 +522,7 @@ def switchover_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "switchover_cluster" not in self._stubs: - self._stubs["switchover_cluster"] = self.grpc_channel.unary_unary( + self._stubs["switchover_cluster"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/SwitchoverCluster", request_serializer=service.SwitchoverClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -463,7 +551,7 @@ def restore_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "restore_cluster" not in self._stubs: - self._stubs["restore_cluster"] = self.grpc_channel.unary_unary( + self._stubs["restore_cluster"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/RestoreCluster", request_serializer=service.RestoreClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -490,7 +578,7 @@ def create_secondary_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_secondary_cluster" not in self._stubs: - self._stubs["create_secondary_cluster"] = self.grpc_channel.unary_unary( + self._stubs["create_secondary_cluster"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/CreateSecondaryCluster", request_serializer=service.CreateSecondaryClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -516,7 +604,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.alloydb.v1.AlloyDBAdmin/ListInstances", request_serializer=service.ListInstancesRequest.serialize, response_deserializer=service.ListInstancesResponse.deserialize, @@ -542,7 +630,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.alloydb.v1.AlloyDBAdmin/GetInstance", request_serializer=service.GetInstanceRequest.serialize, response_deserializer=resources.Instance.deserialize, @@ -569,7 +657,7 @@ def create_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_instance" not in self._stubs: - self._stubs["create_instance"] = self.grpc_channel.unary_unary( + self._stubs["create_instance"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/CreateInstance", request_serializer=service.CreateInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -596,7 +684,7 @@ def create_secondary_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_secondary_instance" not in self._stubs: - self._stubs["create_secondary_instance"] = self.grpc_channel.unary_unary( + self._stubs["create_secondary_instance"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/CreateSecondaryInstance", request_serializer=service.CreateSecondaryInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -634,7 +722,7 @@ def batch_create_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_create_instances" not in self._stubs: - self._stubs["batch_create_instances"] = self.grpc_channel.unary_unary( + self._stubs["batch_create_instances"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/BatchCreateInstances", request_serializer=service.BatchCreateInstancesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -660,7 +748,7 @@ def update_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_instance" not in self._stubs: - self._stubs["update_instance"] = self.grpc_channel.unary_unary( + self._stubs["update_instance"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/UpdateInstance", request_serializer=service.UpdateInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -686,7 +774,7 @@ def delete_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_instance" not in self._stubs: - self._stubs["delete_instance"] = self.grpc_channel.unary_unary( + self._stubs["delete_instance"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/DeleteInstance", request_serializer=service.DeleteInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -714,7 +802,7 @@ def failover_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "failover_instance" not in self._stubs: - self._stubs["failover_instance"] = self.grpc_channel.unary_unary( + self._stubs["failover_instance"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/FailoverInstance", request_serializer=service.FailoverInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -741,7 +829,7 @@ def inject_fault( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "inject_fault" not in self._stubs: - self._stubs["inject_fault"] = self.grpc_channel.unary_unary( + self._stubs["inject_fault"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/InjectFault", request_serializer=service.InjectFaultRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -768,7 +856,7 @@ def restart_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "restart_instance" not in self._stubs: - self._stubs["restart_instance"] = self.grpc_channel.unary_unary( + self._stubs["restart_instance"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/RestartInstance", request_serializer=service.RestartInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -795,7 +883,7 @@ def execute_sql( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "execute_sql" not in self._stubs: - self._stubs["execute_sql"] = self.grpc_channel.unary_unary( + self._stubs["execute_sql"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/ExecuteSql", request_serializer=service.ExecuteSqlRequest.serialize, response_deserializer=service.ExecuteSqlResponse.deserialize, @@ -821,7 +909,7 @@ def list_backups( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_backups" not in self._stubs: - self._stubs["list_backups"] = self.grpc_channel.unary_unary( + self._stubs["list_backups"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/ListBackups", request_serializer=service.ListBackupsRequest.serialize, response_deserializer=service.ListBackupsResponse.deserialize, @@ -845,7 +933,7 @@ def get_backup(self) -> Callable[[service.GetBackupRequest], resources.Backup]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_backup" not in self._stubs: - self._stubs["get_backup"] = self.grpc_channel.unary_unary( + self._stubs["get_backup"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/GetBackup", request_serializer=service.GetBackupRequest.serialize, response_deserializer=resources.Backup.deserialize, @@ -871,7 +959,7 @@ def create_backup( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_backup" not in self._stubs: - self._stubs["create_backup"] = self.grpc_channel.unary_unary( + self._stubs["create_backup"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/CreateBackup", request_serializer=service.CreateBackupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -897,7 +985,7 @@ def update_backup( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_backup" not in self._stubs: - self._stubs["update_backup"] = self.grpc_channel.unary_unary( + self._stubs["update_backup"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/UpdateBackup", request_serializer=service.UpdateBackupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -923,7 +1011,7 @@ def delete_backup( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_backup" not in self._stubs: - self._stubs["delete_backup"] = self.grpc_channel.unary_unary( + self._stubs["delete_backup"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/DeleteBackup", request_serializer=service.DeleteBackupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -955,7 +1043,7 @@ def list_supported_database_flags( if "list_supported_database_flags" not in self._stubs: self._stubs[ "list_supported_database_flags" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/ListSupportedDatabaseFlags", request_serializer=service.ListSupportedDatabaseFlagsRequest.serialize, response_deserializer=service.ListSupportedDatabaseFlagsResponse.deserialize, @@ -990,7 +1078,9 @@ def generate_client_certificate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_client_certificate" not in self._stubs: - self._stubs["generate_client_certificate"] = self.grpc_channel.unary_unary( + self._stubs[ + "generate_client_certificate" + ] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/GenerateClientCertificate", request_serializer=service.GenerateClientCertificateRequest.serialize, response_deserializer=service.GenerateClientCertificateResponse.deserialize, @@ -1016,7 +1106,7 @@ def get_connection_info( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_connection_info" not in self._stubs: - self._stubs["get_connection_info"] = self.grpc_channel.unary_unary( + self._stubs["get_connection_info"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/GetConnectionInfo", request_serializer=service.GetConnectionInfoRequest.serialize, response_deserializer=resources.ConnectionInfo.deserialize, @@ -1042,7 +1132,7 @@ def list_users( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_users" not in self._stubs: - self._stubs["list_users"] = self.grpc_channel.unary_unary( + self._stubs["list_users"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/ListUsers", request_serializer=service.ListUsersRequest.serialize, response_deserializer=service.ListUsersResponse.deserialize, @@ -1066,7 +1156,7 @@ def get_user(self) -> Callable[[service.GetUserRequest], resources.User]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_user" not in self._stubs: - self._stubs["get_user"] = self.grpc_channel.unary_unary( + self._stubs["get_user"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/GetUser", request_serializer=service.GetUserRequest.serialize, response_deserializer=resources.User.deserialize, @@ -1091,7 +1181,7 @@ def create_user(self) -> Callable[[service.CreateUserRequest], resources.User]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_user" not in self._stubs: - self._stubs["create_user"] = self.grpc_channel.unary_unary( + self._stubs["create_user"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/CreateUser", request_serializer=service.CreateUserRequest.serialize, response_deserializer=resources.User.deserialize, @@ -1115,7 +1205,7 @@ def update_user(self) -> Callable[[service.UpdateUserRequest], resources.User]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_user" not in self._stubs: - self._stubs["update_user"] = self.grpc_channel.unary_unary( + self._stubs["update_user"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/UpdateUser", request_serializer=service.UpdateUserRequest.serialize, response_deserializer=resources.User.deserialize, @@ -1139,7 +1229,7 @@ def delete_user(self) -> Callable[[service.DeleteUserRequest], empty_pb2.Empty]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_user" not in self._stubs: - self._stubs["delete_user"] = self.grpc_channel.unary_unary( + self._stubs["delete_user"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/DeleteUser", request_serializer=service.DeleteUserRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1165,7 +1255,7 @@ def list_databases( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_databases" not in self._stubs: - self._stubs["list_databases"] = self.grpc_channel.unary_unary( + self._stubs["list_databases"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/ListDatabases", request_serializer=service.ListDatabasesRequest.serialize, response_deserializer=service.ListDatabasesResponse.deserialize, @@ -1173,7 +1263,7 @@ def list_databases( return self._stubs["list_databases"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -1185,7 +1275,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 +1292,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 +1309,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 +1328,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, @@ -1257,7 +1347,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, @@ -1274,7 +1364,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-alloydb/google/cloud/alloydb_v1/services/alloy_db_admin/transports/grpc_asyncio.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_db_admin/transports/grpc_asyncio.py index 39901e54a154..fc4d83f71dda 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_db_admin/transports/grpc_asyncio.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_db_admin/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.alloydb_v1.types import resources, service from .base import DEFAULT_CLIENT_INFO, AlloyDBAdminTransport from .grpc import AlloyDBAdminGrpcTransport +try: + from google.api_core import client_logging # 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.alloydb.v1.AlloyDBAdmin", + "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.alloydb.v1.AlloyDBAdmin", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AlloyDBAdminGrpcAsyncIOTransport(AlloyDBAdminTransport): """gRPC AsyncIO backend transport for AlloyDBAdmin. @@ -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. @@ -285,7 +370,7 @@ def list_clusters( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_clusters" not in self._stubs: - self._stubs["list_clusters"] = self.grpc_channel.unary_unary( + self._stubs["list_clusters"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/ListClusters", request_serializer=service.ListClustersRequest.serialize, response_deserializer=service.ListClustersResponse.deserialize, @@ -311,7 +396,7 @@ def get_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_cluster" not in self._stubs: - self._stubs["get_cluster"] = self.grpc_channel.unary_unary( + self._stubs["get_cluster"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/GetCluster", request_serializer=service.GetClusterRequest.serialize, response_deserializer=resources.Cluster.deserialize, @@ -338,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.alloydb.v1.AlloyDBAdmin/CreateCluster", request_serializer=service.CreateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -364,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.alloydb.v1.AlloyDBAdmin/UpdateCluster", request_serializer=service.UpdateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -390,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.alloydb.v1.AlloyDBAdmin/DeleteCluster", request_serializer=service.DeleteClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -419,7 +504,7 @@ def promote_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "promote_cluster" not in self._stubs: - self._stubs["promote_cluster"] = self.grpc_channel.unary_unary( + self._stubs["promote_cluster"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/PromoteCluster", request_serializer=service.PromoteClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -450,7 +535,7 @@ def switchover_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "switchover_cluster" not in self._stubs: - self._stubs["switchover_cluster"] = self.grpc_channel.unary_unary( + self._stubs["switchover_cluster"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/SwitchoverCluster", request_serializer=service.SwitchoverClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -479,7 +564,7 @@ def restore_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "restore_cluster" not in self._stubs: - self._stubs["restore_cluster"] = self.grpc_channel.unary_unary( + self._stubs["restore_cluster"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/RestoreCluster", request_serializer=service.RestoreClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -508,7 +593,7 @@ def create_secondary_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_secondary_cluster" not in self._stubs: - self._stubs["create_secondary_cluster"] = self.grpc_channel.unary_unary( + self._stubs["create_secondary_cluster"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/CreateSecondaryCluster", request_serializer=service.CreateSecondaryClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -536,7 +621,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.alloydb.v1.AlloyDBAdmin/ListInstances", request_serializer=service.ListInstancesRequest.serialize, response_deserializer=service.ListInstancesResponse.deserialize, @@ -562,7 +647,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.alloydb.v1.AlloyDBAdmin/GetInstance", request_serializer=service.GetInstanceRequest.serialize, response_deserializer=resources.Instance.deserialize, @@ -589,7 +674,7 @@ def create_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_instance" not in self._stubs: - self._stubs["create_instance"] = self.grpc_channel.unary_unary( + self._stubs["create_instance"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/CreateInstance", request_serializer=service.CreateInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -618,7 +703,7 @@ def create_secondary_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_secondary_instance" not in self._stubs: - self._stubs["create_secondary_instance"] = self.grpc_channel.unary_unary( + self._stubs["create_secondary_instance"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/CreateSecondaryInstance", request_serializer=service.CreateSecondaryInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -658,7 +743,7 @@ def batch_create_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_create_instances" not in self._stubs: - self._stubs["batch_create_instances"] = self.grpc_channel.unary_unary( + self._stubs["batch_create_instances"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/BatchCreateInstances", request_serializer=service.BatchCreateInstancesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -684,7 +769,7 @@ def update_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_instance" not in self._stubs: - self._stubs["update_instance"] = self.grpc_channel.unary_unary( + self._stubs["update_instance"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/UpdateInstance", request_serializer=service.UpdateInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -710,7 +795,7 @@ def delete_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_instance" not in self._stubs: - self._stubs["delete_instance"] = self.grpc_channel.unary_unary( + self._stubs["delete_instance"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/DeleteInstance", request_serializer=service.DeleteInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -740,7 +825,7 @@ def failover_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "failover_instance" not in self._stubs: - self._stubs["failover_instance"] = self.grpc_channel.unary_unary( + self._stubs["failover_instance"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/FailoverInstance", request_serializer=service.FailoverInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -767,7 +852,7 @@ def inject_fault( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "inject_fault" not in self._stubs: - self._stubs["inject_fault"] = self.grpc_channel.unary_unary( + self._stubs["inject_fault"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/InjectFault", request_serializer=service.InjectFaultRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -796,7 +881,7 @@ def restart_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "restart_instance" not in self._stubs: - self._stubs["restart_instance"] = self.grpc_channel.unary_unary( + self._stubs["restart_instance"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/RestartInstance", request_serializer=service.RestartInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -823,7 +908,7 @@ def execute_sql( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "execute_sql" not in self._stubs: - self._stubs["execute_sql"] = self.grpc_channel.unary_unary( + self._stubs["execute_sql"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/ExecuteSql", request_serializer=service.ExecuteSqlRequest.serialize, response_deserializer=service.ExecuteSqlResponse.deserialize, @@ -849,7 +934,7 @@ def list_backups( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_backups" not in self._stubs: - self._stubs["list_backups"] = self.grpc_channel.unary_unary( + self._stubs["list_backups"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/ListBackups", request_serializer=service.ListBackupsRequest.serialize, response_deserializer=service.ListBackupsResponse.deserialize, @@ -875,7 +960,7 @@ def get_backup( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_backup" not in self._stubs: - self._stubs["get_backup"] = self.grpc_channel.unary_unary( + self._stubs["get_backup"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/GetBackup", request_serializer=service.GetBackupRequest.serialize, response_deserializer=resources.Backup.deserialize, @@ -901,7 +986,7 @@ def create_backup( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_backup" not in self._stubs: - self._stubs["create_backup"] = self.grpc_channel.unary_unary( + self._stubs["create_backup"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/CreateBackup", request_serializer=service.CreateBackupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -927,7 +1012,7 @@ def update_backup( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_backup" not in self._stubs: - self._stubs["update_backup"] = self.grpc_channel.unary_unary( + self._stubs["update_backup"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/UpdateBackup", request_serializer=service.UpdateBackupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -953,7 +1038,7 @@ def delete_backup( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_backup" not in self._stubs: - self._stubs["delete_backup"] = self.grpc_channel.unary_unary( + self._stubs["delete_backup"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/DeleteBackup", request_serializer=service.DeleteBackupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -985,7 +1070,7 @@ def list_supported_database_flags( if "list_supported_database_flags" not in self._stubs: self._stubs[ "list_supported_database_flags" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/ListSupportedDatabaseFlags", request_serializer=service.ListSupportedDatabaseFlagsRequest.serialize, response_deserializer=service.ListSupportedDatabaseFlagsResponse.deserialize, @@ -1020,7 +1105,9 @@ def generate_client_certificate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_client_certificate" not in self._stubs: - self._stubs["generate_client_certificate"] = self.grpc_channel.unary_unary( + self._stubs[ + "generate_client_certificate" + ] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/GenerateClientCertificate", request_serializer=service.GenerateClientCertificateRequest.serialize, response_deserializer=service.GenerateClientCertificateResponse.deserialize, @@ -1048,7 +1135,7 @@ def get_connection_info( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_connection_info" not in self._stubs: - self._stubs["get_connection_info"] = self.grpc_channel.unary_unary( + self._stubs["get_connection_info"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/GetConnectionInfo", request_serializer=service.GetConnectionInfoRequest.serialize, response_deserializer=resources.ConnectionInfo.deserialize, @@ -1074,7 +1161,7 @@ def list_users( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_users" not in self._stubs: - self._stubs["list_users"] = self.grpc_channel.unary_unary( + self._stubs["list_users"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/ListUsers", request_serializer=service.ListUsersRequest.serialize, response_deserializer=service.ListUsersResponse.deserialize, @@ -1098,7 +1185,7 @@ def get_user(self) -> Callable[[service.GetUserRequest], Awaitable[resources.Use # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_user" not in self._stubs: - self._stubs["get_user"] = self.grpc_channel.unary_unary( + self._stubs["get_user"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/GetUser", request_serializer=service.GetUserRequest.serialize, response_deserializer=resources.User.deserialize, @@ -1125,7 +1212,7 @@ def create_user( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_user" not in self._stubs: - self._stubs["create_user"] = self.grpc_channel.unary_unary( + self._stubs["create_user"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/CreateUser", request_serializer=service.CreateUserRequest.serialize, response_deserializer=resources.User.deserialize, @@ -1151,7 +1238,7 @@ def update_user( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_user" not in self._stubs: - self._stubs["update_user"] = self.grpc_channel.unary_unary( + self._stubs["update_user"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/UpdateUser", request_serializer=service.UpdateUserRequest.serialize, response_deserializer=resources.User.deserialize, @@ -1177,7 +1264,7 @@ def delete_user( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_user" not in self._stubs: - self._stubs["delete_user"] = self.grpc_channel.unary_unary( + self._stubs["delete_user"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/DeleteUser", request_serializer=service.DeleteUserRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1205,7 +1292,7 @@ def list_databases( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_databases" not in self._stubs: - self._stubs["list_databases"] = self.grpc_channel.unary_unary( + self._stubs["list_databases"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1.AlloyDBAdmin/ListDatabases", request_serializer=service.ListDatabasesRequest.serialize, response_deserializer=service.ListDatabasesResponse.deserialize, @@ -1504,7 +1591,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: @@ -1520,7 +1607,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, @@ -1537,7 +1624,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, @@ -1554,7 +1641,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, @@ -1573,7 +1660,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, @@ -1592,7 +1679,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, @@ -1609,7 +1696,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-alloydb/google/cloud/alloydb_v1/services/alloy_db_admin/transports/rest.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_db_admin/transports/rest.py index de223f20e6ae..faa1b840a61b 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_db_admin/transports/rest.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1/services/alloy_db_admin/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, @@ -342,8 +350,10 @@ def post_update_user(self, response): def pre_batch_create_instances( self, request: service.BatchCreateInstancesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.BatchCreateInstancesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.BatchCreateInstancesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for batch_create_instances Override in a subclass to manipulate the request or metadata @@ -363,8 +373,10 @@ def post_batch_create_instances( return response def pre_create_backup( - self, request: service.CreateBackupRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.CreateBackupRequest, Sequence[Tuple[str, str]]]: + self, + request: service.CreateBackupRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.CreateBackupRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_backup Override in a subclass to manipulate the request or metadata @@ -384,8 +396,10 @@ def post_create_backup( return response def pre_create_cluster( - self, request: service.CreateClusterRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.CreateClusterRequest, Sequence[Tuple[str, str]]]: + self, + request: service.CreateClusterRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.CreateClusterRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_cluster Override in a subclass to manipulate the request or metadata @@ -407,8 +421,8 @@ def post_create_cluster( def pre_create_instance( self, request: service.CreateInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.CreateInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.CreateInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_instance Override in a subclass to manipulate the request or metadata @@ -430,8 +444,10 @@ def post_create_instance( def pre_create_secondary_cluster( self, request: service.CreateSecondaryClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.CreateSecondaryClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.CreateSecondaryClusterRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_secondary_cluster Override in a subclass to manipulate the request or metadata @@ -453,8 +469,10 @@ def post_create_secondary_cluster( def pre_create_secondary_instance( self, request: service.CreateSecondaryInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.CreateSecondaryInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.CreateSecondaryInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_secondary_instance Override in a subclass to manipulate the request or metadata @@ -474,8 +492,10 @@ def post_create_secondary_instance( return response def pre_create_user( - self, request: service.CreateUserRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.CreateUserRequest, Sequence[Tuple[str, str]]]: + self, + request: service.CreateUserRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.CreateUserRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_user Override in a subclass to manipulate the request or metadata @@ -493,8 +513,10 @@ def post_create_user(self, response: resources.User) -> resources.User: return response def pre_delete_backup( - self, request: service.DeleteBackupRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.DeleteBackupRequest, Sequence[Tuple[str, str]]]: + self, + request: service.DeleteBackupRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.DeleteBackupRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_backup Override in a subclass to manipulate the request or metadata @@ -514,8 +536,10 @@ def post_delete_backup( return response def pre_delete_cluster( - self, request: service.DeleteClusterRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.DeleteClusterRequest, Sequence[Tuple[str, str]]]: + self, + request: service.DeleteClusterRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.DeleteClusterRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_cluster Override in a subclass to manipulate the request or metadata @@ -537,8 +561,8 @@ def post_delete_cluster( def pre_delete_instance( self, request: service.DeleteInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.DeleteInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.DeleteInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_instance Override in a subclass to manipulate the request or metadata @@ -558,8 +582,10 @@ def post_delete_instance( return response def pre_delete_user( - self, request: service.DeleteUserRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.DeleteUserRequest, Sequence[Tuple[str, str]]]: + self, + request: service.DeleteUserRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.DeleteUserRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_user Override in a subclass to manipulate the request or metadata @@ -568,8 +594,10 @@ def pre_delete_user( return request, metadata def pre_execute_sql( - self, request: service.ExecuteSqlRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ExecuteSqlRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ExecuteSqlRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ExecuteSqlRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for execute_sql Override in a subclass to manipulate the request or metadata @@ -591,8 +619,10 @@ def post_execute_sql( def pre_failover_instance( self, request: service.FailoverInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.FailoverInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.FailoverInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for failover_instance Override in a subclass to manipulate the request or metadata @@ -614,8 +644,11 @@ def post_failover_instance( def pre_generate_client_certificate( self, request: service.GenerateClientCertificateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.GenerateClientCertificateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.GenerateClientCertificateRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for generate_client_certificate Override in a subclass to manipulate the request or metadata @@ -635,8 +668,10 @@ def post_generate_client_certificate( return response def pre_get_backup( - self, request: service.GetBackupRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetBackupRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetBackupRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetBackupRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_backup Override in a subclass to manipulate the request or metadata @@ -654,8 +689,10 @@ def post_get_backup(self, response: resources.Backup) -> resources.Backup: return response def pre_get_cluster( - self, request: service.GetClusterRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetClusterRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetClusterRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetClusterRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_cluster Override in a subclass to manipulate the request or metadata @@ -675,8 +712,10 @@ def post_get_cluster(self, response: resources.Cluster) -> resources.Cluster: def pre_get_connection_info( self, request: service.GetConnectionInfoRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.GetConnectionInfoRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.GetConnectionInfoRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_connection_info Override in a subclass to manipulate the request or metadata @@ -696,8 +735,10 @@ def post_get_connection_info( return response def pre_get_instance( - self, request: service.GetInstanceRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetInstanceRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetInstanceRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_instance Override in a subclass to manipulate the request or metadata @@ -715,8 +756,10 @@ def post_get_instance(self, response: resources.Instance) -> resources.Instance: return response def pre_get_user( - self, request: service.GetUserRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetUserRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetUserRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetUserRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_user Override in a subclass to manipulate the request or metadata @@ -734,8 +777,10 @@ def post_get_user(self, response: resources.User) -> resources.User: return response def pre_inject_fault( - self, request: service.InjectFaultRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.InjectFaultRequest, Sequence[Tuple[str, str]]]: + self, + request: service.InjectFaultRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.InjectFaultRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for inject_fault Override in a subclass to manipulate the request or metadata @@ -755,8 +800,10 @@ def post_inject_fault( return response def pre_list_backups( - self, request: service.ListBackupsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ListBackupsRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ListBackupsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListBackupsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_backups Override in a subclass to manipulate the request or metadata @@ -776,8 +823,10 @@ def post_list_backups( return response def pre_list_clusters( - self, request: service.ListClustersRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ListClustersRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ListClustersRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListClustersRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_clusters Override in a subclass to manipulate the request or metadata @@ -797,8 +846,10 @@ def post_list_clusters( return response def pre_list_databases( - self, request: service.ListDatabasesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ListDatabasesRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ListDatabasesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListDatabasesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_databases Override in a subclass to manipulate the request or metadata @@ -818,8 +869,10 @@ def post_list_databases( return response def pre_list_instances( - self, request: service.ListInstancesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ListInstancesRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ListInstancesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListInstancesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_instances Override in a subclass to manipulate the request or metadata @@ -841,8 +894,11 @@ def post_list_instances( def pre_list_supported_database_flags( self, request: service.ListSupportedDatabaseFlagsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.ListSupportedDatabaseFlagsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.ListSupportedDatabaseFlagsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_supported_database_flags Override in a subclass to manipulate the request or metadata @@ -862,8 +918,10 @@ def post_list_supported_database_flags( return response def pre_list_users( - self, request: service.ListUsersRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ListUsersRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ListUsersRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListUsersRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_users Override in a subclass to manipulate the request or metadata @@ -885,8 +943,8 @@ def post_list_users( def pre_promote_cluster( self, request: service.PromoteClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.PromoteClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.PromoteClusterRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for promote_cluster Override in a subclass to manipulate the request or metadata @@ -908,8 +966,8 @@ def post_promote_cluster( def pre_restart_instance( self, request: service.RestartInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.RestartInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.RestartInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for restart_instance Override in a subclass to manipulate the request or metadata @@ -931,8 +989,8 @@ def post_restart_instance( def pre_restore_cluster( self, request: service.RestoreClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.RestoreClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.RestoreClusterRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for restore_cluster Override in a subclass to manipulate the request or metadata @@ -954,8 +1012,10 @@ def post_restore_cluster( def pre_switchover_cluster( self, request: service.SwitchoverClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.SwitchoverClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.SwitchoverClusterRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for switchover_cluster Override in a subclass to manipulate the request or metadata @@ -975,8 +1035,10 @@ def post_switchover_cluster( return response def pre_update_backup( - self, request: service.UpdateBackupRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.UpdateBackupRequest, Sequence[Tuple[str, str]]]: + self, + request: service.UpdateBackupRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.UpdateBackupRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_backup Override in a subclass to manipulate the request or metadata @@ -996,8 +1058,10 @@ def post_update_backup( return response def pre_update_cluster( - self, request: service.UpdateClusterRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.UpdateClusterRequest, Sequence[Tuple[str, str]]]: + self, + request: service.UpdateClusterRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.UpdateClusterRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_cluster Override in a subclass to manipulate the request or metadata @@ -1019,8 +1083,8 @@ def post_update_cluster( def pre_update_instance( self, request: service.UpdateInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.UpdateInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.UpdateInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_instance Override in a subclass to manipulate the request or metadata @@ -1040,8 +1104,10 @@ def post_update_instance( return response def pre_update_user( - self, request: service.UpdateUserRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.UpdateUserRequest, Sequence[Tuple[str, str]]]: + self, + request: service.UpdateUserRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.UpdateUserRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_user Override in a subclass to manipulate the request or metadata @@ -1061,8 +1127,10 @@ def post_update_user(self, response: resources.User) -> resources.User: 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 @@ -1084,8 +1152,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 @@ -1107,8 +1177,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 @@ -1128,8 +1200,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 @@ -1149,8 +1223,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 @@ -1172,8 +1248,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 @@ -1368,7 +1446,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the batch create instances method over HTTP. @@ -1379,8 +1457,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1393,6 +1473,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseBatchCreateInstances._get_http_options() ) + request, metadata = self._interceptor.pre_batch_create_instances( request, metadata ) @@ -1409,6 +1490,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.BatchCreateInstances", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "BatchCreateInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._BatchCreateInstances._get_response( self._host, @@ -1428,7 +1536,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_create_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.alloydb_v1.AlloyDBAdminClient.batch_create_instances", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "BatchCreateInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateBackup( @@ -1466,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create backup method over HTTP. @@ -1476,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: ~.operations_pb2.Operation: @@ -1490,6 +1622,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseCreateBackup._get_http_options() ) + request, metadata = self._interceptor.pre_create_backup(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseCreateBackup._get_transcoded_request( http_options, request @@ -1508,6 +1641,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.CreateBackup", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "CreateBackup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._CreateBackup._get_response( self._host, @@ -1527,7 +1687,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_backup(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1.AlloyDBAdminClient.create_backup", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "CreateBackup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateCluster( @@ -1565,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create cluster method over HTTP. @@ -1575,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: ~.operations_pb2.Operation: @@ -1589,6 +1773,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseCreateCluster._get_http_options() ) + request, metadata = self._interceptor.pre_create_cluster(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseCreateCluster._get_transcoded_request( http_options, request @@ -1603,6 +1788,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.CreateCluster", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "CreateCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._CreateCluster._get_response( self._host, @@ -1622,7 +1834,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.alloydb_v1.AlloyDBAdminClient.create_cluster", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "CreateCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateInstance( @@ -1660,7 +1894,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create instance method over HTTP. @@ -1670,8 +1904,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1684,6 +1920,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseCreateInstance._get_http_options() ) + request, metadata = self._interceptor.pre_create_instance(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseCreateInstance._get_transcoded_request( http_options, request @@ -1698,6 +1935,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.CreateInstance", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "CreateInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._CreateInstance._get_response( self._host, @@ -1717,7 +1981,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_instance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1.AlloyDBAdminClient.create_instance", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "CreateInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSecondaryCluster( @@ -1755,7 +2041,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 secondary cluster method over HTTP. @@ -1765,8 +2051,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1779,6 +2067,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseCreateSecondaryCluster._get_http_options() ) + request, metadata = self._interceptor.pre_create_secondary_cluster( request, metadata ) @@ -1795,6 +2084,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.CreateSecondaryCluster", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "CreateSecondaryCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._CreateSecondaryCluster._get_response( self._host, @@ -1814,7 +2130,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_secondary_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.alloydb_v1.AlloyDBAdminClient.create_secondary_cluster", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "CreateSecondaryCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSecondaryInstance( @@ -1853,7 +2191,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 secondary instance method over HTTP. @@ -1864,8 +2202,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1878,6 +2218,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseCreateSecondaryInstance._get_http_options() ) + request, metadata = self._interceptor.pre_create_secondary_instance( request, metadata ) @@ -1894,6 +2235,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.CreateSecondaryInstance", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "CreateSecondaryInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._CreateSecondaryInstance._get_response( self._host, @@ -1913,7 +2281,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_secondary_instance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1.AlloyDBAdminClient.create_secondary_instance", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "CreateSecondaryInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateUser( @@ -1951,7 +2341,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.User: r"""Call the create user method over HTTP. @@ -1961,8 +2351,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.User: @@ -1972,6 +2364,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseCreateUser._get_http_options() ) + request, metadata = self._interceptor.pre_create_user(request, metadata) transcoded_request = ( _BaseAlloyDBAdminRestTransport._BaseCreateUser._get_transcoded_request( @@ -1992,6 +2385,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.CreateUser", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "CreateUser", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._CreateUser._get_response( self._host, @@ -2013,7 +2433,29 @@ def __call__( pb_resp = resources.User.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_user(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.User.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1.AlloyDBAdminClient.create_user", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "CreateUser", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteBackup( @@ -2050,7 +2492,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 backup method over HTTP. @@ -2060,8 +2502,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2074,6 +2518,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseDeleteBackup._get_http_options() ) + request, metadata = self._interceptor.pre_delete_backup(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseDeleteBackup._get_transcoded_request( http_options, request @@ -2086,6 +2531,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.DeleteBackup", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "DeleteBackup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._DeleteBackup._get_response( self._host, @@ -2104,7 +2576,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_backup(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1.AlloyDBAdminClient.delete_backup", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "DeleteBackup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteCluster( @@ -2141,7 +2635,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete cluster method over HTTP. @@ -2151,8 +2645,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2165,6 +2661,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseDeleteCluster._get_http_options() ) + request, metadata = self._interceptor.pre_delete_cluster(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseDeleteCluster._get_transcoded_request( http_options, request @@ -2175,6 +2672,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.DeleteCluster", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "DeleteCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._DeleteCluster._get_response( self._host, @@ -2193,7 +2717,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.alloydb_v1.AlloyDBAdminClient.delete_cluster", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "DeleteCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteInstance( @@ -2230,7 +2776,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete instance method over HTTP. @@ -2240,8 +2786,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2254,6 +2802,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseDeleteInstance._get_http_options() ) + request, metadata = self._interceptor.pre_delete_instance(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseDeleteInstance._get_transcoded_request( http_options, request @@ -2264,6 +2813,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.DeleteInstance", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "DeleteInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._DeleteInstance._get_response( self._host, @@ -2282,7 +2858,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_instance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1.AlloyDBAdminClient.delete_instance", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "DeleteInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteUser( @@ -2319,7 +2917,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete user method over HTTP. @@ -2329,13 +2927,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 = ( _BaseAlloyDBAdminRestTransport._BaseDeleteUser._get_http_options() ) + request, metadata = self._interceptor.pre_delete_user(request, metadata) transcoded_request = ( _BaseAlloyDBAdminRestTransport._BaseDeleteUser._get_transcoded_request( @@ -2350,6 +2951,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.DeleteUser", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "DeleteUser", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._DeleteUser._get_response( self._host, @@ -2400,7 +3028,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.ExecuteSqlResponse: r"""Call the execute sql method over HTTP. @@ -2410,8 +3038,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ExecuteSqlResponse: @@ -2421,6 +3051,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseExecuteSql._get_http_options() ) + request, metadata = self._interceptor.pre_execute_sql(request, metadata) transcoded_request = ( _BaseAlloyDBAdminRestTransport._BaseExecuteSql._get_transcoded_request( @@ -2441,6 +3072,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.ExecuteSql", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "ExecuteSql", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._ExecuteSql._get_response( self._host, @@ -2462,7 +3120,29 @@ def __call__( pb_resp = service.ExecuteSqlResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_execute_sql(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ExecuteSqlResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1.AlloyDBAdminClient.execute_sql", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "ExecuteSql", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _FailoverInstance( @@ -2500,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]]] = (), ) -> operations_pb2.Operation: r"""Call the failover instance method over HTTP. @@ -2511,8 +3191,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2525,6 +3207,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseFailoverInstance._get_http_options() ) + request, metadata = self._interceptor.pre_failover_instance( request, metadata ) @@ -2541,6 +3224,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.FailoverInstance", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "FailoverInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._FailoverInstance._get_response( self._host, @@ -2560,7 +3270,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_failover_instance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1.AlloyDBAdminClient.failover_instance", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "FailoverInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GenerateClientCertificate( @@ -2599,7 +3331,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.GenerateClientCertificateResponse: r"""Call the generate client certificate method over HTTP. @@ -2612,8 +3344,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.GenerateClientCertificateResponse: @@ -2625,6 +3359,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseGenerateClientCertificate._get_http_options() ) + request, metadata = self._interceptor.pre_generate_client_certificate( request, metadata ) @@ -2641,6 +3376,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.GenerateClientCertificate", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "GenerateClientCertificate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AlloyDBAdminRestTransport._GenerateClientCertificate._get_response( @@ -2664,7 +3426,31 @@ def __call__( pb_resp = service.GenerateClientCertificateResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_generate_client_certificate(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + service.GenerateClientCertificateResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1.AlloyDBAdminClient.generate_client_certificate", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "GenerateClientCertificate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetBackup( @@ -2701,7 +3487,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Backup: r"""Call the get backup method over HTTP. @@ -2711,8 +3497,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.resources.Backup: @@ -2722,6 +3510,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseGetBackup._get_http_options() ) + request, metadata = self._interceptor.pre_get_backup(request, metadata) transcoded_request = ( _BaseAlloyDBAdminRestTransport._BaseGetBackup._get_transcoded_request( @@ -2736,6 +3525,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.GetBackup", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "GetBackup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._GetBackup._get_response( self._host, @@ -2756,7 +3572,29 @@ def __call__( pb_resp = resources.Backup.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_backup(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Backup.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1.AlloyDBAdminClient.get_backup", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "GetBackup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCluster( @@ -2793,7 +3631,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Cluster: r"""Call the get cluster method over HTTP. @@ -2803,8 +3641,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.resources.Cluster: @@ -2820,6 +3660,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseGetCluster._get_http_options() ) + request, metadata = self._interceptor.pre_get_cluster(request, metadata) transcoded_request = ( _BaseAlloyDBAdminRestTransport._BaseGetCluster._get_transcoded_request( @@ -2834,6 +3675,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.GetCluster", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "GetCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._GetCluster._get_response( self._host, @@ -2854,7 +3722,29 @@ def __call__( pb_resp = resources.Cluster.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_cluster(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Cluster.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1.AlloyDBAdminClient.get_cluster", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "GetCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetConnectionInfo( @@ -2891,7 +3781,7 @@ 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.ConnectionInfo: r"""Call the get connection info method over HTTP. @@ -2902,8 +3792,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ConnectionInfo: @@ -2915,6 +3807,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseGetConnectionInfo._get_http_options() ) + request, metadata = self._interceptor.pre_get_connection_info( request, metadata ) @@ -2927,6 +3820,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.GetConnectionInfo", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "GetConnectionInfo", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._GetConnectionInfo._get_response( self._host, @@ -2947,7 +3867,29 @@ def __call__( pb_resp = resources.ConnectionInfo.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_connection_info(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.ConnectionInfo.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1.AlloyDBAdminClient.get_connection_info", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "GetConnectionInfo", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetInstance( @@ -2984,7 +3926,7 @@ 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.Instance: r"""Call the get instance method over HTTP. @@ -2994,8 +3936,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.Instance: @@ -3009,6 +3953,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseGetInstance._get_http_options() ) + request, metadata = self._interceptor.pre_get_instance(request, metadata) transcoded_request = ( _BaseAlloyDBAdminRestTransport._BaseGetInstance._get_transcoded_request( @@ -3023,6 +3968,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.GetInstance", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "GetInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._GetInstance._get_response( self._host, @@ -3043,7 +4015,29 @@ def __call__( pb_resp = resources.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 = resources.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.alloydb_v1.AlloyDBAdminClient.get_instance", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "GetInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetUser(_BaseAlloyDBAdminRestTransport._BaseGetUser, AlloyDBAdminRestStub): @@ -3078,7 +4072,7 @@ 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.User: r"""Call the get user method over HTTP. @@ -3088,8 +4082,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.User: @@ -3099,6 +4095,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseGetUser._get_http_options() ) + request, metadata = self._interceptor.pre_get_user(request, metadata) transcoded_request = ( _BaseAlloyDBAdminRestTransport._BaseGetUser._get_transcoded_request( @@ -3113,6 +4110,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.GetUser", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "GetUser", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._GetUser._get_response( self._host, @@ -3133,7 +4157,29 @@ def __call__( pb_resp = resources.User.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_user(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.User.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1.AlloyDBAdminClient.get_user", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "GetUser", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _InjectFault( @@ -3171,7 +4217,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the inject fault method over HTTP. @@ -3182,8 +4228,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3196,6 +4244,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseInjectFault._get_http_options() ) + request, metadata = self._interceptor.pre_inject_fault(request, metadata) transcoded_request = ( _BaseAlloyDBAdminRestTransport._BaseInjectFault._get_transcoded_request( @@ -3216,6 +4265,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.InjectFault", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "InjectFault", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._InjectFault._get_response( self._host, @@ -3235,7 +4311,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_inject_fault(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1.AlloyDBAdminClient.inject_fault", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "InjectFault", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListBackups( @@ -3272,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]]] = (), ) -> service.ListBackupsResponse: r"""Call the list backups method over HTTP. @@ -3283,8 +4381,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ListBackupsResponse: @@ -3296,6 +4396,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseListBackups._get_http_options() ) + request, metadata = self._interceptor.pre_list_backups(request, metadata) transcoded_request = ( _BaseAlloyDBAdminRestTransport._BaseListBackups._get_transcoded_request( @@ -3310,6 +4411,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.ListBackups", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "ListBackups", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._ListBackups._get_response( self._host, @@ -3330,7 +4458,29 @@ def __call__( pb_resp = service.ListBackupsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_backups(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListBackupsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1.AlloyDBAdminClient.list_backups", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "ListBackups", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListClusters( @@ -3367,7 +4517,7 @@ 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.ListClustersResponse: r"""Call the list clusters method over HTTP. @@ -3378,8 +4528,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ListClustersResponse: @@ -3391,6 +4543,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseListClusters._get_http_options() ) + request, metadata = self._interceptor.pre_list_clusters(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseListClusters._get_transcoded_request( http_options, request @@ -3403,6 +4556,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.ListClusters", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "ListClusters", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._ListClusters._get_response( self._host, @@ -3423,7 +4603,29 @@ def __call__( pb_resp = 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 = 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.alloydb_v1.AlloyDBAdminClient.list_clusters", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "ListClusters", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDatabases( @@ -3460,7 +4662,7 @@ 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.ListDatabasesResponse: r"""Call the list databases method over HTTP. @@ -3471,8 +4673,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ListDatabasesResponse: @@ -3484,6 +4688,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseListDatabases._get_http_options() ) + request, metadata = self._interceptor.pre_list_databases(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseListDatabases._get_transcoded_request( http_options, request @@ -3494,6 +4699,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.ListDatabases", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "ListDatabases", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._ListDatabases._get_response( self._host, @@ -3514,7 +4746,29 @@ def __call__( pb_resp = service.ListDatabasesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_databases(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListDatabasesResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1.AlloyDBAdminClient.list_databases", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "ListDatabases", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListInstances( @@ -3551,7 +4805,7 @@ 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.ListInstancesResponse: r"""Call the list instances method over HTTP. @@ -3562,8 +4816,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ListInstancesResponse: @@ -3575,6 +4831,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseListInstances._get_http_options() ) + request, metadata = self._interceptor.pre_list_instances(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseListInstances._get_transcoded_request( http_options, request @@ -3585,6 +4842,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.ListInstances", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "ListInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._ListInstances._get_response( self._host, @@ -3605,7 +4889,29 @@ def __call__( pb_resp = service.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 = service.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.alloydb_v1.AlloyDBAdminClient.list_instances", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "ListInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSupportedDatabaseFlags( @@ -3643,7 +4949,7 @@ 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.ListSupportedDatabaseFlagsResponse: r"""Call the list supported database flags method over HTTP. @@ -3655,8 +4961,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ListSupportedDatabaseFlagsResponse: @@ -3668,6 +4976,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseListSupportedDatabaseFlags._get_http_options() ) + request, metadata = self._interceptor.pre_list_supported_database_flags( request, metadata ) @@ -3680,6 +4989,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.ListSupportedDatabaseFlags", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "ListSupportedDatabaseFlags", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AlloyDBAdminRestTransport._ListSupportedDatabaseFlags._get_response( @@ -3702,7 +5038,31 @@ def __call__( pb_resp = service.ListSupportedDatabaseFlagsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_supported_database_flags(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + service.ListSupportedDatabaseFlagsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1.AlloyDBAdminClient.list_supported_database_flags", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "ListSupportedDatabaseFlags", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListUsers( @@ -3739,7 +5099,7 @@ 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.ListUsersResponse: r"""Call the list users method over HTTP. @@ -3749,8 +5109,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ListUsersResponse: @@ -3760,6 +5122,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseListUsers._get_http_options() ) + request, metadata = self._interceptor.pre_list_users(request, metadata) transcoded_request = ( _BaseAlloyDBAdminRestTransport._BaseListUsers._get_transcoded_request( @@ -3774,6 +5137,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.ListUsers", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "ListUsers", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._ListUsers._get_response( self._host, @@ -3794,7 +5184,29 @@ def __call__( pb_resp = service.ListUsersResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_users(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListUsersResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1.AlloyDBAdminClient.list_users", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "ListUsers", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PromoteCluster( @@ -3832,7 +5244,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the promote cluster method over HTTP. @@ -3842,8 +5254,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3856,6 +5270,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BasePromoteCluster._get_http_options() ) + request, metadata = self._interceptor.pre_promote_cluster(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BasePromoteCluster._get_transcoded_request( http_options, request @@ -3870,6 +5285,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.PromoteCluster", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "PromoteCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._PromoteCluster._get_response( self._host, @@ -3889,7 +5331,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_promote_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.alloydb_v1.AlloyDBAdminClient.promote_cluster", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "PromoteCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RestartInstance( @@ -3927,7 +5391,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the restart instance method over HTTP. @@ -3937,8 +5401,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3951,6 +5417,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseRestartInstance._get_http_options() ) + request, metadata = self._interceptor.pre_restart_instance( request, metadata ) @@ -3967,6 +5434,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.RestartInstance", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "RestartInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._RestartInstance._get_response( self._host, @@ -3986,7 +5480,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_restart_instance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1.AlloyDBAdminClient.restart_instance", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "RestartInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RestoreCluster( @@ -4024,7 +5540,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the restore cluster method over HTTP. @@ -4036,8 +5552,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -4050,6 +5568,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseRestoreCluster._get_http_options() ) + request, metadata = self._interceptor.pre_restore_cluster(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseRestoreCluster._get_transcoded_request( http_options, request @@ -4064,6 +5583,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.RestoreCluster", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "RestoreCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._RestoreCluster._get_response( self._host, @@ -4083,7 +5629,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_restore_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.alloydb_v1.AlloyDBAdminClient.restore_cluster", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "RestoreCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SwitchoverCluster( @@ -4121,7 +5689,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the switchover cluster method over HTTP. @@ -4132,8 +5700,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -4146,6 +5716,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseSwitchoverCluster._get_http_options() ) + request, metadata = self._interceptor.pre_switchover_cluster( request, metadata ) @@ -4162,6 +5733,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.SwitchoverCluster", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "SwitchoverCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._SwitchoverCluster._get_response( self._host, @@ -4181,7 +5779,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_switchover_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.alloydb_v1.AlloyDBAdminClient.switchover_cluster", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "SwitchoverCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateBackup( @@ -4219,7 +5839,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 backup method over HTTP. @@ -4229,8 +5849,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -4243,6 +5865,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseUpdateBackup._get_http_options() ) + request, metadata = self._interceptor.pre_update_backup(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseUpdateBackup._get_transcoded_request( http_options, request @@ -4261,6 +5884,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.UpdateBackup", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "UpdateBackup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._UpdateBackup._get_response( self._host, @@ -4280,7 +5930,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_backup(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1.AlloyDBAdminClient.update_backup", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "UpdateBackup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCluster( @@ -4318,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]]] = (), ) -> operations_pb2.Operation: r"""Call the update cluster method over HTTP. @@ -4328,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: ~.operations_pb2.Operation: @@ -4342,6 +6016,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseUpdateCluster._get_http_options() ) + request, metadata = self._interceptor.pre_update_cluster(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseUpdateCluster._get_transcoded_request( http_options, request @@ -4356,6 +6031,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.UpdateCluster", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "UpdateCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._UpdateCluster._get_response( self._host, @@ -4375,7 +6077,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.alloydb_v1.AlloyDBAdminClient.update_cluster", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "UpdateCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateInstance( @@ -4413,7 +6137,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update instance method over HTTP. @@ -4423,8 +6147,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -4437,6 +6163,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseUpdateInstance._get_http_options() ) + request, metadata = self._interceptor.pre_update_instance(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseUpdateInstance._get_transcoded_request( http_options, request @@ -4451,6 +6178,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.UpdateInstance", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "UpdateInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._UpdateInstance._get_response( self._host, @@ -4470,7 +6224,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_instance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1.AlloyDBAdminClient.update_instance", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "UpdateInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateUser( @@ -4508,7 +6284,7 @@ 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.User: r"""Call the update user method over HTTP. @@ -4518,8 +6294,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.User: @@ -4529,6 +6307,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseUpdateUser._get_http_options() ) + request, metadata = self._interceptor.pre_update_user(request, metadata) transcoded_request = ( _BaseAlloyDBAdminRestTransport._BaseUpdateUser._get_transcoded_request( @@ -4549,6 +6328,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.UpdateUser", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "UpdateUser", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._UpdateUser._get_response( self._host, @@ -4570,7 +6376,29 @@ def __call__( pb_resp = resources.User.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_user(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.User.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1.AlloyDBAdminClient.update_user", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "UpdateUser", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -4877,7 +6705,7 @@ 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. @@ -4887,8 +6715,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -4897,6 +6727,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseAlloyDBAdminRestTransport._BaseGetLocation._get_transcoded_request( @@ -4911,6 +6742,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.GetLocation", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._GetLocation._get_response( self._host, @@ -4930,6 +6788,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.alloydb_v1.AlloyDBAdminAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4970,7 +6849,7 @@ 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. @@ -4980,8 +6859,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -4990,6 +6871,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -5000,6 +6882,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.ListLocations", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._ListLocations._get_response( self._host, @@ -5019,6 +6928,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.alloydb_v1.AlloyDBAdminAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -5060,7 +6990,7 @@ 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. @@ -5070,13 +7000,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 = ( _BaseAlloyDBAdminRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -5093,6 +7026,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.CancelOperation", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._CancelOperation._get_response( self._host, @@ -5149,7 +7109,7 @@ 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. @@ -5159,13 +7119,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 = ( _BaseAlloyDBAdminRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -5178,6 +7141,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._DeleteOperation._get_response( self._host, @@ -5233,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]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -5243,8 +7233,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -5253,6 +7245,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -5265,6 +7258,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.GetOperation", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._GetOperation._get_response( self._host, @@ -5284,6 +7304,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.alloydb_v1.AlloyDBAdminAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -5324,7 +7365,7 @@ def __call__( *, 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. @@ -5334,8 +7375,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must 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. @@ -5344,6 +7387,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -5354,6 +7398,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1.AlloyDBAdminClient.ListOperations", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._ListOperations._get_response( self._host, @@ -5373,6 +7444,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.alloydb_v1.AlloyDBAdminAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.alloydb.v1.AlloyDBAdmin", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/gapic_version.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/gapic_version.py index 386ddb96d97f..558c8aab67c5 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/gapic_version.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.4.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/async_client.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/async_client.py index a76ea9d81e7f..7aa1cb6a3899 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/async_client.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/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, AlloyDBAdminTransport from .transports.grpc_asyncio import AlloyDBAdminGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class AlloyDBAdminAsyncClient: """Service describing handlers for resources""" @@ -290,6 +300,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.alloydb_v1alpha.AlloyDBAdminAsyncClient`.", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "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.alloydb.v1alpha.AlloyDBAdmin", + "credentialsType": None, + }, + ) + async def list_clusters( self, request: Optional[Union[service.ListClustersRequest, dict]] = None, @@ -297,7 +329,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. @@ -347,8 +379,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.alloydb_v1alpha.services.alloy_db_admin.pagers.ListClustersAsyncPager: @@ -423,7 +457,7 @@ async def get_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Cluster: r"""Gets details of a single Cluster. @@ -467,8 +501,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.alloydb_v1alpha.types.Cluster: @@ -535,7 +571,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. @@ -602,8 +638,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: @@ -681,7 +719,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. @@ -741,8 +779,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: @@ -820,7 +860,7 @@ async def upgrade_cluster( version: Optional[resources.DatabaseVersion] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 a single Cluster. Imperative only. @@ -876,8 +916,10 @@ async def sample_upgrade_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: @@ -952,7 +994,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. @@ -1000,8 +1042,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: @@ -1080,7 +1124,7 @@ async def promote_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"""Promotes a SECONDARY cluster. This turns down replication from the PRIMARY cluster and promotes a @@ -1131,8 +1175,10 @@ async def sample_promote_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: @@ -1205,7 +1251,7 @@ async def switchover_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"""Switches the roles of PRIMARY and SECONDARY clusters without any data loss. This promotes the SECONDARY @@ -1257,8 +1303,10 @@ async def sample_switchover_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: @@ -1330,7 +1378,7 @@ async def restore_cluster( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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, with a volume restored from the provided @@ -1385,8 +1433,10 @@ async def sample_restore_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: @@ -1447,7 +1497,7 @@ async def create_secondary_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 cluster of type SECONDARY in the given location using the primary cluster as the source. @@ -1517,8 +1567,10 @@ async def sample_create_secondary_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: @@ -1595,7 +1647,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. @@ -1646,8 +1698,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.alloydb_v1alpha.services.alloy_db_admin.pagers.ListInstancesAsyncPager: @@ -1722,7 +1776,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]]] = (), ) -> resources.Instance: r"""Gets details of a single Instance. @@ -1766,8 +1820,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.alloydb_v1alpha.types.Instance: @@ -1832,7 +1888,7 @@ async def create_instance( instance_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new Instance in a given project and location. @@ -1898,8 +1954,10 @@ async def sample_create_instance(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -1976,7 +2034,7 @@ async def create_secondary_instance( instance_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new SECONDARY Instance in a given project and location. @@ -2043,8 +2101,10 @@ async def sample_create_secondary_instance(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -2118,7 +2178,7 @@ async def batch_create_instances( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 new instances under the given project, location and cluster. There can be only one primary @@ -2177,8 +2237,10 @@ async def sample_batch_create_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: @@ -2237,7 +2299,7 @@ async def update_instance( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single Instance. @@ -2296,8 +2358,10 @@ async def sample_update_instance(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -2372,7 +2436,7 @@ async def delete_instance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single Instance. @@ -2420,8 +2484,10 @@ async def sample_delete_instance(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -2500,7 +2566,7 @@ async def failover_instance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Forces a Failover for a highly available instance. Failover promotes the HA standby instance as the new @@ -2551,8 +2617,10 @@ async def sample_failover_instance(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -2624,7 +2692,7 @@ async def inject_fault( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Injects fault in an instance. Imperative only. @@ -2682,8 +2750,10 @@ async def sample_inject_fault(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -2756,7 +2826,7 @@ async def restart_instance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Restart an Instance in a cluster. Imperative only. @@ -2805,8 +2875,10 @@ async def sample_restart_instance(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -2881,7 +2953,7 @@ async def execute_sql( password: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.ExecuteSqlResponse: r"""Executes a SQL statement in a database inside an AlloyDB instance. @@ -2965,8 +3037,10 @@ async def sample_execute_sql(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1alpha.types.ExecuteSqlResponse: @@ -3033,7 +3107,7 @@ async def list_backups( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListBackupsAsyncPager: r"""Lists Backups in a given project and location. @@ -3078,8 +3152,10 @@ async def sample_list_backups(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1alpha.services.alloy_db_admin.pagers.ListBackupsAsyncPager: @@ -3154,7 +3230,7 @@ async def get_backup( name: Optional[str] = None, retry: OptionalRetry = 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.Backup: r"""Gets details of a single Backup. @@ -3195,8 +3271,10 @@ async def sample_get_backup(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1alpha.types.Backup: @@ -3257,7 +3335,7 @@ async def create_backup( backup_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 Backup in a given project and location. @@ -3319,8 +3397,10 @@ async def sample_create_backup(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -3397,7 +3477,7 @@ async def update_backup( 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 Backup. @@ -3456,8 +3536,10 @@ async def sample_update_backup(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -3533,7 +3615,7 @@ async def delete_backup( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 Backup. @@ -3581,8 +3663,10 @@ async def sample_delete_backup(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -3663,7 +3747,7 @@ async def list_supported_database_flags( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSupportedDatabaseFlagsAsyncPager: r"""Lists SupportedDatabaseFlags for a given project and location. @@ -3716,8 +3800,10 @@ async def sample_list_supported_database_flags(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1alpha.services.alloy_db_admin.pagers.ListSupportedDatabaseFlagsAsyncPager: @@ -3792,7 +3878,7 @@ async def generate_client_certificate( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.GenerateClientCertificateResponse: r"""Generate a client certificate signed by a Cluster CA. The sole purpose of this endpoint is to support AlloyDB @@ -3845,8 +3931,10 @@ async def sample_generate_client_certificate(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1alpha.types.GenerateClientCertificateResponse: @@ -3907,7 +3995,7 @@ async def get_connection_info( parent: Optional[str] = None, retry: OptionalRetry = 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.ConnectionInfo: r"""Get instance metadata used for a connection. @@ -3952,8 +4040,10 @@ async def sample_get_connection_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.alloydb_v1alpha.types.ConnectionInfo: @@ -4014,7 +4104,7 @@ async def list_users( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListUsersAsyncPager: r"""Lists Users in a given project and location. @@ -4058,8 +4148,10 @@ async def sample_list_users(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1alpha.services.alloy_db_admin.pagers.ListUsersAsyncPager: @@ -4134,7 +4226,7 @@ async def get_user( name: Optional[str] = None, retry: OptionalRetry = 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.User: r"""Gets details of a single User. @@ -4178,8 +4270,10 @@ async def sample_get_user(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1alpha.types.User: @@ -4238,7 +4332,7 @@ async def create_user( user_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.User: r"""Creates a new User in a given project, location, and cluster. @@ -4293,8 +4387,10 @@ async def sample_create_user(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1alpha.types.User: @@ -4358,7 +4454,7 @@ async def update_user( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.User: r"""Updates the parameters of a single User. @@ -4409,8 +4505,10 @@ async def sample_update_user(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1alpha.types.User: @@ -4473,7 +4571,7 @@ async def delete_user( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 User. @@ -4514,8 +4612,10 @@ async def sample_delete_user(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -4567,7 +4667,7 @@ async def list_databases( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDatabasesAsyncPager: r"""Lists Databases in a given project and location. @@ -4612,8 +4712,10 @@ async def sample_list_databases(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1alpha.services.alloy_db_admin.pagers.ListDatabasesAsyncPager: @@ -4687,7 +4789,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. @@ -4698,8 +4800,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. @@ -4740,7 +4844,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. @@ -4751,8 +4855,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. @@ -4793,7 +4899,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. @@ -4809,8 +4915,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 """ @@ -4847,7 +4955,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. @@ -4862,8 +4970,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 """ @@ -4900,7 +5010,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. @@ -4911,8 +5021,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. @@ -4953,7 +5065,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. @@ -4964,8 +5076,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-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/client.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/client.py index 9881348032e2..8be23dd20736 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/client.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/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 @@ -777,6 +787,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( @@ -839,6 +853,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.alloydb_v1alpha.AlloyDBAdminClient`.", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "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.alloydb.v1alpha.AlloyDBAdmin", + "credentialsType": None, + }, + ) + def list_clusters( self, request: Optional[Union[service.ListClustersRequest, dict]] = None, @@ -846,7 +883,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. @@ -896,8 +933,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.alloydb_v1alpha.services.alloy_db_admin.pagers.ListClustersPager: @@ -969,7 +1008,7 @@ def get_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Cluster: r"""Gets details of a single Cluster. @@ -1013,8 +1052,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.alloydb_v1alpha.types.Cluster: @@ -1078,7 +1119,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. @@ -1145,8 +1186,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: @@ -1221,7 +1264,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. @@ -1281,8 +1324,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: @@ -1357,7 +1402,7 @@ def upgrade_cluster( version: Optional[resources.DatabaseVersion] = None, retry: OptionalRetry = gapic_v1.method.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 a single Cluster. Imperative only. @@ -1413,8 +1458,10 @@ def sample_upgrade_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: @@ -1486,7 +1533,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. @@ -1534,8 +1581,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: @@ -1611,7 +1660,7 @@ def promote_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"""Promotes a SECONDARY cluster. This turns down replication from the PRIMARY cluster and promotes a @@ -1662,8 +1711,10 @@ def sample_promote_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: @@ -1733,7 +1784,7 @@ def switchover_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"""Switches the roles of PRIMARY and SECONDARY clusters without any data loss. This promotes the SECONDARY @@ -1785,8 +1836,10 @@ def sample_switchover_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: @@ -1855,7 +1908,7 @@ def restore_cluster( *, retry: OptionalRetry = gapic_v1.method.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, with a volume restored from the provided @@ -1910,8 +1963,10 @@ def sample_restore_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: @@ -1970,7 +2025,7 @@ def create_secondary_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 cluster of type SECONDARY in the given location using the primary cluster as the source. @@ -2040,8 +2095,10 @@ def sample_create_secondary_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: @@ -2115,7 +2172,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. @@ -2166,8 +2223,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.alloydb_v1alpha.services.alloy_db_admin.pagers.ListInstancesPager: @@ -2239,7 +2298,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]]] = (), ) -> resources.Instance: r"""Gets details of a single Instance. @@ -2283,8 +2342,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.alloydb_v1alpha.types.Instance: @@ -2346,7 +2407,7 @@ def create_instance( instance_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new Instance in a given project and location. @@ -2412,8 +2473,10 @@ def sample_create_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -2487,7 +2550,7 @@ def create_secondary_instance( instance_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new SECONDARY Instance in a given project and location. @@ -2554,8 +2617,10 @@ def sample_create_secondary_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -2628,7 +2693,7 @@ def batch_create_instances( *, retry: OptionalRetry = gapic_v1.method.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 new instances under the given project, location and cluster. There can be only one primary @@ -2687,8 +2752,10 @@ def sample_batch_create_instances(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -2745,7 +2812,7 @@ def update_instance( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the parameters of a single Instance. @@ -2804,8 +2871,10 @@ def sample_update_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -2877,7 +2946,7 @@ def delete_instance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single Instance. @@ -2925,8 +2994,10 @@ def sample_delete_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -3002,7 +3073,7 @@ def failover_instance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Forces a Failover for a highly available instance. Failover promotes the HA standby instance as the new @@ -3053,8 +3124,10 @@ def sample_failover_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -3123,7 +3196,7 @@ def inject_fault( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Injects fault in an instance. Imperative only. @@ -3181,8 +3254,10 @@ def sample_inject_fault(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -3252,7 +3327,7 @@ def restart_instance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Restart an Instance in a cluster. Imperative only. @@ -3301,8 +3376,10 @@ def sample_restart_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -3374,7 +3451,7 @@ def execute_sql( password: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.ExecuteSqlResponse: r"""Executes a SQL statement in a database inside an AlloyDB instance. @@ -3458,8 +3535,10 @@ def sample_execute_sql(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1alpha.types.ExecuteSqlResponse: @@ -3523,7 +3602,7 @@ def list_backups( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListBackupsPager: r"""Lists Backups in a given project and location. @@ -3568,8 +3647,10 @@ def sample_list_backups(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1alpha.services.alloy_db_admin.pagers.ListBackupsPager: @@ -3641,7 +3722,7 @@ def get_backup( name: Optional[str] = None, retry: OptionalRetry = 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.Backup: r"""Gets details of a single Backup. @@ -3682,8 +3763,10 @@ def sample_get_backup(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1alpha.types.Backup: @@ -3741,7 +3824,7 @@ def create_backup( backup_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 Backup in a given project and location. @@ -3803,8 +3886,10 @@ def sample_create_backup(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -3878,7 +3963,7 @@ def update_backup( 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 Backup. @@ -3937,8 +4022,10 @@ def sample_update_backup(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -4011,7 +4098,7 @@ def delete_backup( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 Backup. @@ -4059,8 +4146,10 @@ def sample_delete_backup(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -4138,7 +4227,7 @@ def list_supported_database_flags( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSupportedDatabaseFlagsPager: r"""Lists SupportedDatabaseFlags for a given project and location. @@ -4191,8 +4280,10 @@ def sample_list_supported_database_flags(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1alpha.services.alloy_db_admin.pagers.ListSupportedDatabaseFlagsPager: @@ -4266,7 +4357,7 @@ def generate_client_certificate( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.GenerateClientCertificateResponse: r"""Generate a client certificate signed by a Cluster CA. The sole purpose of this endpoint is to support AlloyDB @@ -4319,8 +4410,10 @@ def sample_generate_client_certificate(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1alpha.types.GenerateClientCertificateResponse: @@ -4380,7 +4473,7 @@ def get_connection_info( parent: Optional[str] = None, retry: OptionalRetry = 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.ConnectionInfo: r"""Get instance metadata used for a connection. @@ -4425,8 +4518,10 @@ def sample_get_connection_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.alloydb_v1alpha.types.ConnectionInfo: @@ -4484,7 +4579,7 @@ def list_users( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListUsersPager: r"""Lists Users in a given project and location. @@ -4528,8 +4623,10 @@ def sample_list_users(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1alpha.services.alloy_db_admin.pagers.ListUsersPager: @@ -4601,7 +4698,7 @@ def get_user( name: Optional[str] = None, retry: OptionalRetry = 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.User: r"""Gets details of a single User. @@ -4645,8 +4742,10 @@ def sample_get_user(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1alpha.types.User: @@ -4704,7 +4803,7 @@ def create_user( user_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.User: r"""Creates a new User in a given project, location, and cluster. @@ -4759,8 +4858,10 @@ def sample_create_user(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1alpha.types.User: @@ -4821,7 +4922,7 @@ def update_user( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.User: r"""Updates the parameters of a single User. @@ -4872,8 +4973,10 @@ def sample_update_user(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1alpha.types.User: @@ -4933,7 +5036,7 @@ def delete_user( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 User. @@ -4974,8 +5077,10 @@ def sample_delete_user(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -5024,7 +5129,7 @@ def list_databases( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDatabasesPager: r"""Lists Databases in a given project and location. @@ -5069,8 +5174,10 @@ def sample_list_databases(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1alpha.services.alloy_db_admin.pagers.ListDatabasesPager: @@ -5154,7 +5261,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. @@ -5165,8 +5272,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. @@ -5207,7 +5316,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. @@ -5218,8 +5327,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. @@ -5260,7 +5371,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. @@ -5276,8 +5387,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 """ @@ -5314,7 +5427,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. @@ -5329,8 +5442,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 """ @@ -5367,7 +5482,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. @@ -5378,8 +5493,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. @@ -5420,7 +5537,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. @@ -5431,8 +5548,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-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/pagers.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/pagers.py index 9a1af6bb103d..1b06400c3195 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/pagers.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/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.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 = 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 = service.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 = service.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 = service.ListBackupsRequest(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.ListBackupsRequest(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.ListSupportedDatabaseFlagsRequest(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.ListSupportedDatabaseFlagsRequest(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.ListUsersRequest(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.ListUsersRequest(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 = service.ListDatabasesRequest(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 = service.ListDatabasesRequest(request) diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/transports/grpc.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/transports/grpc.py index 5a23f92cecfe..be055e5b3443 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/transports/grpc.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/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.alloydb_v1alpha.types import resources, service from .base import DEFAULT_CLIENT_INFO, AlloyDBAdminTransport +try: + from google.api_core import client_logging # 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.alloydb.v1alpha.AlloyDBAdmin", + "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.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AlloyDBAdminGrpcTransport(AlloyDBAdminTransport): """gRPC backend transport for AlloyDBAdmin. @@ -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 @@ -273,7 +361,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.alloydb.v1alpha.AlloyDBAdmin/ListClusters", request_serializer=service.ListClustersRequest.serialize, response_deserializer=service.ListClustersResponse.deserialize, @@ -297,7 +385,7 @@ def get_cluster(self) -> Callable[[service.GetClusterRequest], resources.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.alloydb.v1alpha.AlloyDBAdmin/GetCluster", request_serializer=service.GetClusterRequest.serialize, response_deserializer=resources.Cluster.deserialize, @@ -324,7 +412,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.alloydb.v1alpha.AlloyDBAdmin/CreateCluster", request_serializer=service.CreateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -350,7 +438,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.alloydb.v1alpha.AlloyDBAdmin/UpdateCluster", request_serializer=service.UpdateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -377,7 +465,7 @@ def upgrade_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "upgrade_cluster" not in self._stubs: - self._stubs["upgrade_cluster"] = self.grpc_channel.unary_unary( + self._stubs["upgrade_cluster"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/UpgradeCluster", request_serializer=service.UpgradeClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -403,7 +491,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.alloydb.v1alpha.AlloyDBAdmin/DeleteCluster", request_serializer=service.DeleteClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -432,7 +520,7 @@ def promote_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "promote_cluster" not in self._stubs: - self._stubs["promote_cluster"] = self.grpc_channel.unary_unary( + self._stubs["promote_cluster"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/PromoteCluster", request_serializer=service.PromoteClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -461,7 +549,7 @@ def switchover_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "switchover_cluster" not in self._stubs: - self._stubs["switchover_cluster"] = self.grpc_channel.unary_unary( + self._stubs["switchover_cluster"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/SwitchoverCluster", request_serializer=service.SwitchoverClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -490,7 +578,7 @@ def restore_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "restore_cluster" not in self._stubs: - self._stubs["restore_cluster"] = self.grpc_channel.unary_unary( + self._stubs["restore_cluster"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/RestoreCluster", request_serializer=service.RestoreClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -517,7 +605,7 @@ def create_secondary_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_secondary_cluster" not in self._stubs: - self._stubs["create_secondary_cluster"] = self.grpc_channel.unary_unary( + self._stubs["create_secondary_cluster"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/CreateSecondaryCluster", request_serializer=service.CreateSecondaryClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -543,7 +631,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.alloydb.v1alpha.AlloyDBAdmin/ListInstances", request_serializer=service.ListInstancesRequest.serialize, response_deserializer=service.ListInstancesResponse.deserialize, @@ -569,7 +657,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.alloydb.v1alpha.AlloyDBAdmin/GetInstance", request_serializer=service.GetInstanceRequest.serialize, response_deserializer=resources.Instance.deserialize, @@ -596,7 +684,7 @@ def create_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_instance" not in self._stubs: - self._stubs["create_instance"] = self.grpc_channel.unary_unary( + self._stubs["create_instance"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/CreateInstance", request_serializer=service.CreateInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -623,7 +711,7 @@ def create_secondary_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_secondary_instance" not in self._stubs: - self._stubs["create_secondary_instance"] = self.grpc_channel.unary_unary( + self._stubs["create_secondary_instance"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/CreateSecondaryInstance", request_serializer=service.CreateSecondaryInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -661,7 +749,7 @@ def batch_create_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_create_instances" not in self._stubs: - self._stubs["batch_create_instances"] = self.grpc_channel.unary_unary( + self._stubs["batch_create_instances"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/BatchCreateInstances", request_serializer=service.BatchCreateInstancesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -687,7 +775,7 @@ def update_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_instance" not in self._stubs: - self._stubs["update_instance"] = self.grpc_channel.unary_unary( + self._stubs["update_instance"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/UpdateInstance", request_serializer=service.UpdateInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -713,7 +801,7 @@ def delete_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_instance" not in self._stubs: - self._stubs["delete_instance"] = self.grpc_channel.unary_unary( + self._stubs["delete_instance"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/DeleteInstance", request_serializer=service.DeleteInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -741,7 +829,7 @@ def failover_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "failover_instance" not in self._stubs: - self._stubs["failover_instance"] = self.grpc_channel.unary_unary( + self._stubs["failover_instance"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/FailoverInstance", request_serializer=service.FailoverInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -768,7 +856,7 @@ def inject_fault( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "inject_fault" not in self._stubs: - self._stubs["inject_fault"] = self.grpc_channel.unary_unary( + self._stubs["inject_fault"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/InjectFault", request_serializer=service.InjectFaultRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -795,7 +883,7 @@ def restart_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "restart_instance" not in self._stubs: - self._stubs["restart_instance"] = self.grpc_channel.unary_unary( + self._stubs["restart_instance"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/RestartInstance", request_serializer=service.RestartInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -822,7 +910,7 @@ def execute_sql( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "execute_sql" not in self._stubs: - self._stubs["execute_sql"] = self.grpc_channel.unary_unary( + self._stubs["execute_sql"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/ExecuteSql", request_serializer=service.ExecuteSqlRequest.serialize, response_deserializer=service.ExecuteSqlResponse.deserialize, @@ -848,7 +936,7 @@ def list_backups( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_backups" not in self._stubs: - self._stubs["list_backups"] = self.grpc_channel.unary_unary( + self._stubs["list_backups"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/ListBackups", request_serializer=service.ListBackupsRequest.serialize, response_deserializer=service.ListBackupsResponse.deserialize, @@ -872,7 +960,7 @@ def get_backup(self) -> Callable[[service.GetBackupRequest], resources.Backup]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_backup" not in self._stubs: - self._stubs["get_backup"] = self.grpc_channel.unary_unary( + self._stubs["get_backup"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/GetBackup", request_serializer=service.GetBackupRequest.serialize, response_deserializer=resources.Backup.deserialize, @@ -898,7 +986,7 @@ def create_backup( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_backup" not in self._stubs: - self._stubs["create_backup"] = self.grpc_channel.unary_unary( + self._stubs["create_backup"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/CreateBackup", request_serializer=service.CreateBackupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -924,7 +1012,7 @@ def update_backup( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_backup" not in self._stubs: - self._stubs["update_backup"] = self.grpc_channel.unary_unary( + self._stubs["update_backup"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/UpdateBackup", request_serializer=service.UpdateBackupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -950,7 +1038,7 @@ def delete_backup( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_backup" not in self._stubs: - self._stubs["delete_backup"] = self.grpc_channel.unary_unary( + self._stubs["delete_backup"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/DeleteBackup", request_serializer=service.DeleteBackupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -982,7 +1070,7 @@ def list_supported_database_flags( if "list_supported_database_flags" not in self._stubs: self._stubs[ "list_supported_database_flags" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/ListSupportedDatabaseFlags", request_serializer=service.ListSupportedDatabaseFlagsRequest.serialize, response_deserializer=service.ListSupportedDatabaseFlagsResponse.deserialize, @@ -1017,7 +1105,9 @@ def generate_client_certificate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_client_certificate" not in self._stubs: - self._stubs["generate_client_certificate"] = self.grpc_channel.unary_unary( + self._stubs[ + "generate_client_certificate" + ] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/GenerateClientCertificate", request_serializer=service.GenerateClientCertificateRequest.serialize, response_deserializer=service.GenerateClientCertificateResponse.deserialize, @@ -1043,7 +1133,7 @@ def get_connection_info( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_connection_info" not in self._stubs: - self._stubs["get_connection_info"] = self.grpc_channel.unary_unary( + self._stubs["get_connection_info"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/GetConnectionInfo", request_serializer=service.GetConnectionInfoRequest.serialize, response_deserializer=resources.ConnectionInfo.deserialize, @@ -1069,7 +1159,7 @@ def list_users( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_users" not in self._stubs: - self._stubs["list_users"] = self.grpc_channel.unary_unary( + self._stubs["list_users"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/ListUsers", request_serializer=service.ListUsersRequest.serialize, response_deserializer=service.ListUsersResponse.deserialize, @@ -1093,7 +1183,7 @@ def get_user(self) -> Callable[[service.GetUserRequest], resources.User]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_user" not in self._stubs: - self._stubs["get_user"] = self.grpc_channel.unary_unary( + self._stubs["get_user"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/GetUser", request_serializer=service.GetUserRequest.serialize, response_deserializer=resources.User.deserialize, @@ -1118,7 +1208,7 @@ def create_user(self) -> Callable[[service.CreateUserRequest], resources.User]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_user" not in self._stubs: - self._stubs["create_user"] = self.grpc_channel.unary_unary( + self._stubs["create_user"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/CreateUser", request_serializer=service.CreateUserRequest.serialize, response_deserializer=resources.User.deserialize, @@ -1142,7 +1232,7 @@ def update_user(self) -> Callable[[service.UpdateUserRequest], resources.User]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_user" not in self._stubs: - self._stubs["update_user"] = self.grpc_channel.unary_unary( + self._stubs["update_user"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/UpdateUser", request_serializer=service.UpdateUserRequest.serialize, response_deserializer=resources.User.deserialize, @@ -1166,7 +1256,7 @@ def delete_user(self) -> Callable[[service.DeleteUserRequest], empty_pb2.Empty]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_user" not in self._stubs: - self._stubs["delete_user"] = self.grpc_channel.unary_unary( + self._stubs["delete_user"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/DeleteUser", request_serializer=service.DeleteUserRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1192,7 +1282,7 @@ def list_databases( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_databases" not in self._stubs: - self._stubs["list_databases"] = self.grpc_channel.unary_unary( + self._stubs["list_databases"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/ListDatabases", request_serializer=service.ListDatabasesRequest.serialize, response_deserializer=service.ListDatabasesResponse.deserialize, @@ -1200,7 +1290,7 @@ def list_databases( return self._stubs["list_databases"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -1212,7 +1302,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, @@ -1229,7 +1319,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, @@ -1246,7 +1336,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, @@ -1265,7 +1355,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, @@ -1284,7 +1374,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, @@ -1301,7 +1391,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-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/transports/grpc_asyncio.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/transports/grpc_asyncio.py index ed1893416b12..161b55fd2289 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/transports/grpc_asyncio.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/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.alloydb_v1alpha.types import resources, service from .base import DEFAULT_CLIENT_INFO, AlloyDBAdminTransport from .grpc import AlloyDBAdminGrpcTransport +try: + from google.api_core import client_logging # 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.alloydb.v1alpha.AlloyDBAdmin", + "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.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AlloyDBAdminGrpcAsyncIOTransport(AlloyDBAdminTransport): """gRPC AsyncIO backend transport for AlloyDBAdmin. @@ -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. @@ -285,7 +370,7 @@ def list_clusters( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_clusters" not in self._stubs: - self._stubs["list_clusters"] = self.grpc_channel.unary_unary( + self._stubs["list_clusters"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/ListClusters", request_serializer=service.ListClustersRequest.serialize, response_deserializer=service.ListClustersResponse.deserialize, @@ -311,7 +396,7 @@ def get_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_cluster" not in self._stubs: - self._stubs["get_cluster"] = self.grpc_channel.unary_unary( + self._stubs["get_cluster"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/GetCluster", request_serializer=service.GetClusterRequest.serialize, response_deserializer=resources.Cluster.deserialize, @@ -338,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.alloydb.v1alpha.AlloyDBAdmin/CreateCluster", request_serializer=service.CreateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -364,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.alloydb.v1alpha.AlloyDBAdmin/UpdateCluster", request_serializer=service.UpdateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -391,7 +476,7 @@ def upgrade_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "upgrade_cluster" not in self._stubs: - self._stubs["upgrade_cluster"] = self.grpc_channel.unary_unary( + self._stubs["upgrade_cluster"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/UpgradeCluster", request_serializer=service.UpgradeClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -417,7 +502,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.alloydb.v1alpha.AlloyDBAdmin/DeleteCluster", request_serializer=service.DeleteClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -446,7 +531,7 @@ def promote_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "promote_cluster" not in self._stubs: - self._stubs["promote_cluster"] = self.grpc_channel.unary_unary( + self._stubs["promote_cluster"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/PromoteCluster", request_serializer=service.PromoteClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -477,7 +562,7 @@ def switchover_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "switchover_cluster" not in self._stubs: - self._stubs["switchover_cluster"] = self.grpc_channel.unary_unary( + self._stubs["switchover_cluster"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/SwitchoverCluster", request_serializer=service.SwitchoverClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -506,7 +591,7 @@ def restore_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "restore_cluster" not in self._stubs: - self._stubs["restore_cluster"] = self.grpc_channel.unary_unary( + self._stubs["restore_cluster"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/RestoreCluster", request_serializer=service.RestoreClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -535,7 +620,7 @@ def create_secondary_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_secondary_cluster" not in self._stubs: - self._stubs["create_secondary_cluster"] = self.grpc_channel.unary_unary( + self._stubs["create_secondary_cluster"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/CreateSecondaryCluster", request_serializer=service.CreateSecondaryClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -563,7 +648,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.alloydb.v1alpha.AlloyDBAdmin/ListInstances", request_serializer=service.ListInstancesRequest.serialize, response_deserializer=service.ListInstancesResponse.deserialize, @@ -589,7 +674,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.alloydb.v1alpha.AlloyDBAdmin/GetInstance", request_serializer=service.GetInstanceRequest.serialize, response_deserializer=resources.Instance.deserialize, @@ -616,7 +701,7 @@ def create_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_instance" not in self._stubs: - self._stubs["create_instance"] = self.grpc_channel.unary_unary( + self._stubs["create_instance"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/CreateInstance", request_serializer=service.CreateInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -645,7 +730,7 @@ def create_secondary_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_secondary_instance" not in self._stubs: - self._stubs["create_secondary_instance"] = self.grpc_channel.unary_unary( + self._stubs["create_secondary_instance"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/CreateSecondaryInstance", request_serializer=service.CreateSecondaryInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -685,7 +770,7 @@ def batch_create_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_create_instances" not in self._stubs: - self._stubs["batch_create_instances"] = self.grpc_channel.unary_unary( + self._stubs["batch_create_instances"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/BatchCreateInstances", request_serializer=service.BatchCreateInstancesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -711,7 +796,7 @@ def update_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_instance" not in self._stubs: - self._stubs["update_instance"] = self.grpc_channel.unary_unary( + self._stubs["update_instance"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/UpdateInstance", request_serializer=service.UpdateInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -737,7 +822,7 @@ def delete_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_instance" not in self._stubs: - self._stubs["delete_instance"] = self.grpc_channel.unary_unary( + self._stubs["delete_instance"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/DeleteInstance", request_serializer=service.DeleteInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -767,7 +852,7 @@ def failover_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "failover_instance" not in self._stubs: - self._stubs["failover_instance"] = self.grpc_channel.unary_unary( + self._stubs["failover_instance"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/FailoverInstance", request_serializer=service.FailoverInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -794,7 +879,7 @@ def inject_fault( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "inject_fault" not in self._stubs: - self._stubs["inject_fault"] = self.grpc_channel.unary_unary( + self._stubs["inject_fault"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/InjectFault", request_serializer=service.InjectFaultRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -823,7 +908,7 @@ def restart_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "restart_instance" not in self._stubs: - self._stubs["restart_instance"] = self.grpc_channel.unary_unary( + self._stubs["restart_instance"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/RestartInstance", request_serializer=service.RestartInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -850,7 +935,7 @@ def execute_sql( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "execute_sql" not in self._stubs: - self._stubs["execute_sql"] = self.grpc_channel.unary_unary( + self._stubs["execute_sql"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/ExecuteSql", request_serializer=service.ExecuteSqlRequest.serialize, response_deserializer=service.ExecuteSqlResponse.deserialize, @@ -876,7 +961,7 @@ def list_backups( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_backups" not in self._stubs: - self._stubs["list_backups"] = self.grpc_channel.unary_unary( + self._stubs["list_backups"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/ListBackups", request_serializer=service.ListBackupsRequest.serialize, response_deserializer=service.ListBackupsResponse.deserialize, @@ -902,7 +987,7 @@ def get_backup( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_backup" not in self._stubs: - self._stubs["get_backup"] = self.grpc_channel.unary_unary( + self._stubs["get_backup"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/GetBackup", request_serializer=service.GetBackupRequest.serialize, response_deserializer=resources.Backup.deserialize, @@ -928,7 +1013,7 @@ def create_backup( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_backup" not in self._stubs: - self._stubs["create_backup"] = self.grpc_channel.unary_unary( + self._stubs["create_backup"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/CreateBackup", request_serializer=service.CreateBackupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -954,7 +1039,7 @@ def update_backup( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_backup" not in self._stubs: - self._stubs["update_backup"] = self.grpc_channel.unary_unary( + self._stubs["update_backup"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/UpdateBackup", request_serializer=service.UpdateBackupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -980,7 +1065,7 @@ def delete_backup( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_backup" not in self._stubs: - self._stubs["delete_backup"] = self.grpc_channel.unary_unary( + self._stubs["delete_backup"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/DeleteBackup", request_serializer=service.DeleteBackupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1012,7 +1097,7 @@ def list_supported_database_flags( if "list_supported_database_flags" not in self._stubs: self._stubs[ "list_supported_database_flags" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/ListSupportedDatabaseFlags", request_serializer=service.ListSupportedDatabaseFlagsRequest.serialize, response_deserializer=service.ListSupportedDatabaseFlagsResponse.deserialize, @@ -1047,7 +1132,9 @@ def generate_client_certificate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_client_certificate" not in self._stubs: - self._stubs["generate_client_certificate"] = self.grpc_channel.unary_unary( + self._stubs[ + "generate_client_certificate" + ] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/GenerateClientCertificate", request_serializer=service.GenerateClientCertificateRequest.serialize, response_deserializer=service.GenerateClientCertificateResponse.deserialize, @@ -1075,7 +1162,7 @@ def get_connection_info( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_connection_info" not in self._stubs: - self._stubs["get_connection_info"] = self.grpc_channel.unary_unary( + self._stubs["get_connection_info"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/GetConnectionInfo", request_serializer=service.GetConnectionInfoRequest.serialize, response_deserializer=resources.ConnectionInfo.deserialize, @@ -1101,7 +1188,7 @@ def list_users( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_users" not in self._stubs: - self._stubs["list_users"] = self.grpc_channel.unary_unary( + self._stubs["list_users"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/ListUsers", request_serializer=service.ListUsersRequest.serialize, response_deserializer=service.ListUsersResponse.deserialize, @@ -1125,7 +1212,7 @@ def get_user(self) -> Callable[[service.GetUserRequest], Awaitable[resources.Use # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_user" not in self._stubs: - self._stubs["get_user"] = self.grpc_channel.unary_unary( + self._stubs["get_user"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/GetUser", request_serializer=service.GetUserRequest.serialize, response_deserializer=resources.User.deserialize, @@ -1152,7 +1239,7 @@ def create_user( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_user" not in self._stubs: - self._stubs["create_user"] = self.grpc_channel.unary_unary( + self._stubs["create_user"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/CreateUser", request_serializer=service.CreateUserRequest.serialize, response_deserializer=resources.User.deserialize, @@ -1178,7 +1265,7 @@ def update_user( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_user" not in self._stubs: - self._stubs["update_user"] = self.grpc_channel.unary_unary( + self._stubs["update_user"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/UpdateUser", request_serializer=service.UpdateUserRequest.serialize, response_deserializer=resources.User.deserialize, @@ -1204,7 +1291,7 @@ def delete_user( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_user" not in self._stubs: - self._stubs["delete_user"] = self.grpc_channel.unary_unary( + self._stubs["delete_user"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/DeleteUser", request_serializer=service.DeleteUserRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1232,7 +1319,7 @@ def list_databases( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_databases" not in self._stubs: - self._stubs["list_databases"] = self.grpc_channel.unary_unary( + self._stubs["list_databases"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1alpha.AlloyDBAdmin/ListDatabases", request_serializer=service.ListDatabasesRequest.serialize, response_deserializer=service.ListDatabasesResponse.deserialize, @@ -1554,7 +1641,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: @@ -1570,7 +1657,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, @@ -1587,7 +1674,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, @@ -1604,7 +1691,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, @@ -1623,7 +1710,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, @@ -1642,7 +1729,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, @@ -1659,7 +1746,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-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/transports/rest.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/transports/rest.py index eb1c9315c093..7a0bbcd53a09 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/transports/rest.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1alpha/services/alloy_db_admin/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, @@ -350,8 +358,10 @@ def post_upgrade_cluster(self, response): def pre_batch_create_instances( self, request: service.BatchCreateInstancesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.BatchCreateInstancesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.BatchCreateInstancesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for batch_create_instances Override in a subclass to manipulate the request or metadata @@ -371,8 +381,10 @@ def post_batch_create_instances( return response def pre_create_backup( - self, request: service.CreateBackupRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.CreateBackupRequest, Sequence[Tuple[str, str]]]: + self, + request: service.CreateBackupRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.CreateBackupRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_backup Override in a subclass to manipulate the request or metadata @@ -392,8 +404,10 @@ def post_create_backup( return response def pre_create_cluster( - self, request: service.CreateClusterRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.CreateClusterRequest, Sequence[Tuple[str, str]]]: + self, + request: service.CreateClusterRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.CreateClusterRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_cluster Override in a subclass to manipulate the request or metadata @@ -415,8 +429,8 @@ def post_create_cluster( def pre_create_instance( self, request: service.CreateInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.CreateInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.CreateInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_instance Override in a subclass to manipulate the request or metadata @@ -438,8 +452,10 @@ def post_create_instance( def pre_create_secondary_cluster( self, request: service.CreateSecondaryClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.CreateSecondaryClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.CreateSecondaryClusterRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_secondary_cluster Override in a subclass to manipulate the request or metadata @@ -461,8 +477,10 @@ def post_create_secondary_cluster( def pre_create_secondary_instance( self, request: service.CreateSecondaryInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.CreateSecondaryInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.CreateSecondaryInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_secondary_instance Override in a subclass to manipulate the request or metadata @@ -482,8 +500,10 @@ def post_create_secondary_instance( return response def pre_create_user( - self, request: service.CreateUserRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.CreateUserRequest, Sequence[Tuple[str, str]]]: + self, + request: service.CreateUserRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.CreateUserRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_user Override in a subclass to manipulate the request or metadata @@ -501,8 +521,10 @@ def post_create_user(self, response: resources.User) -> resources.User: return response def pre_delete_backup( - self, request: service.DeleteBackupRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.DeleteBackupRequest, Sequence[Tuple[str, str]]]: + self, + request: service.DeleteBackupRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.DeleteBackupRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_backup Override in a subclass to manipulate the request or metadata @@ -522,8 +544,10 @@ def post_delete_backup( return response def pre_delete_cluster( - self, request: service.DeleteClusterRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.DeleteClusterRequest, Sequence[Tuple[str, str]]]: + self, + request: service.DeleteClusterRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.DeleteClusterRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_cluster Override in a subclass to manipulate the request or metadata @@ -545,8 +569,8 @@ def post_delete_cluster( def pre_delete_instance( self, request: service.DeleteInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.DeleteInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.DeleteInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_instance Override in a subclass to manipulate the request or metadata @@ -566,8 +590,10 @@ def post_delete_instance( return response def pre_delete_user( - self, request: service.DeleteUserRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.DeleteUserRequest, Sequence[Tuple[str, str]]]: + self, + request: service.DeleteUserRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.DeleteUserRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_user Override in a subclass to manipulate the request or metadata @@ -576,8 +602,10 @@ def pre_delete_user( return request, metadata def pre_execute_sql( - self, request: service.ExecuteSqlRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ExecuteSqlRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ExecuteSqlRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ExecuteSqlRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for execute_sql Override in a subclass to manipulate the request or metadata @@ -599,8 +627,10 @@ def post_execute_sql( def pre_failover_instance( self, request: service.FailoverInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.FailoverInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.FailoverInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for failover_instance Override in a subclass to manipulate the request or metadata @@ -622,8 +652,11 @@ def post_failover_instance( def pre_generate_client_certificate( self, request: service.GenerateClientCertificateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.GenerateClientCertificateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.GenerateClientCertificateRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for generate_client_certificate Override in a subclass to manipulate the request or metadata @@ -643,8 +676,10 @@ def post_generate_client_certificate( return response def pre_get_backup( - self, request: service.GetBackupRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetBackupRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetBackupRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetBackupRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_backup Override in a subclass to manipulate the request or metadata @@ -662,8 +697,10 @@ def post_get_backup(self, response: resources.Backup) -> resources.Backup: return response def pre_get_cluster( - self, request: service.GetClusterRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetClusterRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetClusterRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetClusterRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_cluster Override in a subclass to manipulate the request or metadata @@ -683,8 +720,10 @@ def post_get_cluster(self, response: resources.Cluster) -> resources.Cluster: def pre_get_connection_info( self, request: service.GetConnectionInfoRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.GetConnectionInfoRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.GetConnectionInfoRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_connection_info Override in a subclass to manipulate the request or metadata @@ -704,8 +743,10 @@ def post_get_connection_info( return response def pre_get_instance( - self, request: service.GetInstanceRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetInstanceRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetInstanceRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_instance Override in a subclass to manipulate the request or metadata @@ -723,8 +764,10 @@ def post_get_instance(self, response: resources.Instance) -> resources.Instance: return response def pre_get_user( - self, request: service.GetUserRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetUserRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetUserRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetUserRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_user Override in a subclass to manipulate the request or metadata @@ -742,8 +785,10 @@ def post_get_user(self, response: resources.User) -> resources.User: return response def pre_inject_fault( - self, request: service.InjectFaultRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.InjectFaultRequest, Sequence[Tuple[str, str]]]: + self, + request: service.InjectFaultRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.InjectFaultRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for inject_fault Override in a subclass to manipulate the request or metadata @@ -763,8 +808,10 @@ def post_inject_fault( return response def pre_list_backups( - self, request: service.ListBackupsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ListBackupsRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ListBackupsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListBackupsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_backups Override in a subclass to manipulate the request or metadata @@ -784,8 +831,10 @@ def post_list_backups( return response def pre_list_clusters( - self, request: service.ListClustersRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ListClustersRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ListClustersRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListClustersRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_clusters Override in a subclass to manipulate the request or metadata @@ -805,8 +854,10 @@ def post_list_clusters( return response def pre_list_databases( - self, request: service.ListDatabasesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ListDatabasesRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ListDatabasesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListDatabasesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_databases Override in a subclass to manipulate the request or metadata @@ -826,8 +877,10 @@ def post_list_databases( return response def pre_list_instances( - self, request: service.ListInstancesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ListInstancesRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ListInstancesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListInstancesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_instances Override in a subclass to manipulate the request or metadata @@ -849,8 +902,11 @@ def post_list_instances( def pre_list_supported_database_flags( self, request: service.ListSupportedDatabaseFlagsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.ListSupportedDatabaseFlagsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.ListSupportedDatabaseFlagsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_supported_database_flags Override in a subclass to manipulate the request or metadata @@ -870,8 +926,10 @@ def post_list_supported_database_flags( return response def pre_list_users( - self, request: service.ListUsersRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ListUsersRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ListUsersRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListUsersRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_users Override in a subclass to manipulate the request or metadata @@ -893,8 +951,8 @@ def post_list_users( def pre_promote_cluster( self, request: service.PromoteClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.PromoteClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.PromoteClusterRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for promote_cluster Override in a subclass to manipulate the request or metadata @@ -916,8 +974,8 @@ def post_promote_cluster( def pre_restart_instance( self, request: service.RestartInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.RestartInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.RestartInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for restart_instance Override in a subclass to manipulate the request or metadata @@ -939,8 +997,8 @@ def post_restart_instance( def pre_restore_cluster( self, request: service.RestoreClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.RestoreClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.RestoreClusterRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for restore_cluster Override in a subclass to manipulate the request or metadata @@ -962,8 +1020,10 @@ def post_restore_cluster( def pre_switchover_cluster( self, request: service.SwitchoverClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.SwitchoverClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.SwitchoverClusterRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for switchover_cluster Override in a subclass to manipulate the request or metadata @@ -983,8 +1043,10 @@ def post_switchover_cluster( return response def pre_update_backup( - self, request: service.UpdateBackupRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.UpdateBackupRequest, Sequence[Tuple[str, str]]]: + self, + request: service.UpdateBackupRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.UpdateBackupRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_backup Override in a subclass to manipulate the request or metadata @@ -1004,8 +1066,10 @@ def post_update_backup( return response def pre_update_cluster( - self, request: service.UpdateClusterRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.UpdateClusterRequest, Sequence[Tuple[str, str]]]: + self, + request: service.UpdateClusterRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.UpdateClusterRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_cluster Override in a subclass to manipulate the request or metadata @@ -1027,8 +1091,8 @@ def post_update_cluster( def pre_update_instance( self, request: service.UpdateInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.UpdateInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.UpdateInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_instance Override in a subclass to manipulate the request or metadata @@ -1048,8 +1112,10 @@ def post_update_instance( return response def pre_update_user( - self, request: service.UpdateUserRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.UpdateUserRequest, Sequence[Tuple[str, str]]]: + self, + request: service.UpdateUserRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.UpdateUserRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_user Override in a subclass to manipulate the request or metadata @@ -1069,8 +1135,8 @@ def post_update_user(self, response: resources.User) -> resources.User: def pre_upgrade_cluster( self, request: service.UpgradeClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.UpgradeClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.UpgradeClusterRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for upgrade_cluster Override in a subclass to manipulate the request or metadata @@ -1092,8 +1158,10 @@ def post_upgrade_cluster( 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 @@ -1115,8 +1183,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 @@ -1138,8 +1208,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 @@ -1159,8 +1231,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 @@ -1180,8 +1254,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 @@ -1203,8 +1279,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 @@ -1399,7 +1477,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the batch create instances method over HTTP. @@ -1410,8 +1488,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1424,6 +1504,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseBatchCreateInstances._get_http_options() ) + request, metadata = self._interceptor.pre_batch_create_instances( request, metadata ) @@ -1440,6 +1521,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.BatchCreateInstances", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "BatchCreateInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._BatchCreateInstances._get_response( self._host, @@ -1459,7 +1567,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_create_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.alloydb_v1alpha.AlloyDBAdminClient.batch_create_instances", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "BatchCreateInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateBackup( @@ -1497,7 +1627,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create backup method over HTTP. @@ -1507,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: ~.operations_pb2.Operation: @@ -1521,6 +1653,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseCreateBackup._get_http_options() ) + request, metadata = self._interceptor.pre_create_backup(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseCreateBackup._get_transcoded_request( http_options, request @@ -1539,6 +1672,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.CreateBackup", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "CreateBackup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._CreateBackup._get_response( self._host, @@ -1558,7 +1718,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_backup(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.create_backup", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "CreateBackup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateCluster( @@ -1596,7 +1778,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create cluster method over HTTP. @@ -1606,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: @@ -1620,6 +1804,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseCreateCluster._get_http_options() ) + request, metadata = self._interceptor.pre_create_cluster(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseCreateCluster._get_transcoded_request( http_options, request @@ -1634,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.alloydb_v1alpha.AlloyDBAdminClient.CreateCluster", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "CreateCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._CreateCluster._get_response( self._host, @@ -1653,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_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.alloydb_v1alpha.AlloyDBAdminClient.create_cluster", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "CreateCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateInstance( @@ -1691,7 +1925,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create instance method over HTTP. @@ -1701,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: @@ -1715,6 +1951,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseCreateInstance._get_http_options() ) + request, metadata = self._interceptor.pre_create_instance(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseCreateInstance._get_transcoded_request( http_options, request @@ -1729,6 +1966,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.CreateInstance", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "CreateInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._CreateInstance._get_response( self._host, @@ -1748,7 +2012,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_instance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.create_instance", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "CreateInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSecondaryCluster( @@ -1786,7 +2072,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 secondary cluster method over HTTP. @@ -1796,8 +2082,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1810,6 +2098,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseCreateSecondaryCluster._get_http_options() ) + request, metadata = self._interceptor.pre_create_secondary_cluster( request, metadata ) @@ -1826,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.alloydb_v1alpha.AlloyDBAdminClient.CreateSecondaryCluster", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "CreateSecondaryCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._CreateSecondaryCluster._get_response( self._host, @@ -1845,7 +2161,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_secondary_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.alloydb_v1alpha.AlloyDBAdminClient.create_secondary_cluster", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "CreateSecondaryCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSecondaryInstance( @@ -1884,7 +2222,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 secondary instance method over HTTP. @@ -1895,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: @@ -1909,6 +2249,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseCreateSecondaryInstance._get_http_options() ) + request, metadata = self._interceptor.pre_create_secondary_instance( request, metadata ) @@ -1925,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.alloydb_v1alpha.AlloyDBAdminClient.CreateSecondaryInstance", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "CreateSecondaryInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._CreateSecondaryInstance._get_response( self._host, @@ -1944,7 +2312,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_secondary_instance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.create_secondary_instance", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "CreateSecondaryInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateUser( @@ -1982,7 +2372,7 @@ 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.User: r"""Call the create user method over HTTP. @@ -1992,8 +2382,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.User: @@ -2003,6 +2395,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseCreateUser._get_http_options() ) + request, metadata = self._interceptor.pre_create_user(request, metadata) transcoded_request = ( _BaseAlloyDBAdminRestTransport._BaseCreateUser._get_transcoded_request( @@ -2023,6 +2416,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.CreateUser", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "CreateUser", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._CreateUser._get_response( self._host, @@ -2044,7 +2464,29 @@ def __call__( pb_resp = resources.User.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_user(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.User.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.create_user", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "CreateUser", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteBackup( @@ -2081,7 +2523,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 backup method over HTTP. @@ -2091,8 +2533,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2105,6 +2549,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseDeleteBackup._get_http_options() ) + request, metadata = self._interceptor.pre_delete_backup(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseDeleteBackup._get_transcoded_request( http_options, request @@ -2117,6 +2562,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.DeleteBackup", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "DeleteBackup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._DeleteBackup._get_response( self._host, @@ -2135,7 +2607,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_backup(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.delete_backup", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "DeleteBackup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteCluster( @@ -2172,7 +2666,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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. @@ -2182,8 +2676,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2196,6 +2692,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseDeleteCluster._get_http_options() ) + request, metadata = self._interceptor.pre_delete_cluster(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseDeleteCluster._get_transcoded_request( http_options, request @@ -2206,6 +2703,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.DeleteCluster", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "DeleteCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._DeleteCluster._get_response( self._host, @@ -2224,7 +2748,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.alloydb_v1alpha.AlloyDBAdminClient.delete_cluster", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "DeleteCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteInstance( @@ -2261,7 +2807,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete instance method over HTTP. @@ -2271,8 +2817,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2285,6 +2833,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseDeleteInstance._get_http_options() ) + request, metadata = self._interceptor.pre_delete_instance(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseDeleteInstance._get_transcoded_request( http_options, request @@ -2295,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 = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.DeleteInstance", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "DeleteInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._DeleteInstance._get_response( self._host, @@ -2313,7 +2889,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_instance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.delete_instance", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "DeleteInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteUser( @@ -2350,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]]] = (), ): r"""Call the delete user method over HTTP. @@ -2360,13 +2958,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 = ( _BaseAlloyDBAdminRestTransport._BaseDeleteUser._get_http_options() ) + request, metadata = self._interceptor.pre_delete_user(request, metadata) transcoded_request = ( _BaseAlloyDBAdminRestTransport._BaseDeleteUser._get_transcoded_request( @@ -2381,6 +2982,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.DeleteUser", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "DeleteUser", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._DeleteUser._get_response( self._host, @@ -2431,7 +3059,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.ExecuteSqlResponse: r"""Call the execute sql method over HTTP. @@ -2441,8 +3069,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.service.ExecuteSqlResponse: @@ -2452,6 +3082,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseExecuteSql._get_http_options() ) + request, metadata = self._interceptor.pre_execute_sql(request, metadata) transcoded_request = ( _BaseAlloyDBAdminRestTransport._BaseExecuteSql._get_transcoded_request( @@ -2472,6 +3103,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.ExecuteSql", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "ExecuteSql", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._ExecuteSql._get_response( self._host, @@ -2493,7 +3151,29 @@ def __call__( pb_resp = service.ExecuteSqlResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_execute_sql(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ExecuteSqlResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.execute_sql", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "ExecuteSql", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _FailoverInstance( @@ -2531,7 +3211,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the failover instance method over HTTP. @@ -2542,8 +3222,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2556,6 +3238,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseFailoverInstance._get_http_options() ) + request, metadata = self._interceptor.pre_failover_instance( request, metadata ) @@ -2572,6 +3255,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.FailoverInstance", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "FailoverInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._FailoverInstance._get_response( self._host, @@ -2591,7 +3301,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_failover_instance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.failover_instance", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "FailoverInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GenerateClientCertificate( @@ -2630,7 +3362,7 @@ 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.GenerateClientCertificateResponse: r"""Call the generate client certificate method over HTTP. @@ -2643,8 +3375,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.GenerateClientCertificateResponse: @@ -2656,6 +3390,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseGenerateClientCertificate._get_http_options() ) + request, metadata = self._interceptor.pre_generate_client_certificate( request, metadata ) @@ -2672,6 +3407,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.GenerateClientCertificate", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "GenerateClientCertificate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AlloyDBAdminRestTransport._GenerateClientCertificate._get_response( @@ -2695,7 +3457,31 @@ def __call__( pb_resp = service.GenerateClientCertificateResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_generate_client_certificate(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + service.GenerateClientCertificateResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.generate_client_certificate", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "GenerateClientCertificate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetBackup( @@ -2732,7 +3518,7 @@ 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.Backup: r"""Call the get backup method over HTTP. @@ -2742,8 +3528,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.Backup: @@ -2753,6 +3541,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseGetBackup._get_http_options() ) + request, metadata = self._interceptor.pre_get_backup(request, metadata) transcoded_request = ( _BaseAlloyDBAdminRestTransport._BaseGetBackup._get_transcoded_request( @@ -2767,6 +3556,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.GetBackup", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "GetBackup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._GetBackup._get_response( self._host, @@ -2787,7 +3603,29 @@ def __call__( pb_resp = resources.Backup.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_backup(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Backup.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.get_backup", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "GetBackup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCluster( @@ -2824,7 +3662,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Cluster: r"""Call the get cluster method over HTTP. @@ -2834,8 +3672,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.resources.Cluster: @@ -2851,6 +3691,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseGetCluster._get_http_options() ) + request, metadata = self._interceptor.pre_get_cluster(request, metadata) transcoded_request = ( _BaseAlloyDBAdminRestTransport._BaseGetCluster._get_transcoded_request( @@ -2865,6 +3706,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.GetCluster", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "GetCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._GetCluster._get_response( self._host, @@ -2885,7 +3753,29 @@ def __call__( pb_resp = resources.Cluster.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_cluster(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Cluster.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.get_cluster", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "GetCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetConnectionInfo( @@ -2922,7 +3812,7 @@ 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.ConnectionInfo: r"""Call the get connection info method over HTTP. @@ -2933,8 +3823,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ConnectionInfo: @@ -2946,6 +3838,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseGetConnectionInfo._get_http_options() ) + request, metadata = self._interceptor.pre_get_connection_info( request, metadata ) @@ -2958,6 +3851,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.GetConnectionInfo", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "GetConnectionInfo", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._GetConnectionInfo._get_response( self._host, @@ -2978,7 +3898,29 @@ def __call__( pb_resp = resources.ConnectionInfo.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_connection_info(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.ConnectionInfo.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.get_connection_info", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "GetConnectionInfo", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetInstance( @@ -3015,7 +3957,7 @@ 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.Instance: r"""Call the get instance method over HTTP. @@ -3025,8 +3967,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.Instance: @@ -3040,6 +3984,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseGetInstance._get_http_options() ) + request, metadata = self._interceptor.pre_get_instance(request, metadata) transcoded_request = ( _BaseAlloyDBAdminRestTransport._BaseGetInstance._get_transcoded_request( @@ -3054,6 +3999,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.GetInstance", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "GetInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._GetInstance._get_response( self._host, @@ -3074,7 +4046,29 @@ def __call__( pb_resp = resources.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 = resources.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.alloydb_v1alpha.AlloyDBAdminClient.get_instance", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "GetInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetUser(_BaseAlloyDBAdminRestTransport._BaseGetUser, AlloyDBAdminRestStub): @@ -3109,7 +4103,7 @@ 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.User: r"""Call the get user method over HTTP. @@ -3119,8 +4113,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.User: @@ -3130,6 +4126,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseGetUser._get_http_options() ) + request, metadata = self._interceptor.pre_get_user(request, metadata) transcoded_request = ( _BaseAlloyDBAdminRestTransport._BaseGetUser._get_transcoded_request( @@ -3144,6 +4141,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.GetUser", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "GetUser", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._GetUser._get_response( self._host, @@ -3164,7 +4188,29 @@ def __call__( pb_resp = resources.User.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_user(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.User.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.get_user", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "GetUser", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _InjectFault( @@ -3202,7 +4248,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the inject fault method over HTTP. @@ -3213,8 +4259,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3227,6 +4275,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseInjectFault._get_http_options() ) + request, metadata = self._interceptor.pre_inject_fault(request, metadata) transcoded_request = ( _BaseAlloyDBAdminRestTransport._BaseInjectFault._get_transcoded_request( @@ -3247,6 +4296,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.InjectFault", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "InjectFault", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._InjectFault._get_response( self._host, @@ -3266,7 +4342,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_inject_fault(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.inject_fault", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "InjectFault", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListBackups( @@ -3303,7 +4401,7 @@ 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.ListBackupsResponse: r"""Call the list backups method over HTTP. @@ -3314,8 +4412,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ListBackupsResponse: @@ -3327,6 +4427,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseListBackups._get_http_options() ) + request, metadata = self._interceptor.pre_list_backups(request, metadata) transcoded_request = ( _BaseAlloyDBAdminRestTransport._BaseListBackups._get_transcoded_request( @@ -3341,6 +4442,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.ListBackups", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "ListBackups", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._ListBackups._get_response( self._host, @@ -3361,7 +4489,29 @@ def __call__( pb_resp = service.ListBackupsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_backups(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListBackupsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.list_backups", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "ListBackups", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListClusters( @@ -3398,7 +4548,7 @@ 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.ListClustersResponse: r"""Call the list clusters method over HTTP. @@ -3409,8 +4559,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ListClustersResponse: @@ -3422,6 +4574,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseListClusters._get_http_options() ) + request, metadata = self._interceptor.pre_list_clusters(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseListClusters._get_transcoded_request( http_options, request @@ -3434,6 +4587,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.ListClusters", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "ListClusters", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._ListClusters._get_response( self._host, @@ -3454,7 +4634,29 @@ def __call__( pb_resp = 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 = 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.alloydb_v1alpha.AlloyDBAdminClient.list_clusters", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "ListClusters", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDatabases( @@ -3491,7 +4693,7 @@ 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.ListDatabasesResponse: r"""Call the list databases method over HTTP. @@ -3502,8 +4704,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ListDatabasesResponse: @@ -3515,6 +4719,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseListDatabases._get_http_options() ) + request, metadata = self._interceptor.pre_list_databases(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseListDatabases._get_transcoded_request( http_options, request @@ -3525,6 +4730,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.ListDatabases", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "ListDatabases", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._ListDatabases._get_response( self._host, @@ -3545,7 +4777,29 @@ def __call__( pb_resp = service.ListDatabasesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_databases(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListDatabasesResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.list_databases", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "ListDatabases", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListInstances( @@ -3582,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]]] = (), ) -> service.ListInstancesResponse: r"""Call the list instances method over HTTP. @@ -3593,8 +4847,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ListInstancesResponse: @@ -3606,6 +4862,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseListInstances._get_http_options() ) + request, metadata = self._interceptor.pre_list_instances(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseListInstances._get_transcoded_request( http_options, request @@ -3616,6 +4873,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.ListInstances", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "ListInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._ListInstances._get_response( self._host, @@ -3636,7 +4920,29 @@ def __call__( pb_resp = service.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 = service.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.alloydb_v1alpha.AlloyDBAdminClient.list_instances", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "ListInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSupportedDatabaseFlags( @@ -3674,7 +4980,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.ListSupportedDatabaseFlagsResponse: r"""Call the list supported database flags method over HTTP. @@ -3686,8 +4992,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ListSupportedDatabaseFlagsResponse: @@ -3699,6 +5007,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseListSupportedDatabaseFlags._get_http_options() ) + request, metadata = self._interceptor.pre_list_supported_database_flags( request, metadata ) @@ -3711,6 +5020,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.ListSupportedDatabaseFlags", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "ListSupportedDatabaseFlags", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AlloyDBAdminRestTransport._ListSupportedDatabaseFlags._get_response( @@ -3733,7 +5069,31 @@ def __call__( pb_resp = service.ListSupportedDatabaseFlagsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_supported_database_flags(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + service.ListSupportedDatabaseFlagsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.list_supported_database_flags", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "ListSupportedDatabaseFlags", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListUsers( @@ -3770,7 +5130,7 @@ 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.ListUsersResponse: r"""Call the list users method over HTTP. @@ -3780,8 +5140,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ListUsersResponse: @@ -3791,6 +5153,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseListUsers._get_http_options() ) + request, metadata = self._interceptor.pre_list_users(request, metadata) transcoded_request = ( _BaseAlloyDBAdminRestTransport._BaseListUsers._get_transcoded_request( @@ -3805,6 +5168,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.ListUsers", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "ListUsers", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._ListUsers._get_response( self._host, @@ -3825,7 +5215,29 @@ def __call__( pb_resp = service.ListUsersResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_users(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListUsersResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.list_users", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "ListUsers", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PromoteCluster( @@ -3863,7 +5275,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the promote cluster method over HTTP. @@ -3873,8 +5285,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3887,6 +5301,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BasePromoteCluster._get_http_options() ) + request, metadata = self._interceptor.pre_promote_cluster(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BasePromoteCluster._get_transcoded_request( http_options, request @@ -3901,6 +5316,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.PromoteCluster", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "PromoteCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._PromoteCluster._get_response( self._host, @@ -3920,7 +5362,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_promote_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.alloydb_v1alpha.AlloyDBAdminClient.promote_cluster", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "PromoteCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RestartInstance( @@ -3958,7 +5422,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the restart instance method over HTTP. @@ -3968,8 +5432,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3982,6 +5448,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseRestartInstance._get_http_options() ) + request, metadata = self._interceptor.pre_restart_instance( request, metadata ) @@ -3998,6 +5465,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.RestartInstance", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "RestartInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._RestartInstance._get_response( self._host, @@ -4017,7 +5511,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_restart_instance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.restart_instance", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "RestartInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RestoreCluster( @@ -4055,7 +5571,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the restore cluster method over HTTP. @@ -4067,8 +5583,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -4081,6 +5599,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseRestoreCluster._get_http_options() ) + request, metadata = self._interceptor.pre_restore_cluster(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseRestoreCluster._get_transcoded_request( http_options, request @@ -4095,6 +5614,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.RestoreCluster", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "RestoreCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._RestoreCluster._get_response( self._host, @@ -4114,7 +5660,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_restore_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.alloydb_v1alpha.AlloyDBAdminClient.restore_cluster", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "RestoreCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SwitchoverCluster( @@ -4152,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]]] = (), ) -> operations_pb2.Operation: r"""Call the switchover cluster method over HTTP. @@ -4163,8 +5731,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -4177,6 +5747,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseSwitchoverCluster._get_http_options() ) + request, metadata = self._interceptor.pre_switchover_cluster( request, metadata ) @@ -4193,6 +5764,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.SwitchoverCluster", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "SwitchoverCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._SwitchoverCluster._get_response( self._host, @@ -4212,7 +5810,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_switchover_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.alloydb_v1alpha.AlloyDBAdminClient.switchover_cluster", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "SwitchoverCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateBackup( @@ -4250,7 +5870,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 backup method over HTTP. @@ -4260,8 +5880,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -4274,6 +5896,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseUpdateBackup._get_http_options() ) + request, metadata = self._interceptor.pre_update_backup(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseUpdateBackup._get_transcoded_request( http_options, request @@ -4292,6 +5915,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.UpdateBackup", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "UpdateBackup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._UpdateBackup._get_response( self._host, @@ -4311,7 +5961,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_backup(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.update_backup", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "UpdateBackup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCluster( @@ -4349,7 +6021,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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. @@ -4359,8 +6031,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -4373,6 +6047,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseUpdateCluster._get_http_options() ) + request, metadata = self._interceptor.pre_update_cluster(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseUpdateCluster._get_transcoded_request( http_options, request @@ -4387,6 +6062,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.UpdateCluster", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "UpdateCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._UpdateCluster._get_response( self._host, @@ -4406,7 +6108,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.alloydb_v1alpha.AlloyDBAdminClient.update_cluster", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "UpdateCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateInstance( @@ -4444,7 +6168,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update instance method over HTTP. @@ -4454,8 +6178,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -4468,6 +6194,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseUpdateInstance._get_http_options() ) + request, metadata = self._interceptor.pre_update_instance(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseUpdateInstance._get_transcoded_request( http_options, request @@ -4482,6 +6209,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.UpdateInstance", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "UpdateInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._UpdateInstance._get_response( self._host, @@ -4501,7 +6255,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_instance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.update_instance", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "UpdateInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateUser( @@ -4539,7 +6315,7 @@ 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.User: r"""Call the update user method over HTTP. @@ -4549,8 +6325,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.User: @@ -4560,6 +6338,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseUpdateUser._get_http_options() ) + request, metadata = self._interceptor.pre_update_user(request, metadata) transcoded_request = ( _BaseAlloyDBAdminRestTransport._BaseUpdateUser._get_transcoded_request( @@ -4580,6 +6359,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.UpdateUser", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "UpdateUser", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._UpdateUser._get_response( self._host, @@ -4601,7 +6407,29 @@ def __call__( pb_resp = resources.User.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_user(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.User.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.update_user", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "UpdateUser", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpgradeCluster( @@ -4639,7 +6467,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 cluster method over HTTP. @@ -4649,8 +6477,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -4663,6 +6493,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseUpgradeCluster._get_http_options() ) + request, metadata = self._interceptor.pre_upgrade_cluster(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseUpgradeCluster._get_transcoded_request( http_options, request @@ -4677,6 +6508,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.UpgradeCluster", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "UpgradeCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._UpgradeCluster._get_response( self._host, @@ -4696,7 +6554,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_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.alloydb_v1alpha.AlloyDBAdminClient.upgrade_cluster", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "UpgradeCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -5011,7 +6891,7 @@ 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. @@ -5021,8 +6901,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -5031,6 +6913,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseAlloyDBAdminRestTransport._BaseGetLocation._get_transcoded_request( @@ -5045,6 +6928,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.GetLocation", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._GetLocation._get_response( self._host, @@ -5064,6 +6974,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.alloydb_v1alpha.AlloyDBAdminAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -5104,7 +7035,7 @@ 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. @@ -5114,8 +7045,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -5124,6 +7057,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -5134,6 +7068,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.ListLocations", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._ListLocations._get_response( self._host, @@ -5153,6 +7114,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.alloydb_v1alpha.AlloyDBAdminAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -5194,7 +7176,7 @@ 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. @@ -5204,13 +7186,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 = ( _BaseAlloyDBAdminRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -5227,6 +7212,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.CancelOperation", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._CancelOperation._get_response( self._host, @@ -5283,7 +7295,7 @@ 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. @@ -5293,13 +7305,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 = ( _BaseAlloyDBAdminRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -5312,6 +7327,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._DeleteOperation._get_response( self._host, @@ -5367,7 +7409,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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. @@ -5377,8 +7419,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -5387,6 +7431,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -5399,6 +7444,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.GetOperation", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._GetOperation._get_response( self._host, @@ -5418,6 +7490,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.alloydb_v1alpha.AlloyDBAdminAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -5458,7 +7551,7 @@ def __call__( *, 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. @@ -5468,8 +7561,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must 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. @@ -5478,6 +7573,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -5488,6 +7584,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1alpha.AlloyDBAdminClient.ListOperations", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._ListOperations._get_response( self._host, @@ -5507,6 +7630,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.alloydb_v1alpha.AlloyDBAdminAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.alloydb.v1alpha.AlloyDBAdmin", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/gapic_version.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/gapic_version.py index 386ddb96d97f..558c8aab67c5 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/gapic_version.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.4.0" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/async_client.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/async_client.py index dccd95717818..8942be52ee70 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/async_client.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/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, AlloyDBAdminTransport from .transports.grpc_asyncio import AlloyDBAdminGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class AlloyDBAdminAsyncClient: """Service describing handlers for resources""" @@ -290,6 +300,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.alloydb_v1beta.AlloyDBAdminAsyncClient`.", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "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.alloydb.v1beta.AlloyDBAdmin", + "credentialsType": None, + }, + ) + async def list_clusters( self, request: Optional[Union[service.ListClustersRequest, dict]] = None, @@ -297,7 +329,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. @@ -347,8 +379,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.alloydb_v1beta.services.alloy_db_admin.pagers.ListClustersAsyncPager: @@ -423,7 +457,7 @@ async def get_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Cluster: r"""Gets details of a single Cluster. @@ -467,8 +501,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.alloydb_v1beta.types.Cluster: @@ -535,7 +571,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. @@ -602,8 +638,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: @@ -681,7 +719,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. @@ -741,8 +779,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: @@ -820,7 +860,7 @@ async def upgrade_cluster( version: Optional[resources.DatabaseVersion] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 a single Cluster. Imperative only. @@ -876,8 +916,10 @@ async def sample_upgrade_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: @@ -952,7 +994,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. @@ -1000,8 +1042,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: @@ -1080,7 +1124,7 @@ async def promote_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"""Promotes a SECONDARY cluster. This turns down replication from the PRIMARY cluster and promotes a @@ -1131,8 +1175,10 @@ async def sample_promote_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: @@ -1205,7 +1251,7 @@ async def switchover_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"""Switches the roles of PRIMARY and SECONDARY clusters without any data loss. This promotes the SECONDARY @@ -1257,8 +1303,10 @@ async def sample_switchover_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: @@ -1330,7 +1378,7 @@ async def restore_cluster( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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, with a volume restored from the provided @@ -1385,8 +1433,10 @@ async def sample_restore_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: @@ -1447,7 +1497,7 @@ async def create_secondary_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 cluster of type SECONDARY in the given location using the primary cluster as the source. @@ -1517,8 +1567,10 @@ async def sample_create_secondary_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: @@ -1595,7 +1647,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. @@ -1646,8 +1698,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.alloydb_v1beta.services.alloy_db_admin.pagers.ListInstancesAsyncPager: @@ -1722,7 +1776,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]]] = (), ) -> resources.Instance: r"""Gets details of a single Instance. @@ -1766,8 +1820,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.alloydb_v1beta.types.Instance: @@ -1832,7 +1888,7 @@ async def create_instance( instance_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new Instance in a given project and location. @@ -1898,8 +1954,10 @@ async def sample_create_instance(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -1976,7 +2034,7 @@ async def create_secondary_instance( instance_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new SECONDARY Instance in a given project and location. @@ -2043,8 +2101,10 @@ async def sample_create_secondary_instance(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -2118,7 +2178,7 @@ async def batch_create_instances( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 new instances under the given project, location and cluster. There can be only one primary @@ -2177,8 +2237,10 @@ async def sample_batch_create_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: @@ -2237,7 +2299,7 @@ async def update_instance( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single Instance. @@ -2296,8 +2358,10 @@ async def sample_update_instance(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -2372,7 +2436,7 @@ async def delete_instance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single Instance. @@ -2420,8 +2484,10 @@ async def sample_delete_instance(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -2500,7 +2566,7 @@ async def failover_instance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Forces a Failover for a highly available instance. Failover promotes the HA standby instance as the new @@ -2551,8 +2617,10 @@ async def sample_failover_instance(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -2624,7 +2692,7 @@ async def inject_fault( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Injects fault in an instance. Imperative only. @@ -2682,8 +2750,10 @@ async def sample_inject_fault(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -2756,7 +2826,7 @@ async def restart_instance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Restart an Instance in a cluster. Imperative only. @@ -2805,8 +2875,10 @@ async def sample_restart_instance(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -2881,7 +2953,7 @@ async def execute_sql( password: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.ExecuteSqlResponse: r"""Executes a SQL statement in a database inside an AlloyDB instance. @@ -2965,8 +3037,10 @@ async def sample_execute_sql(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1beta.types.ExecuteSqlResponse: @@ -3033,7 +3107,7 @@ async def list_backups( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListBackupsAsyncPager: r"""Lists Backups in a given project and location. @@ -3078,8 +3152,10 @@ async def sample_list_backups(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1beta.services.alloy_db_admin.pagers.ListBackupsAsyncPager: @@ -3154,7 +3230,7 @@ async def get_backup( name: Optional[str] = None, retry: OptionalRetry = 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.Backup: r"""Gets details of a single Backup. @@ -3195,8 +3271,10 @@ async def sample_get_backup(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1beta.types.Backup: @@ -3257,7 +3335,7 @@ async def create_backup( backup_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 Backup in a given project and location. @@ -3319,8 +3397,10 @@ async def sample_create_backup(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -3397,7 +3477,7 @@ async def update_backup( 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 Backup. @@ -3456,8 +3536,10 @@ async def sample_update_backup(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -3533,7 +3615,7 @@ async def delete_backup( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 Backup. @@ -3581,8 +3663,10 @@ async def sample_delete_backup(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -3663,7 +3747,7 @@ async def list_supported_database_flags( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSupportedDatabaseFlagsAsyncPager: r"""Lists SupportedDatabaseFlags for a given project and location. @@ -3716,8 +3800,10 @@ async def sample_list_supported_database_flags(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1beta.services.alloy_db_admin.pagers.ListSupportedDatabaseFlagsAsyncPager: @@ -3792,7 +3878,7 @@ async def generate_client_certificate( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.GenerateClientCertificateResponse: r"""Generate a client certificate signed by a Cluster CA. The sole purpose of this endpoint is to support AlloyDB @@ -3845,8 +3931,10 @@ async def sample_generate_client_certificate(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1beta.types.GenerateClientCertificateResponse: @@ -3907,7 +3995,7 @@ async def get_connection_info( parent: Optional[str] = None, retry: OptionalRetry = 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.ConnectionInfo: r"""Get instance metadata used for a connection. @@ -3952,8 +4040,10 @@ async def sample_get_connection_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.alloydb_v1beta.types.ConnectionInfo: @@ -4014,7 +4104,7 @@ async def list_users( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListUsersAsyncPager: r"""Lists Users in a given project and location. @@ -4058,8 +4148,10 @@ async def sample_list_users(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1beta.services.alloy_db_admin.pagers.ListUsersAsyncPager: @@ -4134,7 +4226,7 @@ async def get_user( name: Optional[str] = None, retry: OptionalRetry = 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.User: r"""Gets details of a single User. @@ -4178,8 +4270,10 @@ async def sample_get_user(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1beta.types.User: @@ -4238,7 +4332,7 @@ async def create_user( user_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.User: r"""Creates a new User in a given project, location, and cluster. @@ -4293,8 +4387,10 @@ async def sample_create_user(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1beta.types.User: @@ -4358,7 +4454,7 @@ async def update_user( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.User: r"""Updates the parameters of a single User. @@ -4409,8 +4505,10 @@ async def sample_update_user(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1beta.types.User: @@ -4473,7 +4571,7 @@ async def delete_user( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 User. @@ -4514,8 +4612,10 @@ async def sample_delete_user(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -4567,7 +4667,7 @@ async def list_databases( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDatabasesAsyncPager: r"""Lists Databases in a given project and location. @@ -4612,8 +4712,10 @@ async def sample_list_databases(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1beta.services.alloy_db_admin.pagers.ListDatabasesAsyncPager: @@ -4687,7 +4789,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. @@ -4698,8 +4800,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. @@ -4740,7 +4844,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. @@ -4751,8 +4855,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. @@ -4793,7 +4899,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. @@ -4809,8 +4915,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 """ @@ -4847,7 +4955,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. @@ -4862,8 +4970,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 """ @@ -4900,7 +5010,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. @@ -4911,8 +5021,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. @@ -4953,7 +5065,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. @@ -4964,8 +5076,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-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/client.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/client.py index 34d74a6c8c3a..53e3e679b97b 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/client.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/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 @@ -777,6 +787,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( @@ -839,6 +853,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.alloydb_v1beta.AlloyDBAdminClient`.", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "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.alloydb.v1beta.AlloyDBAdmin", + "credentialsType": None, + }, + ) + def list_clusters( self, request: Optional[Union[service.ListClustersRequest, dict]] = None, @@ -846,7 +883,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. @@ -896,8 +933,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.alloydb_v1beta.services.alloy_db_admin.pagers.ListClustersPager: @@ -969,7 +1008,7 @@ def get_cluster( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Cluster: r"""Gets details of a single Cluster. @@ -1013,8 +1052,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.alloydb_v1beta.types.Cluster: @@ -1078,7 +1119,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. @@ -1145,8 +1186,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: @@ -1221,7 +1264,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. @@ -1281,8 +1324,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: @@ -1357,7 +1402,7 @@ def upgrade_cluster( version: Optional[resources.DatabaseVersion] = None, retry: OptionalRetry = gapic_v1.method.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 a single Cluster. Imperative only. @@ -1413,8 +1458,10 @@ def sample_upgrade_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: @@ -1486,7 +1533,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. @@ -1534,8 +1581,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: @@ -1611,7 +1660,7 @@ def promote_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"""Promotes a SECONDARY cluster. This turns down replication from the PRIMARY cluster and promotes a @@ -1662,8 +1711,10 @@ def sample_promote_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: @@ -1733,7 +1784,7 @@ def switchover_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"""Switches the roles of PRIMARY and SECONDARY clusters without any data loss. This promotes the SECONDARY @@ -1785,8 +1836,10 @@ def sample_switchover_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: @@ -1855,7 +1908,7 @@ def restore_cluster( *, retry: OptionalRetry = gapic_v1.method.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, with a volume restored from the provided @@ -1910,8 +1963,10 @@ def sample_restore_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: @@ -1970,7 +2025,7 @@ def create_secondary_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 cluster of type SECONDARY in the given location using the primary cluster as the source. @@ -2040,8 +2095,10 @@ def sample_create_secondary_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: @@ -2115,7 +2172,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. @@ -2166,8 +2223,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.alloydb_v1beta.services.alloy_db_admin.pagers.ListInstancesPager: @@ -2239,7 +2298,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]]] = (), ) -> resources.Instance: r"""Gets details of a single Instance. @@ -2283,8 +2342,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.alloydb_v1beta.types.Instance: @@ -2346,7 +2407,7 @@ def create_instance( instance_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new Instance in a given project and location. @@ -2412,8 +2473,10 @@ def sample_create_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -2487,7 +2550,7 @@ def create_secondary_instance( instance_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new SECONDARY Instance in a given project and location. @@ -2554,8 +2617,10 @@ def sample_create_secondary_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -2628,7 +2693,7 @@ def batch_create_instances( *, retry: OptionalRetry = gapic_v1.method.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 new instances under the given project, location and cluster. There can be only one primary @@ -2687,8 +2752,10 @@ def sample_batch_create_instances(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -2745,7 +2812,7 @@ def update_instance( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the parameters of a single Instance. @@ -2804,8 +2871,10 @@ def sample_update_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -2877,7 +2946,7 @@ def delete_instance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single Instance. @@ -2925,8 +2994,10 @@ def sample_delete_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -3002,7 +3073,7 @@ def failover_instance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Forces a Failover for a highly available instance. Failover promotes the HA standby instance as the new @@ -3053,8 +3124,10 @@ def sample_failover_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -3123,7 +3196,7 @@ def inject_fault( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Injects fault in an instance. Imperative only. @@ -3181,8 +3254,10 @@ def sample_inject_fault(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -3252,7 +3327,7 @@ def restart_instance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Restart an Instance in a cluster. Imperative only. @@ -3301,8 +3376,10 @@ def sample_restart_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -3374,7 +3451,7 @@ def execute_sql( password: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.ExecuteSqlResponse: r"""Executes a SQL statement in a database inside an AlloyDB instance. @@ -3458,8 +3535,10 @@ def sample_execute_sql(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1beta.types.ExecuteSqlResponse: @@ -3523,7 +3602,7 @@ def list_backups( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListBackupsPager: r"""Lists Backups in a given project and location. @@ -3568,8 +3647,10 @@ def sample_list_backups(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1beta.services.alloy_db_admin.pagers.ListBackupsPager: @@ -3641,7 +3722,7 @@ def get_backup( name: Optional[str] = None, retry: OptionalRetry = 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.Backup: r"""Gets details of a single Backup. @@ -3682,8 +3763,10 @@ def sample_get_backup(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1beta.types.Backup: @@ -3741,7 +3824,7 @@ def create_backup( backup_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 Backup in a given project and location. @@ -3803,8 +3886,10 @@ def sample_create_backup(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -3878,7 +3963,7 @@ def update_backup( 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 Backup. @@ -3937,8 +4022,10 @@ def sample_update_backup(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -4011,7 +4098,7 @@ def delete_backup( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 Backup. @@ -4059,8 +4146,10 @@ def sample_delete_backup(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -4138,7 +4227,7 @@ def list_supported_database_flags( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSupportedDatabaseFlagsPager: r"""Lists SupportedDatabaseFlags for a given project and location. @@ -4191,8 +4280,10 @@ def sample_list_supported_database_flags(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1beta.services.alloy_db_admin.pagers.ListSupportedDatabaseFlagsPager: @@ -4266,7 +4357,7 @@ def generate_client_certificate( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.GenerateClientCertificateResponse: r"""Generate a client certificate signed by a Cluster CA. The sole purpose of this endpoint is to support AlloyDB @@ -4319,8 +4410,10 @@ def sample_generate_client_certificate(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1beta.types.GenerateClientCertificateResponse: @@ -4380,7 +4473,7 @@ def get_connection_info( parent: Optional[str] = None, retry: OptionalRetry = 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.ConnectionInfo: r"""Get instance metadata used for a connection. @@ -4425,8 +4518,10 @@ def sample_get_connection_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.alloydb_v1beta.types.ConnectionInfo: @@ -4484,7 +4579,7 @@ def list_users( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListUsersPager: r"""Lists Users in a given project and location. @@ -4528,8 +4623,10 @@ def sample_list_users(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1beta.services.alloy_db_admin.pagers.ListUsersPager: @@ -4601,7 +4698,7 @@ def get_user( name: Optional[str] = None, retry: OptionalRetry = 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.User: r"""Gets details of a single User. @@ -4645,8 +4742,10 @@ def sample_get_user(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1beta.types.User: @@ -4704,7 +4803,7 @@ def create_user( user_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.User: r"""Creates a new User in a given project, location, and cluster. @@ -4759,8 +4858,10 @@ def sample_create_user(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1beta.types.User: @@ -4821,7 +4922,7 @@ def update_user( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.User: r"""Updates the parameters of a single User. @@ -4872,8 +4973,10 @@ def sample_update_user(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1beta.types.User: @@ -4933,7 +5036,7 @@ def delete_user( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 User. @@ -4974,8 +5077,10 @@ def sample_delete_user(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -5024,7 +5129,7 @@ def list_databases( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDatabasesPager: r"""Lists Databases in a given project and location. @@ -5069,8 +5174,10 @@ def sample_list_databases(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.alloydb_v1beta.services.alloy_db_admin.pagers.ListDatabasesPager: @@ -5154,7 +5261,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. @@ -5165,8 +5272,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. @@ -5207,7 +5316,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. @@ -5218,8 +5327,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. @@ -5260,7 +5371,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. @@ -5276,8 +5387,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 """ @@ -5314,7 +5427,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. @@ -5329,8 +5442,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 """ @@ -5367,7 +5482,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. @@ -5378,8 +5493,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. @@ -5420,7 +5537,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. @@ -5431,8 +5548,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-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/pagers.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/pagers.py index de85c7db6b00..b1436056b841 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/pagers.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/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.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 = 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 = service.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 = service.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 = service.ListBackupsRequest(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.ListBackupsRequest(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.ListSupportedDatabaseFlagsRequest(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.ListSupportedDatabaseFlagsRequest(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.ListUsersRequest(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.ListUsersRequest(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 = service.ListDatabasesRequest(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 = service.ListDatabasesRequest(request) diff --git a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/transports/grpc.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/transports/grpc.py index 0dab282cda4b..1be351650e5d 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/transports/grpc.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/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.alloydb_v1beta.types import resources, service from .base import DEFAULT_CLIENT_INFO, AlloyDBAdminTransport +try: + from google.api_core import client_logging # 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.alloydb.v1beta.AlloyDBAdmin", + "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.alloydb.v1beta.AlloyDBAdmin", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AlloyDBAdminGrpcTransport(AlloyDBAdminTransport): """gRPC backend transport for AlloyDBAdmin. @@ -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 @@ -273,7 +361,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.alloydb.v1beta.AlloyDBAdmin/ListClusters", request_serializer=service.ListClustersRequest.serialize, response_deserializer=service.ListClustersResponse.deserialize, @@ -297,7 +385,7 @@ def get_cluster(self) -> Callable[[service.GetClusterRequest], resources.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.alloydb.v1beta.AlloyDBAdmin/GetCluster", request_serializer=service.GetClusterRequest.serialize, response_deserializer=resources.Cluster.deserialize, @@ -324,7 +412,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.alloydb.v1beta.AlloyDBAdmin/CreateCluster", request_serializer=service.CreateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -350,7 +438,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.alloydb.v1beta.AlloyDBAdmin/UpdateCluster", request_serializer=service.UpdateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -377,7 +465,7 @@ def upgrade_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "upgrade_cluster" not in self._stubs: - self._stubs["upgrade_cluster"] = self.grpc_channel.unary_unary( + self._stubs["upgrade_cluster"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/UpgradeCluster", request_serializer=service.UpgradeClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -403,7 +491,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.alloydb.v1beta.AlloyDBAdmin/DeleteCluster", request_serializer=service.DeleteClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -432,7 +520,7 @@ def promote_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "promote_cluster" not in self._stubs: - self._stubs["promote_cluster"] = self.grpc_channel.unary_unary( + self._stubs["promote_cluster"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/PromoteCluster", request_serializer=service.PromoteClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -461,7 +549,7 @@ def switchover_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "switchover_cluster" not in self._stubs: - self._stubs["switchover_cluster"] = self.grpc_channel.unary_unary( + self._stubs["switchover_cluster"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/SwitchoverCluster", request_serializer=service.SwitchoverClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -490,7 +578,7 @@ def restore_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "restore_cluster" not in self._stubs: - self._stubs["restore_cluster"] = self.grpc_channel.unary_unary( + self._stubs["restore_cluster"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/RestoreCluster", request_serializer=service.RestoreClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -517,7 +605,7 @@ def create_secondary_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_secondary_cluster" not in self._stubs: - self._stubs["create_secondary_cluster"] = self.grpc_channel.unary_unary( + self._stubs["create_secondary_cluster"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/CreateSecondaryCluster", request_serializer=service.CreateSecondaryClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -543,7 +631,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.alloydb.v1beta.AlloyDBAdmin/ListInstances", request_serializer=service.ListInstancesRequest.serialize, response_deserializer=service.ListInstancesResponse.deserialize, @@ -569,7 +657,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.alloydb.v1beta.AlloyDBAdmin/GetInstance", request_serializer=service.GetInstanceRequest.serialize, response_deserializer=resources.Instance.deserialize, @@ -596,7 +684,7 @@ def create_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_instance" not in self._stubs: - self._stubs["create_instance"] = self.grpc_channel.unary_unary( + self._stubs["create_instance"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/CreateInstance", request_serializer=service.CreateInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -623,7 +711,7 @@ def create_secondary_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_secondary_instance" not in self._stubs: - self._stubs["create_secondary_instance"] = self.grpc_channel.unary_unary( + self._stubs["create_secondary_instance"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/CreateSecondaryInstance", request_serializer=service.CreateSecondaryInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -661,7 +749,7 @@ def batch_create_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_create_instances" not in self._stubs: - self._stubs["batch_create_instances"] = self.grpc_channel.unary_unary( + self._stubs["batch_create_instances"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/BatchCreateInstances", request_serializer=service.BatchCreateInstancesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -687,7 +775,7 @@ def update_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_instance" not in self._stubs: - self._stubs["update_instance"] = self.grpc_channel.unary_unary( + self._stubs["update_instance"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/UpdateInstance", request_serializer=service.UpdateInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -713,7 +801,7 @@ def delete_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_instance" not in self._stubs: - self._stubs["delete_instance"] = self.grpc_channel.unary_unary( + self._stubs["delete_instance"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/DeleteInstance", request_serializer=service.DeleteInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -741,7 +829,7 @@ def failover_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "failover_instance" not in self._stubs: - self._stubs["failover_instance"] = self.grpc_channel.unary_unary( + self._stubs["failover_instance"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/FailoverInstance", request_serializer=service.FailoverInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -768,7 +856,7 @@ def inject_fault( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "inject_fault" not in self._stubs: - self._stubs["inject_fault"] = self.grpc_channel.unary_unary( + self._stubs["inject_fault"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/InjectFault", request_serializer=service.InjectFaultRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -795,7 +883,7 @@ def restart_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "restart_instance" not in self._stubs: - self._stubs["restart_instance"] = self.grpc_channel.unary_unary( + self._stubs["restart_instance"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/RestartInstance", request_serializer=service.RestartInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -822,7 +910,7 @@ def execute_sql( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "execute_sql" not in self._stubs: - self._stubs["execute_sql"] = self.grpc_channel.unary_unary( + self._stubs["execute_sql"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/ExecuteSql", request_serializer=service.ExecuteSqlRequest.serialize, response_deserializer=service.ExecuteSqlResponse.deserialize, @@ -848,7 +936,7 @@ def list_backups( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_backups" not in self._stubs: - self._stubs["list_backups"] = self.grpc_channel.unary_unary( + self._stubs["list_backups"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/ListBackups", request_serializer=service.ListBackupsRequest.serialize, response_deserializer=service.ListBackupsResponse.deserialize, @@ -872,7 +960,7 @@ def get_backup(self) -> Callable[[service.GetBackupRequest], resources.Backup]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_backup" not in self._stubs: - self._stubs["get_backup"] = self.grpc_channel.unary_unary( + self._stubs["get_backup"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/GetBackup", request_serializer=service.GetBackupRequest.serialize, response_deserializer=resources.Backup.deserialize, @@ -898,7 +986,7 @@ def create_backup( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_backup" not in self._stubs: - self._stubs["create_backup"] = self.grpc_channel.unary_unary( + self._stubs["create_backup"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/CreateBackup", request_serializer=service.CreateBackupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -924,7 +1012,7 @@ def update_backup( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_backup" not in self._stubs: - self._stubs["update_backup"] = self.grpc_channel.unary_unary( + self._stubs["update_backup"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/UpdateBackup", request_serializer=service.UpdateBackupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -950,7 +1038,7 @@ def delete_backup( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_backup" not in self._stubs: - self._stubs["delete_backup"] = self.grpc_channel.unary_unary( + self._stubs["delete_backup"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/DeleteBackup", request_serializer=service.DeleteBackupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -982,7 +1070,7 @@ def list_supported_database_flags( if "list_supported_database_flags" not in self._stubs: self._stubs[ "list_supported_database_flags" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/ListSupportedDatabaseFlags", request_serializer=service.ListSupportedDatabaseFlagsRequest.serialize, response_deserializer=service.ListSupportedDatabaseFlagsResponse.deserialize, @@ -1017,7 +1105,9 @@ def generate_client_certificate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_client_certificate" not in self._stubs: - self._stubs["generate_client_certificate"] = self.grpc_channel.unary_unary( + self._stubs[ + "generate_client_certificate" + ] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/GenerateClientCertificate", request_serializer=service.GenerateClientCertificateRequest.serialize, response_deserializer=service.GenerateClientCertificateResponse.deserialize, @@ -1043,7 +1133,7 @@ def get_connection_info( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_connection_info" not in self._stubs: - self._stubs["get_connection_info"] = self.grpc_channel.unary_unary( + self._stubs["get_connection_info"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/GetConnectionInfo", request_serializer=service.GetConnectionInfoRequest.serialize, response_deserializer=resources.ConnectionInfo.deserialize, @@ -1069,7 +1159,7 @@ def list_users( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_users" not in self._stubs: - self._stubs["list_users"] = self.grpc_channel.unary_unary( + self._stubs["list_users"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/ListUsers", request_serializer=service.ListUsersRequest.serialize, response_deserializer=service.ListUsersResponse.deserialize, @@ -1093,7 +1183,7 @@ def get_user(self) -> Callable[[service.GetUserRequest], resources.User]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_user" not in self._stubs: - self._stubs["get_user"] = self.grpc_channel.unary_unary( + self._stubs["get_user"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/GetUser", request_serializer=service.GetUserRequest.serialize, response_deserializer=resources.User.deserialize, @@ -1118,7 +1208,7 @@ def create_user(self) -> Callable[[service.CreateUserRequest], resources.User]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_user" not in self._stubs: - self._stubs["create_user"] = self.grpc_channel.unary_unary( + self._stubs["create_user"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/CreateUser", request_serializer=service.CreateUserRequest.serialize, response_deserializer=resources.User.deserialize, @@ -1142,7 +1232,7 @@ def update_user(self) -> Callable[[service.UpdateUserRequest], resources.User]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_user" not in self._stubs: - self._stubs["update_user"] = self.grpc_channel.unary_unary( + self._stubs["update_user"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/UpdateUser", request_serializer=service.UpdateUserRequest.serialize, response_deserializer=resources.User.deserialize, @@ -1166,7 +1256,7 @@ def delete_user(self) -> Callable[[service.DeleteUserRequest], empty_pb2.Empty]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_user" not in self._stubs: - self._stubs["delete_user"] = self.grpc_channel.unary_unary( + self._stubs["delete_user"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/DeleteUser", request_serializer=service.DeleteUserRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1192,7 +1282,7 @@ def list_databases( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_databases" not in self._stubs: - self._stubs["list_databases"] = self.grpc_channel.unary_unary( + self._stubs["list_databases"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/ListDatabases", request_serializer=service.ListDatabasesRequest.serialize, response_deserializer=service.ListDatabasesResponse.deserialize, @@ -1200,7 +1290,7 @@ def list_databases( return self._stubs["list_databases"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -1212,7 +1302,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, @@ -1229,7 +1319,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, @@ -1246,7 +1336,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, @@ -1265,7 +1355,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, @@ -1284,7 +1374,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, @@ -1301,7 +1391,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-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/transports/grpc_asyncio.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/transports/grpc_asyncio.py index 5b7012e7a607..001b50edbc30 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/transports/grpc_asyncio.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/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.alloydb_v1beta.types import resources, service from .base import DEFAULT_CLIENT_INFO, AlloyDBAdminTransport from .grpc import AlloyDBAdminGrpcTransport +try: + from google.api_core import client_logging # 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.alloydb.v1beta.AlloyDBAdmin", + "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.alloydb.v1beta.AlloyDBAdmin", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AlloyDBAdminGrpcAsyncIOTransport(AlloyDBAdminTransport): """gRPC AsyncIO backend transport for AlloyDBAdmin. @@ -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. @@ -285,7 +370,7 @@ def list_clusters( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_clusters" not in self._stubs: - self._stubs["list_clusters"] = self.grpc_channel.unary_unary( + self._stubs["list_clusters"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/ListClusters", request_serializer=service.ListClustersRequest.serialize, response_deserializer=service.ListClustersResponse.deserialize, @@ -311,7 +396,7 @@ def get_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_cluster" not in self._stubs: - self._stubs["get_cluster"] = self.grpc_channel.unary_unary( + self._stubs["get_cluster"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/GetCluster", request_serializer=service.GetClusterRequest.serialize, response_deserializer=resources.Cluster.deserialize, @@ -338,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.alloydb.v1beta.AlloyDBAdmin/CreateCluster", request_serializer=service.CreateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -364,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.alloydb.v1beta.AlloyDBAdmin/UpdateCluster", request_serializer=service.UpdateClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -391,7 +476,7 @@ def upgrade_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "upgrade_cluster" not in self._stubs: - self._stubs["upgrade_cluster"] = self.grpc_channel.unary_unary( + self._stubs["upgrade_cluster"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/UpgradeCluster", request_serializer=service.UpgradeClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -417,7 +502,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.alloydb.v1beta.AlloyDBAdmin/DeleteCluster", request_serializer=service.DeleteClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -446,7 +531,7 @@ def promote_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "promote_cluster" not in self._stubs: - self._stubs["promote_cluster"] = self.grpc_channel.unary_unary( + self._stubs["promote_cluster"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/PromoteCluster", request_serializer=service.PromoteClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -477,7 +562,7 @@ def switchover_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "switchover_cluster" not in self._stubs: - self._stubs["switchover_cluster"] = self.grpc_channel.unary_unary( + self._stubs["switchover_cluster"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/SwitchoverCluster", request_serializer=service.SwitchoverClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -506,7 +591,7 @@ def restore_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "restore_cluster" not in self._stubs: - self._stubs["restore_cluster"] = self.grpc_channel.unary_unary( + self._stubs["restore_cluster"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/RestoreCluster", request_serializer=service.RestoreClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -535,7 +620,7 @@ def create_secondary_cluster( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_secondary_cluster" not in self._stubs: - self._stubs["create_secondary_cluster"] = self.grpc_channel.unary_unary( + self._stubs["create_secondary_cluster"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/CreateSecondaryCluster", request_serializer=service.CreateSecondaryClusterRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -563,7 +648,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.alloydb.v1beta.AlloyDBAdmin/ListInstances", request_serializer=service.ListInstancesRequest.serialize, response_deserializer=service.ListInstancesResponse.deserialize, @@ -589,7 +674,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.alloydb.v1beta.AlloyDBAdmin/GetInstance", request_serializer=service.GetInstanceRequest.serialize, response_deserializer=resources.Instance.deserialize, @@ -616,7 +701,7 @@ def create_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_instance" not in self._stubs: - self._stubs["create_instance"] = self.grpc_channel.unary_unary( + self._stubs["create_instance"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/CreateInstance", request_serializer=service.CreateInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -645,7 +730,7 @@ def create_secondary_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_secondary_instance" not in self._stubs: - self._stubs["create_secondary_instance"] = self.grpc_channel.unary_unary( + self._stubs["create_secondary_instance"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/CreateSecondaryInstance", request_serializer=service.CreateSecondaryInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -685,7 +770,7 @@ def batch_create_instances( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_create_instances" not in self._stubs: - self._stubs["batch_create_instances"] = self.grpc_channel.unary_unary( + self._stubs["batch_create_instances"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/BatchCreateInstances", request_serializer=service.BatchCreateInstancesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -711,7 +796,7 @@ def update_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_instance" not in self._stubs: - self._stubs["update_instance"] = self.grpc_channel.unary_unary( + self._stubs["update_instance"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/UpdateInstance", request_serializer=service.UpdateInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -737,7 +822,7 @@ def delete_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_instance" not in self._stubs: - self._stubs["delete_instance"] = self.grpc_channel.unary_unary( + self._stubs["delete_instance"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/DeleteInstance", request_serializer=service.DeleteInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -767,7 +852,7 @@ def failover_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "failover_instance" not in self._stubs: - self._stubs["failover_instance"] = self.grpc_channel.unary_unary( + self._stubs["failover_instance"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/FailoverInstance", request_serializer=service.FailoverInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -794,7 +879,7 @@ def inject_fault( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "inject_fault" not in self._stubs: - self._stubs["inject_fault"] = self.grpc_channel.unary_unary( + self._stubs["inject_fault"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/InjectFault", request_serializer=service.InjectFaultRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -823,7 +908,7 @@ def restart_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "restart_instance" not in self._stubs: - self._stubs["restart_instance"] = self.grpc_channel.unary_unary( + self._stubs["restart_instance"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/RestartInstance", request_serializer=service.RestartInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -850,7 +935,7 @@ def execute_sql( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "execute_sql" not in self._stubs: - self._stubs["execute_sql"] = self.grpc_channel.unary_unary( + self._stubs["execute_sql"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/ExecuteSql", request_serializer=service.ExecuteSqlRequest.serialize, response_deserializer=service.ExecuteSqlResponse.deserialize, @@ -876,7 +961,7 @@ def list_backups( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_backups" not in self._stubs: - self._stubs["list_backups"] = self.grpc_channel.unary_unary( + self._stubs["list_backups"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/ListBackups", request_serializer=service.ListBackupsRequest.serialize, response_deserializer=service.ListBackupsResponse.deserialize, @@ -902,7 +987,7 @@ def get_backup( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_backup" not in self._stubs: - self._stubs["get_backup"] = self.grpc_channel.unary_unary( + self._stubs["get_backup"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/GetBackup", request_serializer=service.GetBackupRequest.serialize, response_deserializer=resources.Backup.deserialize, @@ -928,7 +1013,7 @@ def create_backup( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_backup" not in self._stubs: - self._stubs["create_backup"] = self.grpc_channel.unary_unary( + self._stubs["create_backup"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/CreateBackup", request_serializer=service.CreateBackupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -954,7 +1039,7 @@ def update_backup( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_backup" not in self._stubs: - self._stubs["update_backup"] = self.grpc_channel.unary_unary( + self._stubs["update_backup"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/UpdateBackup", request_serializer=service.UpdateBackupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -980,7 +1065,7 @@ def delete_backup( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_backup" not in self._stubs: - self._stubs["delete_backup"] = self.grpc_channel.unary_unary( + self._stubs["delete_backup"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/DeleteBackup", request_serializer=service.DeleteBackupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1012,7 +1097,7 @@ def list_supported_database_flags( if "list_supported_database_flags" not in self._stubs: self._stubs[ "list_supported_database_flags" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/ListSupportedDatabaseFlags", request_serializer=service.ListSupportedDatabaseFlagsRequest.serialize, response_deserializer=service.ListSupportedDatabaseFlagsResponse.deserialize, @@ -1047,7 +1132,9 @@ def generate_client_certificate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "generate_client_certificate" not in self._stubs: - self._stubs["generate_client_certificate"] = self.grpc_channel.unary_unary( + self._stubs[ + "generate_client_certificate" + ] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/GenerateClientCertificate", request_serializer=service.GenerateClientCertificateRequest.serialize, response_deserializer=service.GenerateClientCertificateResponse.deserialize, @@ -1075,7 +1162,7 @@ def get_connection_info( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_connection_info" not in self._stubs: - self._stubs["get_connection_info"] = self.grpc_channel.unary_unary( + self._stubs["get_connection_info"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/GetConnectionInfo", request_serializer=service.GetConnectionInfoRequest.serialize, response_deserializer=resources.ConnectionInfo.deserialize, @@ -1101,7 +1188,7 @@ def list_users( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_users" not in self._stubs: - self._stubs["list_users"] = self.grpc_channel.unary_unary( + self._stubs["list_users"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/ListUsers", request_serializer=service.ListUsersRequest.serialize, response_deserializer=service.ListUsersResponse.deserialize, @@ -1125,7 +1212,7 @@ def get_user(self) -> Callable[[service.GetUserRequest], Awaitable[resources.Use # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_user" not in self._stubs: - self._stubs["get_user"] = self.grpc_channel.unary_unary( + self._stubs["get_user"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/GetUser", request_serializer=service.GetUserRequest.serialize, response_deserializer=resources.User.deserialize, @@ -1152,7 +1239,7 @@ def create_user( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_user" not in self._stubs: - self._stubs["create_user"] = self.grpc_channel.unary_unary( + self._stubs["create_user"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/CreateUser", request_serializer=service.CreateUserRequest.serialize, response_deserializer=resources.User.deserialize, @@ -1178,7 +1265,7 @@ def update_user( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_user" not in self._stubs: - self._stubs["update_user"] = self.grpc_channel.unary_unary( + self._stubs["update_user"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/UpdateUser", request_serializer=service.UpdateUserRequest.serialize, response_deserializer=resources.User.deserialize, @@ -1204,7 +1291,7 @@ def delete_user( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_user" not in self._stubs: - self._stubs["delete_user"] = self.grpc_channel.unary_unary( + self._stubs["delete_user"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/DeleteUser", request_serializer=service.DeleteUserRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1232,7 +1319,7 @@ def list_databases( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_databases" not in self._stubs: - self._stubs["list_databases"] = self.grpc_channel.unary_unary( + self._stubs["list_databases"] = self._logged_channel.unary_unary( "/google.cloud.alloydb.v1beta.AlloyDBAdmin/ListDatabases", request_serializer=service.ListDatabasesRequest.serialize, response_deserializer=service.ListDatabasesResponse.deserialize, @@ -1563,7 +1650,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: @@ -1579,7 +1666,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, @@ -1596,7 +1683,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, @@ -1613,7 +1700,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, @@ -1632,7 +1719,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, @@ -1651,7 +1738,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, @@ -1668,7 +1755,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-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/transports/rest.py b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/transports/rest.py index 91964a1c55e8..aca2fbca3004 100644 --- a/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/transports/rest.py +++ b/packages/google-cloud-alloydb/google/cloud/alloydb_v1beta/services/alloy_db_admin/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, @@ -350,8 +358,10 @@ def post_upgrade_cluster(self, response): def pre_batch_create_instances( self, request: service.BatchCreateInstancesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.BatchCreateInstancesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.BatchCreateInstancesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for batch_create_instances Override in a subclass to manipulate the request or metadata @@ -371,8 +381,10 @@ def post_batch_create_instances( return response def pre_create_backup( - self, request: service.CreateBackupRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.CreateBackupRequest, Sequence[Tuple[str, str]]]: + self, + request: service.CreateBackupRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.CreateBackupRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_backup Override in a subclass to manipulate the request or metadata @@ -392,8 +404,10 @@ def post_create_backup( return response def pre_create_cluster( - self, request: service.CreateClusterRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.CreateClusterRequest, Sequence[Tuple[str, str]]]: + self, + request: service.CreateClusterRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.CreateClusterRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_cluster Override in a subclass to manipulate the request or metadata @@ -415,8 +429,8 @@ def post_create_cluster( def pre_create_instance( self, request: service.CreateInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.CreateInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.CreateInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_instance Override in a subclass to manipulate the request or metadata @@ -438,8 +452,10 @@ def post_create_instance( def pre_create_secondary_cluster( self, request: service.CreateSecondaryClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.CreateSecondaryClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.CreateSecondaryClusterRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_secondary_cluster Override in a subclass to manipulate the request or metadata @@ -461,8 +477,10 @@ def post_create_secondary_cluster( def pre_create_secondary_instance( self, request: service.CreateSecondaryInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.CreateSecondaryInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.CreateSecondaryInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_secondary_instance Override in a subclass to manipulate the request or metadata @@ -482,8 +500,10 @@ def post_create_secondary_instance( return response def pre_create_user( - self, request: service.CreateUserRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.CreateUserRequest, Sequence[Tuple[str, str]]]: + self, + request: service.CreateUserRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.CreateUserRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_user Override in a subclass to manipulate the request or metadata @@ -501,8 +521,10 @@ def post_create_user(self, response: resources.User) -> resources.User: return response def pre_delete_backup( - self, request: service.DeleteBackupRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.DeleteBackupRequest, Sequence[Tuple[str, str]]]: + self, + request: service.DeleteBackupRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.DeleteBackupRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_backup Override in a subclass to manipulate the request or metadata @@ -522,8 +544,10 @@ def post_delete_backup( return response def pre_delete_cluster( - self, request: service.DeleteClusterRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.DeleteClusterRequest, Sequence[Tuple[str, str]]]: + self, + request: service.DeleteClusterRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.DeleteClusterRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_cluster Override in a subclass to manipulate the request or metadata @@ -545,8 +569,8 @@ def post_delete_cluster( def pre_delete_instance( self, request: service.DeleteInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.DeleteInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.DeleteInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_instance Override in a subclass to manipulate the request or metadata @@ -566,8 +590,10 @@ def post_delete_instance( return response def pre_delete_user( - self, request: service.DeleteUserRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.DeleteUserRequest, Sequence[Tuple[str, str]]]: + self, + request: service.DeleteUserRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.DeleteUserRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_user Override in a subclass to manipulate the request or metadata @@ -576,8 +602,10 @@ def pre_delete_user( return request, metadata def pre_execute_sql( - self, request: service.ExecuteSqlRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ExecuteSqlRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ExecuteSqlRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ExecuteSqlRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for execute_sql Override in a subclass to manipulate the request or metadata @@ -599,8 +627,10 @@ def post_execute_sql( def pre_failover_instance( self, request: service.FailoverInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.FailoverInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.FailoverInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for failover_instance Override in a subclass to manipulate the request or metadata @@ -622,8 +652,11 @@ def post_failover_instance( def pre_generate_client_certificate( self, request: service.GenerateClientCertificateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.GenerateClientCertificateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.GenerateClientCertificateRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for generate_client_certificate Override in a subclass to manipulate the request or metadata @@ -643,8 +676,10 @@ def post_generate_client_certificate( return response def pre_get_backup( - self, request: service.GetBackupRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetBackupRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetBackupRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetBackupRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_backup Override in a subclass to manipulate the request or metadata @@ -662,8 +697,10 @@ def post_get_backup(self, response: resources.Backup) -> resources.Backup: return response def pre_get_cluster( - self, request: service.GetClusterRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetClusterRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetClusterRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetClusterRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_cluster Override in a subclass to manipulate the request or metadata @@ -683,8 +720,10 @@ def post_get_cluster(self, response: resources.Cluster) -> resources.Cluster: def pre_get_connection_info( self, request: service.GetConnectionInfoRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.GetConnectionInfoRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.GetConnectionInfoRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_connection_info Override in a subclass to manipulate the request or metadata @@ -704,8 +743,10 @@ def post_get_connection_info( return response def pre_get_instance( - self, request: service.GetInstanceRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetInstanceRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetInstanceRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_instance Override in a subclass to manipulate the request or metadata @@ -723,8 +764,10 @@ def post_get_instance(self, response: resources.Instance) -> resources.Instance: return response def pre_get_user( - self, request: service.GetUserRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetUserRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetUserRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetUserRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_user Override in a subclass to manipulate the request or metadata @@ -742,8 +785,10 @@ def post_get_user(self, response: resources.User) -> resources.User: return response def pre_inject_fault( - self, request: service.InjectFaultRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.InjectFaultRequest, Sequence[Tuple[str, str]]]: + self, + request: service.InjectFaultRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.InjectFaultRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for inject_fault Override in a subclass to manipulate the request or metadata @@ -763,8 +808,10 @@ def post_inject_fault( return response def pre_list_backups( - self, request: service.ListBackupsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ListBackupsRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ListBackupsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListBackupsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_backups Override in a subclass to manipulate the request or metadata @@ -784,8 +831,10 @@ def post_list_backups( return response def pre_list_clusters( - self, request: service.ListClustersRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ListClustersRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ListClustersRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListClustersRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_clusters Override in a subclass to manipulate the request or metadata @@ -805,8 +854,10 @@ def post_list_clusters( return response def pre_list_databases( - self, request: service.ListDatabasesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ListDatabasesRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ListDatabasesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListDatabasesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_databases Override in a subclass to manipulate the request or metadata @@ -826,8 +877,10 @@ def post_list_databases( return response def pre_list_instances( - self, request: service.ListInstancesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ListInstancesRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ListInstancesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListInstancesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_instances Override in a subclass to manipulate the request or metadata @@ -849,8 +902,11 @@ def post_list_instances( def pre_list_supported_database_flags( self, request: service.ListSupportedDatabaseFlagsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.ListSupportedDatabaseFlagsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.ListSupportedDatabaseFlagsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_supported_database_flags Override in a subclass to manipulate the request or metadata @@ -870,8 +926,10 @@ def post_list_supported_database_flags( return response def pre_list_users( - self, request: service.ListUsersRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ListUsersRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ListUsersRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListUsersRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_users Override in a subclass to manipulate the request or metadata @@ -893,8 +951,8 @@ def post_list_users( def pre_promote_cluster( self, request: service.PromoteClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.PromoteClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.PromoteClusterRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for promote_cluster Override in a subclass to manipulate the request or metadata @@ -916,8 +974,8 @@ def post_promote_cluster( def pre_restart_instance( self, request: service.RestartInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.RestartInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.RestartInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for restart_instance Override in a subclass to manipulate the request or metadata @@ -939,8 +997,8 @@ def post_restart_instance( def pre_restore_cluster( self, request: service.RestoreClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.RestoreClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.RestoreClusterRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for restore_cluster Override in a subclass to manipulate the request or metadata @@ -962,8 +1020,10 @@ def post_restore_cluster( def pre_switchover_cluster( self, request: service.SwitchoverClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.SwitchoverClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.SwitchoverClusterRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for switchover_cluster Override in a subclass to manipulate the request or metadata @@ -983,8 +1043,10 @@ def post_switchover_cluster( return response def pre_update_backup( - self, request: service.UpdateBackupRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.UpdateBackupRequest, Sequence[Tuple[str, str]]]: + self, + request: service.UpdateBackupRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.UpdateBackupRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_backup Override in a subclass to manipulate the request or metadata @@ -1004,8 +1066,10 @@ def post_update_backup( return response def pre_update_cluster( - self, request: service.UpdateClusterRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.UpdateClusterRequest, Sequence[Tuple[str, str]]]: + self, + request: service.UpdateClusterRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.UpdateClusterRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_cluster Override in a subclass to manipulate the request or metadata @@ -1027,8 +1091,8 @@ def post_update_cluster( def pre_update_instance( self, request: service.UpdateInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.UpdateInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.UpdateInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_instance Override in a subclass to manipulate the request or metadata @@ -1048,8 +1112,10 @@ def post_update_instance( return response def pre_update_user( - self, request: service.UpdateUserRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.UpdateUserRequest, Sequence[Tuple[str, str]]]: + self, + request: service.UpdateUserRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.UpdateUserRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_user Override in a subclass to manipulate the request or metadata @@ -1069,8 +1135,8 @@ def post_update_user(self, response: resources.User) -> resources.User: def pre_upgrade_cluster( self, request: service.UpgradeClusterRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.UpgradeClusterRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.UpgradeClusterRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for upgrade_cluster Override in a subclass to manipulate the request or metadata @@ -1092,8 +1158,10 @@ def post_upgrade_cluster( 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 @@ -1115,8 +1183,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 @@ -1138,8 +1208,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 @@ -1159,8 +1231,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 @@ -1180,8 +1254,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 @@ -1203,8 +1279,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 @@ -1398,7 +1476,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the batch create instances method over HTTP. @@ -1409,8 +1487,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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 +1503,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseBatchCreateInstances._get_http_options() ) + request, metadata = self._interceptor.pre_batch_create_instances( request, metadata ) @@ -1439,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.alloydb_v1beta.AlloyDBAdminClient.BatchCreateInstances", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "BatchCreateInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._BatchCreateInstances._get_response( self._host, @@ -1458,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_batch_create_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.alloydb_v1beta.AlloyDBAdminClient.batch_create_instances", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "BatchCreateInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateBackup( @@ -1496,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create backup method over HTTP. @@ -1506,8 +1636,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1520,6 +1652,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseCreateBackup._get_http_options() ) + request, metadata = self._interceptor.pre_create_backup(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseCreateBackup._get_transcoded_request( http_options, request @@ -1538,6 +1671,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.CreateBackup", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "CreateBackup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._CreateBackup._get_response( self._host, @@ -1557,7 +1717,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_backup(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1beta.AlloyDBAdminClient.create_backup", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "CreateBackup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateCluster( @@ -1595,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 cluster method over HTTP. @@ -1605,8 +1787,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1619,6 +1803,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseCreateCluster._get_http_options() ) + request, metadata = self._interceptor.pre_create_cluster(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseCreateCluster._get_transcoded_request( http_options, request @@ -1633,6 +1818,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.CreateCluster", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "CreateCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._CreateCluster._get_response( self._host, @@ -1652,7 +1864,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.alloydb_v1beta.AlloyDBAdminClient.create_cluster", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "CreateCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateInstance( @@ -1690,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 create instance method over HTTP. @@ -1700,8 +1934,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1714,6 +1950,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseCreateInstance._get_http_options() ) + request, metadata = self._interceptor.pre_create_instance(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseCreateInstance._get_transcoded_request( http_options, request @@ -1728,6 +1965,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.CreateInstance", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "CreateInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._CreateInstance._get_response( self._host, @@ -1747,7 +2011,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_instance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1beta.AlloyDBAdminClient.create_instance", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "CreateInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSecondaryCluster( @@ -1785,7 +2071,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 secondary cluster method over HTTP. @@ -1795,8 +2081,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1809,6 +2097,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseCreateSecondaryCluster._get_http_options() ) + request, metadata = self._interceptor.pre_create_secondary_cluster( request, metadata ) @@ -1825,6 +2114,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.CreateSecondaryCluster", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "CreateSecondaryCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._CreateSecondaryCluster._get_response( self._host, @@ -1844,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_create_secondary_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.alloydb_v1beta.AlloyDBAdminClient.create_secondary_cluster", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "CreateSecondaryCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSecondaryInstance( @@ -1883,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 create secondary instance method over HTTP. @@ -1894,8 +2232,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1908,6 +2248,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseCreateSecondaryInstance._get_http_options() ) + request, metadata = self._interceptor.pre_create_secondary_instance( request, metadata ) @@ -1924,6 +2265,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.CreateSecondaryInstance", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "CreateSecondaryInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._CreateSecondaryInstance._get_response( self._host, @@ -1943,7 +2311,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_secondary_instance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1beta.AlloyDBAdminClient.create_secondary_instance", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "CreateSecondaryInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateUser( @@ -1981,7 +2371,7 @@ 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.User: r"""Call the create user method over HTTP. @@ -1991,8 +2381,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.User: @@ -2002,6 +2394,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseCreateUser._get_http_options() ) + request, metadata = self._interceptor.pre_create_user(request, metadata) transcoded_request = ( _BaseAlloyDBAdminRestTransport._BaseCreateUser._get_transcoded_request( @@ -2022,6 +2415,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.CreateUser", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "CreateUser", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._CreateUser._get_response( self._host, @@ -2043,7 +2463,29 @@ def __call__( pb_resp = resources.User.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_user(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.User.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1beta.AlloyDBAdminClient.create_user", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "CreateUser", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteBackup( @@ -2080,7 +2522,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 backup method over HTTP. @@ -2090,8 +2532,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2104,6 +2548,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseDeleteBackup._get_http_options() ) + request, metadata = self._interceptor.pre_delete_backup(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseDeleteBackup._get_transcoded_request( http_options, request @@ -2116,6 +2561,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.DeleteBackup", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "DeleteBackup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._DeleteBackup._get_response( self._host, @@ -2134,7 +2606,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_backup(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1beta.AlloyDBAdminClient.delete_backup", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "DeleteBackup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteCluster( @@ -2171,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete cluster method over HTTP. @@ -2181,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: ~.operations_pb2.Operation: @@ -2195,6 +2691,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseDeleteCluster._get_http_options() ) + request, metadata = self._interceptor.pre_delete_cluster(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseDeleteCluster._get_transcoded_request( http_options, request @@ -2205,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.alloydb_v1beta.AlloyDBAdminClient.DeleteCluster", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "DeleteCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._DeleteCluster._get_response( self._host, @@ -2223,7 +2747,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.alloydb_v1beta.AlloyDBAdminClient.delete_cluster", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "DeleteCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteInstance( @@ -2260,7 +2806,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete instance method over HTTP. @@ -2270,8 +2816,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2284,6 +2832,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseDeleteInstance._get_http_options() ) + request, metadata = self._interceptor.pre_delete_instance(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseDeleteInstance._get_transcoded_request( http_options, request @@ -2294,6 +2843,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.DeleteInstance", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "DeleteInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._DeleteInstance._get_response( self._host, @@ -2312,7 +2888,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_instance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1beta.AlloyDBAdminClient.delete_instance", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "DeleteInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteUser( @@ -2349,7 +2947,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete user method over HTTP. @@ -2359,13 +2957,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 = ( _BaseAlloyDBAdminRestTransport._BaseDeleteUser._get_http_options() ) + request, metadata = self._interceptor.pre_delete_user(request, metadata) transcoded_request = ( _BaseAlloyDBAdminRestTransport._BaseDeleteUser._get_transcoded_request( @@ -2380,6 +2981,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.DeleteUser", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "DeleteUser", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._DeleteUser._get_response( self._host, @@ -2430,7 +3058,7 @@ 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.ExecuteSqlResponse: r"""Call the execute sql method over HTTP. @@ -2440,8 +3068,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ExecuteSqlResponse: @@ -2451,6 +3081,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseExecuteSql._get_http_options() ) + request, metadata = self._interceptor.pre_execute_sql(request, metadata) transcoded_request = ( _BaseAlloyDBAdminRestTransport._BaseExecuteSql._get_transcoded_request( @@ -2471,6 +3102,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.ExecuteSql", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "ExecuteSql", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._ExecuteSql._get_response( self._host, @@ -2492,7 +3150,29 @@ def __call__( pb_resp = service.ExecuteSqlResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_execute_sql(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ExecuteSqlResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1beta.AlloyDBAdminClient.execute_sql", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "ExecuteSql", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _FailoverInstance( @@ -2530,7 +3210,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the failover instance method over HTTP. @@ -2541,8 +3221,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2555,6 +3237,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseFailoverInstance._get_http_options() ) + request, metadata = self._interceptor.pre_failover_instance( request, metadata ) @@ -2571,6 +3254,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.FailoverInstance", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "FailoverInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._FailoverInstance._get_response( self._host, @@ -2590,7 +3300,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_failover_instance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1beta.AlloyDBAdminClient.failover_instance", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "FailoverInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GenerateClientCertificate( @@ -2629,7 +3361,7 @@ 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.GenerateClientCertificateResponse: r"""Call the generate client certificate method over HTTP. @@ -2642,8 +3374,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.GenerateClientCertificateResponse: @@ -2655,6 +3389,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseGenerateClientCertificate._get_http_options() ) + request, metadata = self._interceptor.pre_generate_client_certificate( request, metadata ) @@ -2671,6 +3406,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.GenerateClientCertificate", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "GenerateClientCertificate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AlloyDBAdminRestTransport._GenerateClientCertificate._get_response( @@ -2694,7 +3456,31 @@ def __call__( pb_resp = service.GenerateClientCertificateResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_generate_client_certificate(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + service.GenerateClientCertificateResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1beta.AlloyDBAdminClient.generate_client_certificate", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "GenerateClientCertificate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetBackup( @@ -2731,7 +3517,7 @@ 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.Backup: r"""Call the get backup method over HTTP. @@ -2741,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: ~.resources.Backup: @@ -2752,6 +3540,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseGetBackup._get_http_options() ) + request, metadata = self._interceptor.pre_get_backup(request, metadata) transcoded_request = ( _BaseAlloyDBAdminRestTransport._BaseGetBackup._get_transcoded_request( @@ -2766,6 +3555,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.GetBackup", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "GetBackup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._GetBackup._get_response( self._host, @@ -2786,7 +3602,29 @@ def __call__( pb_resp = resources.Backup.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_backup(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Backup.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1beta.AlloyDBAdminClient.get_backup", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "GetBackup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCluster( @@ -2823,7 +3661,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Cluster: r"""Call the get cluster method over HTTP. @@ -2833,8 +3671,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.resources.Cluster: @@ -2850,6 +3690,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseGetCluster._get_http_options() ) + request, metadata = self._interceptor.pre_get_cluster(request, metadata) transcoded_request = ( _BaseAlloyDBAdminRestTransport._BaseGetCluster._get_transcoded_request( @@ -2864,6 +3705,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.GetCluster", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "GetCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._GetCluster._get_response( self._host, @@ -2884,7 +3752,29 @@ def __call__( pb_resp = resources.Cluster.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_cluster(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Cluster.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1beta.AlloyDBAdminClient.get_cluster", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "GetCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetConnectionInfo( @@ -2921,7 +3811,7 @@ 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.ConnectionInfo: r"""Call the get connection info method over HTTP. @@ -2932,8 +3822,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ConnectionInfo: @@ -2945,6 +3837,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseGetConnectionInfo._get_http_options() ) + request, metadata = self._interceptor.pre_get_connection_info( request, metadata ) @@ -2957,6 +3850,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.GetConnectionInfo", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "GetConnectionInfo", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._GetConnectionInfo._get_response( self._host, @@ -2977,7 +3897,29 @@ def __call__( pb_resp = resources.ConnectionInfo.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_connection_info(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.ConnectionInfo.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1beta.AlloyDBAdminClient.get_connection_info", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "GetConnectionInfo", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetInstance( @@ -3014,7 +3956,7 @@ 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.Instance: r"""Call the get instance method over HTTP. @@ -3024,8 +3966,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.Instance: @@ -3039,6 +3983,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseGetInstance._get_http_options() ) + request, metadata = self._interceptor.pre_get_instance(request, metadata) transcoded_request = ( _BaseAlloyDBAdminRestTransport._BaseGetInstance._get_transcoded_request( @@ -3053,6 +3998,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.GetInstance", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "GetInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._GetInstance._get_response( self._host, @@ -3073,7 +4045,29 @@ def __call__( pb_resp = resources.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 = resources.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.alloydb_v1beta.AlloyDBAdminClient.get_instance", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "GetInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetUser(_BaseAlloyDBAdminRestTransport._BaseGetUser, AlloyDBAdminRestStub): @@ -3108,7 +4102,7 @@ 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.User: r"""Call the get user method over HTTP. @@ -3118,8 +4112,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.User: @@ -3129,6 +4125,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseGetUser._get_http_options() ) + request, metadata = self._interceptor.pre_get_user(request, metadata) transcoded_request = ( _BaseAlloyDBAdminRestTransport._BaseGetUser._get_transcoded_request( @@ -3143,6 +4140,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.GetUser", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "GetUser", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._GetUser._get_response( self._host, @@ -3163,7 +4187,29 @@ def __call__( pb_resp = resources.User.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_user(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.User.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1beta.AlloyDBAdminClient.get_user", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "GetUser", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _InjectFault( @@ -3201,7 +4247,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the inject fault method over HTTP. @@ -3212,8 +4258,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3226,6 +4274,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseInjectFault._get_http_options() ) + request, metadata = self._interceptor.pre_inject_fault(request, metadata) transcoded_request = ( _BaseAlloyDBAdminRestTransport._BaseInjectFault._get_transcoded_request( @@ -3246,6 +4295,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.InjectFault", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "InjectFault", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._InjectFault._get_response( self._host, @@ -3265,7 +4341,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_inject_fault(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1beta.AlloyDBAdminClient.inject_fault", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "InjectFault", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListBackups( @@ -3302,7 +4400,7 @@ 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.ListBackupsResponse: r"""Call the list backups method over HTTP. @@ -3313,8 +4411,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ListBackupsResponse: @@ -3326,6 +4426,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseListBackups._get_http_options() ) + request, metadata = self._interceptor.pre_list_backups(request, metadata) transcoded_request = ( _BaseAlloyDBAdminRestTransport._BaseListBackups._get_transcoded_request( @@ -3340,6 +4441,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.ListBackups", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "ListBackups", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._ListBackups._get_response( self._host, @@ -3360,7 +4488,29 @@ def __call__( pb_resp = service.ListBackupsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_backups(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListBackupsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1beta.AlloyDBAdminClient.list_backups", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "ListBackups", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListClusters( @@ -3397,7 +4547,7 @@ 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.ListClustersResponse: r"""Call the list clusters method over HTTP. @@ -3408,8 +4558,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ListClustersResponse: @@ -3421,6 +4573,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseListClusters._get_http_options() ) + request, metadata = self._interceptor.pre_list_clusters(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseListClusters._get_transcoded_request( http_options, request @@ -3433,6 +4586,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.ListClusters", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "ListClusters", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._ListClusters._get_response( self._host, @@ -3453,7 +4633,29 @@ def __call__( pb_resp = 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 = 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.alloydb_v1beta.AlloyDBAdminClient.list_clusters", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "ListClusters", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDatabases( @@ -3490,7 +4692,7 @@ 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.ListDatabasesResponse: r"""Call the list databases method over HTTP. @@ -3501,8 +4703,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.service.ListDatabasesResponse: @@ -3514,6 +4718,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseListDatabases._get_http_options() ) + request, metadata = self._interceptor.pre_list_databases(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseListDatabases._get_transcoded_request( http_options, request @@ -3524,6 +4729,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.ListDatabases", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "ListDatabases", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._ListDatabases._get_response( self._host, @@ -3544,7 +4776,29 @@ def __call__( pb_resp = service.ListDatabasesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_databases(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListDatabasesResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1beta.AlloyDBAdminClient.list_databases", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "ListDatabases", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListInstances( @@ -3581,7 +4835,7 @@ 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.ListInstancesResponse: r"""Call the list instances method over HTTP. @@ -3592,8 +4846,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ListInstancesResponse: @@ -3605,6 +4861,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseListInstances._get_http_options() ) + request, metadata = self._interceptor.pre_list_instances(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseListInstances._get_transcoded_request( http_options, request @@ -3615,6 +4872,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.ListInstances", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "ListInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._ListInstances._get_response( self._host, @@ -3635,7 +4919,29 @@ def __call__( pb_resp = service.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 = service.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.alloydb_v1beta.AlloyDBAdminClient.list_instances", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "ListInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSupportedDatabaseFlags( @@ -3673,7 +4979,7 @@ 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.ListSupportedDatabaseFlagsResponse: r"""Call the list supported database flags method over HTTP. @@ -3685,8 +4991,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ListSupportedDatabaseFlagsResponse: @@ -3698,6 +5006,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseListSupportedDatabaseFlags._get_http_options() ) + request, metadata = self._interceptor.pre_list_supported_database_flags( request, metadata ) @@ -3710,6 +5019,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.ListSupportedDatabaseFlags", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "ListSupportedDatabaseFlags", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AlloyDBAdminRestTransport._ListSupportedDatabaseFlags._get_response( @@ -3732,7 +5068,31 @@ def __call__( pb_resp = service.ListSupportedDatabaseFlagsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_supported_database_flags(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + service.ListSupportedDatabaseFlagsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1beta.AlloyDBAdminClient.list_supported_database_flags", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "ListSupportedDatabaseFlags", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListUsers( @@ -3769,7 +5129,7 @@ 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.ListUsersResponse: r"""Call the list users method over HTTP. @@ -3779,8 +5139,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ListUsersResponse: @@ -3790,6 +5152,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseListUsers._get_http_options() ) + request, metadata = self._interceptor.pre_list_users(request, metadata) transcoded_request = ( _BaseAlloyDBAdminRestTransport._BaseListUsers._get_transcoded_request( @@ -3804,6 +5167,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.ListUsers", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "ListUsers", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._ListUsers._get_response( self._host, @@ -3824,7 +5214,29 @@ def __call__( pb_resp = service.ListUsersResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_users(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListUsersResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1beta.AlloyDBAdminClient.list_users", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "ListUsers", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _PromoteCluster( @@ -3862,7 +5274,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the promote cluster method over HTTP. @@ -3872,8 +5284,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3886,6 +5300,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BasePromoteCluster._get_http_options() ) + request, metadata = self._interceptor.pre_promote_cluster(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BasePromoteCluster._get_transcoded_request( http_options, request @@ -3900,6 +5315,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.PromoteCluster", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "PromoteCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._PromoteCluster._get_response( self._host, @@ -3919,7 +5361,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_promote_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.alloydb_v1beta.AlloyDBAdminClient.promote_cluster", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "PromoteCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RestartInstance( @@ -3957,7 +5421,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the restart instance method over HTTP. @@ -3967,8 +5431,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3981,6 +5447,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseRestartInstance._get_http_options() ) + request, metadata = self._interceptor.pre_restart_instance( request, metadata ) @@ -3997,6 +5464,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.RestartInstance", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "RestartInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._RestartInstance._get_response( self._host, @@ -4016,7 +5510,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_restart_instance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1beta.AlloyDBAdminClient.restart_instance", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "RestartInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RestoreCluster( @@ -4054,7 +5570,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the restore cluster method over HTTP. @@ -4066,8 +5582,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -4080,6 +5598,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseRestoreCluster._get_http_options() ) + request, metadata = self._interceptor.pre_restore_cluster(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseRestoreCluster._get_transcoded_request( http_options, request @@ -4094,6 +5613,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.RestoreCluster", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "RestoreCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._RestoreCluster._get_response( self._host, @@ -4113,7 +5659,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_restore_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.alloydb_v1beta.AlloyDBAdminClient.restore_cluster", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "RestoreCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SwitchoverCluster( @@ -4151,7 +5719,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the switchover cluster method over HTTP. @@ -4162,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: ~.operations_pb2.Operation: @@ -4176,6 +5746,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseSwitchoverCluster._get_http_options() ) + request, metadata = self._interceptor.pre_switchover_cluster( request, metadata ) @@ -4192,6 +5763,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.SwitchoverCluster", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "SwitchoverCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._SwitchoverCluster._get_response( self._host, @@ -4211,7 +5809,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_switchover_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.alloydb_v1beta.AlloyDBAdminClient.switchover_cluster", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "SwitchoverCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateBackup( @@ -4249,7 +5869,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 backup method over HTTP. @@ -4259,8 +5879,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -4273,6 +5895,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseUpdateBackup._get_http_options() ) + request, metadata = self._interceptor.pre_update_backup(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseUpdateBackup._get_transcoded_request( http_options, request @@ -4291,6 +5914,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.UpdateBackup", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "UpdateBackup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._UpdateBackup._get_response( self._host, @@ -4310,7 +5960,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_backup(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1beta.AlloyDBAdminClient.update_backup", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "UpdateBackup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCluster( @@ -4348,7 +6020,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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. @@ -4358,8 +6030,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -4372,6 +6046,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseUpdateCluster._get_http_options() ) + request, metadata = self._interceptor.pre_update_cluster(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseUpdateCluster._get_transcoded_request( http_options, request @@ -4386,6 +6061,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.UpdateCluster", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "UpdateCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._UpdateCluster._get_response( self._host, @@ -4405,7 +6107,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.alloydb_v1beta.AlloyDBAdminClient.update_cluster", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "UpdateCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateInstance( @@ -4443,7 +6167,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update instance method over HTTP. @@ -4453,8 +6177,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -4467,6 +6193,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseUpdateInstance._get_http_options() ) + request, metadata = self._interceptor.pre_update_instance(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseUpdateInstance._get_transcoded_request( http_options, request @@ -4481,6 +6208,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.UpdateInstance", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "UpdateInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._UpdateInstance._get_response( self._host, @@ -4500,7 +6254,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_instance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1beta.AlloyDBAdminClient.update_instance", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "UpdateInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateUser( @@ -4538,7 +6314,7 @@ 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.User: r"""Call the update user method over HTTP. @@ -4548,8 +6324,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.User: @@ -4559,6 +6337,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseUpdateUser._get_http_options() ) + request, metadata = self._interceptor.pre_update_user(request, metadata) transcoded_request = ( _BaseAlloyDBAdminRestTransport._BaseUpdateUser._get_transcoded_request( @@ -4579,6 +6358,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.UpdateUser", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "UpdateUser", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._UpdateUser._get_response( self._host, @@ -4600,7 +6406,29 @@ def __call__( pb_resp = resources.User.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_user(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.User.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.alloydb_v1beta.AlloyDBAdminClient.update_user", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "UpdateUser", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpgradeCluster( @@ -4638,7 +6466,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 cluster method over HTTP. @@ -4648,8 +6476,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -4662,6 +6492,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseUpgradeCluster._get_http_options() ) + request, metadata = self._interceptor.pre_upgrade_cluster(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseUpgradeCluster._get_transcoded_request( http_options, request @@ -4676,6 +6507,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.UpgradeCluster", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "UpgradeCluster", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._UpgradeCluster._get_response( self._host, @@ -4695,7 +6553,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_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.alloydb_v1beta.AlloyDBAdminClient.upgrade_cluster", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "UpgradeCluster", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -5010,7 +6890,7 @@ 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. @@ -5020,8 +6900,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -5030,6 +6912,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseAlloyDBAdminRestTransport._BaseGetLocation._get_transcoded_request( @@ -5044,6 +6927,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.GetLocation", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._GetLocation._get_response( self._host, @@ -5063,6 +6973,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.alloydb_v1beta.AlloyDBAdminAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -5103,7 +7034,7 @@ 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. @@ -5113,8 +7044,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -5123,6 +7056,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -5133,6 +7067,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.ListLocations", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._ListLocations._get_response( self._host, @@ -5152,6 +7113,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.alloydb_v1beta.AlloyDBAdminAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -5192,7 +7174,7 @@ 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. @@ -5202,13 +7184,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 = ( _BaseAlloyDBAdminRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -5221,6 +7206,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.CancelOperation", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._CancelOperation._get_response( self._host, @@ -5276,7 +7288,7 @@ 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. @@ -5286,13 +7298,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 = ( _BaseAlloyDBAdminRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -5305,6 +7320,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._DeleteOperation._get_response( self._host, @@ -5360,7 +7402,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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. @@ -5370,8 +7412,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -5380,6 +7424,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -5392,6 +7437,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.GetOperation", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._GetOperation._get_response( self._host, @@ -5411,6 +7483,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.alloydb_v1beta.AlloyDBAdminAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -5451,7 +7544,7 @@ def __call__( *, 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. @@ -5461,8 +7554,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must 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. @@ -5471,6 +7566,7 @@ def __call__( http_options = ( _BaseAlloyDBAdminRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseAlloyDBAdminRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -5481,6 +7577,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.alloydb_v1beta.AlloyDBAdminClient.ListOperations", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AlloyDBAdminRestTransport._ListOperations._get_response( self._host, @@ -5500,6 +7623,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.alloydb_v1beta.AlloyDBAdminAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.alloydb.v1beta.AlloyDBAdmin", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-alloydb/samples/generated_samples/snippet_metadata_google.cloud.alloydb.v1.json b/packages/google-cloud-alloydb/samples/generated_samples/snippet_metadata_google.cloud.alloydb.v1.json index ba0a9bd4cff5..93784dc7f2da 100644 --- a/packages/google-cloud-alloydb/samples/generated_samples/snippet_metadata_google.cloud.alloydb.v1.json +++ b/packages/google-cloud-alloydb/samples/generated_samples/snippet_metadata_google.cloud.alloydb.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-alloydb", - "version": "0.4.0" + "version": "0.1.0" }, "snippets": [ { @@ -43,7 +43,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -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", @@ -296,7 +296,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -385,7 +385,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -473,7 +473,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", @@ -650,7 +650,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", @@ -827,7 +827,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -916,7 +916,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1004,7 +1004,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.cloud.alloydb_v1.types.User", @@ -1181,7 +1181,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1.types.User", @@ -1262,7 +1262,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1342,7 +1342,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", @@ -1503,7 +1503,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1584,7 +1584,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1664,7 +1664,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1745,7 +1745,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_user" @@ -1822,7 +1822,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_user" @@ -1916,7 +1916,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1.types.ExecuteSqlResponse", @@ -2012,7 +2012,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1.types.ExecuteSqlResponse", @@ -2093,7 +2093,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2173,7 +2173,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2254,7 +2254,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1.types.GenerateClientCertificateResponse", @@ -2334,7 +2334,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1.types.GenerateClientCertificateResponse", @@ -2415,7 +2415,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1.types.Backup", @@ -2495,7 +2495,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1.types.Backup", @@ -2576,7 +2576,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1.types.Cluster", @@ -2656,7 +2656,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1.types.Cluster", @@ -2737,7 +2737,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1.types.ConnectionInfo", @@ -2817,7 +2817,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1.types.ConnectionInfo", @@ -2898,7 +2898,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1.types.Instance", @@ -2978,7 +2978,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1.types.Instance", @@ -3059,7 +3059,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1.types.User", @@ -3139,7 +3139,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1.types.User", @@ -3224,7 +3224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3308,7 +3308,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3389,7 +3389,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1.services.alloy_db_admin.pagers.ListBackupsAsyncPager", @@ -3469,7 +3469,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1.services.alloy_db_admin.pagers.ListBackupsPager", @@ -3550,7 +3550,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1.services.alloy_db_admin.pagers.ListClustersAsyncPager", @@ -3630,7 +3630,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1.services.alloy_db_admin.pagers.ListClustersPager", @@ -3711,7 +3711,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1.services.alloy_db_admin.pagers.ListDatabasesAsyncPager", @@ -3791,7 +3791,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1.services.alloy_db_admin.pagers.ListDatabasesPager", @@ -3872,7 +3872,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1.services.alloy_db_admin.pagers.ListInstancesAsyncPager", @@ -3952,7 +3952,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1.services.alloy_db_admin.pagers.ListInstancesPager", @@ -4033,7 +4033,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1.services.alloy_db_admin.pagers.ListSupportedDatabaseFlagsAsyncPager", @@ -4113,7 +4113,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1.services.alloy_db_admin.pagers.ListSupportedDatabaseFlagsPager", @@ -4194,7 +4194,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1.services.alloy_db_admin.pagers.ListUsersAsyncPager", @@ -4274,7 +4274,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1.services.alloy_db_admin.pagers.ListUsersPager", @@ -4355,7 +4355,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4435,7 +4435,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4516,7 +4516,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4596,7 +4596,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4673,7 +4673,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4749,7 +4749,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4830,7 +4830,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4910,7 +4910,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4995,7 +4995,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5079,7 +5079,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -5164,7 +5164,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5248,7 +5248,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -5333,7 +5333,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5417,7 +5417,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -5502,7 +5502,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1.types.User", @@ -5586,7 +5586,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1.types.User", diff --git a/packages/google-cloud-alloydb/samples/generated_samples/snippet_metadata_google.cloud.alloydb.v1alpha.json b/packages/google-cloud-alloydb/samples/generated_samples/snippet_metadata_google.cloud.alloydb.v1alpha.json index 33d4ab89d6f1..0beca3926d06 100644 --- a/packages/google-cloud-alloydb/samples/generated_samples/snippet_metadata_google.cloud.alloydb.v1alpha.json +++ b/packages/google-cloud-alloydb/samples/generated_samples/snippet_metadata_google.cloud.alloydb.v1alpha.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-alloydb", - "version": "0.4.0" + "version": "0.1.0" }, "snippets": [ { @@ -43,7 +43,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -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", @@ -296,7 +296,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -385,7 +385,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -473,7 +473,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", @@ -650,7 +650,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", @@ -827,7 +827,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -916,7 +916,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1004,7 +1004,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.cloud.alloydb_v1alpha.types.User", @@ -1181,7 +1181,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1alpha.types.User", @@ -1262,7 +1262,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1342,7 +1342,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", @@ -1503,7 +1503,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1584,7 +1584,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1664,7 +1664,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1745,7 +1745,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_user" @@ -1822,7 +1822,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_user" @@ -1916,7 +1916,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1alpha.types.ExecuteSqlResponse", @@ -2012,7 +2012,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1alpha.types.ExecuteSqlResponse", @@ -2093,7 +2093,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2173,7 +2173,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2254,7 +2254,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1alpha.types.GenerateClientCertificateResponse", @@ -2334,7 +2334,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1alpha.types.GenerateClientCertificateResponse", @@ -2415,7 +2415,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1alpha.types.Backup", @@ -2495,7 +2495,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1alpha.types.Backup", @@ -2576,7 +2576,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1alpha.types.Cluster", @@ -2656,7 +2656,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1alpha.types.Cluster", @@ -2737,7 +2737,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1alpha.types.ConnectionInfo", @@ -2817,7 +2817,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1alpha.types.ConnectionInfo", @@ -2898,7 +2898,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1alpha.types.Instance", @@ -2978,7 +2978,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1alpha.types.Instance", @@ -3059,7 +3059,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1alpha.types.User", @@ -3139,7 +3139,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1alpha.types.User", @@ -3224,7 +3224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3308,7 +3308,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3389,7 +3389,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1alpha.services.alloy_db_admin.pagers.ListBackupsAsyncPager", @@ -3469,7 +3469,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1alpha.services.alloy_db_admin.pagers.ListBackupsPager", @@ -3550,7 +3550,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1alpha.services.alloy_db_admin.pagers.ListClustersAsyncPager", @@ -3630,7 +3630,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1alpha.services.alloy_db_admin.pagers.ListClustersPager", @@ -3711,7 +3711,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1alpha.services.alloy_db_admin.pagers.ListDatabasesAsyncPager", @@ -3791,7 +3791,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1alpha.services.alloy_db_admin.pagers.ListDatabasesPager", @@ -3872,7 +3872,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1alpha.services.alloy_db_admin.pagers.ListInstancesAsyncPager", @@ -3952,7 +3952,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1alpha.services.alloy_db_admin.pagers.ListInstancesPager", @@ -4033,7 +4033,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1alpha.services.alloy_db_admin.pagers.ListSupportedDatabaseFlagsAsyncPager", @@ -4113,7 +4113,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1alpha.services.alloy_db_admin.pagers.ListSupportedDatabaseFlagsPager", @@ -4194,7 +4194,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1alpha.services.alloy_db_admin.pagers.ListUsersAsyncPager", @@ -4274,7 +4274,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1alpha.services.alloy_db_admin.pagers.ListUsersPager", @@ -4355,7 +4355,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4435,7 +4435,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4516,7 +4516,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4596,7 +4596,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4673,7 +4673,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4749,7 +4749,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4830,7 +4830,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4910,7 +4910,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4995,7 +4995,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5079,7 +5079,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -5164,7 +5164,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5248,7 +5248,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -5333,7 +5333,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5417,7 +5417,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -5502,7 +5502,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1alpha.types.User", @@ -5586,7 +5586,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1alpha.types.User", @@ -5671,7 +5671,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5755,7 +5755,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-alloydb/samples/generated_samples/snippet_metadata_google.cloud.alloydb.v1beta.json b/packages/google-cloud-alloydb/samples/generated_samples/snippet_metadata_google.cloud.alloydb.v1beta.json index 3ad53914353d..696ffb3efe81 100644 --- a/packages/google-cloud-alloydb/samples/generated_samples/snippet_metadata_google.cloud.alloydb.v1beta.json +++ b/packages/google-cloud-alloydb/samples/generated_samples/snippet_metadata_google.cloud.alloydb.v1beta.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-alloydb", - "version": "0.4.0" + "version": "0.1.0" }, "snippets": [ { @@ -43,7 +43,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -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", @@ -296,7 +296,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -385,7 +385,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -473,7 +473,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", @@ -650,7 +650,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", @@ -827,7 +827,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -916,7 +916,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1004,7 +1004,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.cloud.alloydb_v1beta.types.User", @@ -1181,7 +1181,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1beta.types.User", @@ -1262,7 +1262,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1342,7 +1342,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", @@ -1503,7 +1503,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1584,7 +1584,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1664,7 +1664,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1745,7 +1745,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_user" @@ -1822,7 +1822,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_user" @@ -1916,7 +1916,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1beta.types.ExecuteSqlResponse", @@ -2012,7 +2012,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1beta.types.ExecuteSqlResponse", @@ -2093,7 +2093,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2173,7 +2173,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2254,7 +2254,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1beta.types.GenerateClientCertificateResponse", @@ -2334,7 +2334,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1beta.types.GenerateClientCertificateResponse", @@ -2415,7 +2415,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1beta.types.Backup", @@ -2495,7 +2495,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1beta.types.Backup", @@ -2576,7 +2576,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1beta.types.Cluster", @@ -2656,7 +2656,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1beta.types.Cluster", @@ -2737,7 +2737,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1beta.types.ConnectionInfo", @@ -2817,7 +2817,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1beta.types.ConnectionInfo", @@ -2898,7 +2898,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1beta.types.Instance", @@ -2978,7 +2978,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1beta.types.Instance", @@ -3059,7 +3059,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1beta.types.User", @@ -3139,7 +3139,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1beta.types.User", @@ -3224,7 +3224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3308,7 +3308,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3389,7 +3389,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1beta.services.alloy_db_admin.pagers.ListBackupsAsyncPager", @@ -3469,7 +3469,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1beta.services.alloy_db_admin.pagers.ListBackupsPager", @@ -3550,7 +3550,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1beta.services.alloy_db_admin.pagers.ListClustersAsyncPager", @@ -3630,7 +3630,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1beta.services.alloy_db_admin.pagers.ListClustersPager", @@ -3711,7 +3711,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1beta.services.alloy_db_admin.pagers.ListDatabasesAsyncPager", @@ -3791,7 +3791,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1beta.services.alloy_db_admin.pagers.ListDatabasesPager", @@ -3872,7 +3872,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1beta.services.alloy_db_admin.pagers.ListInstancesAsyncPager", @@ -3952,7 +3952,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1beta.services.alloy_db_admin.pagers.ListInstancesPager", @@ -4033,7 +4033,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1beta.services.alloy_db_admin.pagers.ListSupportedDatabaseFlagsAsyncPager", @@ -4113,7 +4113,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1beta.services.alloy_db_admin.pagers.ListSupportedDatabaseFlagsPager", @@ -4194,7 +4194,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1beta.services.alloy_db_admin.pagers.ListUsersAsyncPager", @@ -4274,7 +4274,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1beta.services.alloy_db_admin.pagers.ListUsersPager", @@ -4355,7 +4355,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4435,7 +4435,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4516,7 +4516,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4596,7 +4596,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4673,7 +4673,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4749,7 +4749,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4830,7 +4830,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4910,7 +4910,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4995,7 +4995,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5079,7 +5079,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -5164,7 +5164,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5248,7 +5248,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -5333,7 +5333,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5417,7 +5417,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -5502,7 +5502,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1beta.types.User", @@ -5586,7 +5586,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.alloydb_v1beta.types.User", @@ -5671,7 +5671,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5755,7 +5755,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-alloydb/tests/unit/gapic/alloydb_v1/test_alloy_db_admin.py b/packages/google-cloud-alloydb/tests/unit/gapic/alloydb_v1/test_alloy_db_admin.py index a86f8d80f942..d7254314ed4f 100644 --- a/packages/google-cloud-alloydb/tests/unit/gapic/alloydb_v1/test_alloy_db_admin.py +++ b/packages/google-cloud-alloydb/tests/unit/gapic/alloydb_v1/test_alloy_db_admin.py @@ -13891,6 +13891,7 @@ def test_list_clusters_rest_required_fields(request_type=service.ListClustersReq response_value._content = json_return_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) @@ -13946,6 +13947,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) @@ -14137,6 +14139,7 @@ def test_get_cluster_rest_required_fields(request_type=service.GetClusterRequest response_value._content = json_return_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) @@ -14182,6 +14185,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) @@ -14327,6 +14331,7 @@ def test_create_cluster_rest_required_fields(request_type=service.CreateClusterR response_value._content = json_return_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) @@ -14395,6 +14400,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) @@ -14533,6 +14539,7 @@ def test_update_cluster_rest_required_fields(request_type=service.UpdateClusterR response_value._content = json_return_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) @@ -14591,6 +14598,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) @@ -14733,6 +14741,7 @@ def test_delete_cluster_rest_required_fields(request_type=service.DeleteClusterR response_value._content = json_return_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) @@ -14786,6 +14795,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) @@ -14918,6 +14928,7 @@ def test_promote_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.promote_cluster(request) @@ -14961,6 +14972,7 @@ def test_promote_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.promote_cluster(**mock_args) @@ -15098,6 +15110,7 @@ def test_switchover_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.switchover_cluster(request) @@ -15141,6 +15154,7 @@ def test_switchover_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.switchover_cluster(**mock_args) @@ -15278,6 +15292,7 @@ def test_restore_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.restore_cluster(request) @@ -15428,6 +15443,7 @@ def test_create_secondary_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_secondary_cluster(request) @@ -15496,6 +15512,7 @@ def test_create_secondary_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_secondary_cluster(**mock_args) @@ -15638,6 +15655,7 @@ def test_list_instances_rest_required_fields(request_type=service.ListInstancesR response_value._content = json_return_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) @@ -15695,6 +15713,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) @@ -15889,6 +15908,7 @@ def test_get_instance_rest_required_fields(request_type=service.GetInstanceReque response_value._content = json_return_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) @@ -15936,6 +15956,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) @@ -16084,6 +16105,7 @@ def test_create_instance_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_instance(request) @@ -16152,6 +16174,7 @@ def test_create_instance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_instance(**mock_args) @@ -16307,6 +16330,7 @@ def test_create_secondary_instance_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_secondary_instance(request) @@ -16375,6 +16399,7 @@ def test_create_secondary_instance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_secondary_instance(**mock_args) @@ -16517,6 +16542,7 @@ def test_batch_create_instances_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.batch_create_instances(request) @@ -16650,6 +16676,7 @@ def test_update_instance_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_instance(request) @@ -16708,6 +16735,7 @@ def test_update_instance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_instance(**mock_args) @@ -16849,6 +16877,7 @@ def test_delete_instance_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_instance(request) @@ -16903,6 +16932,7 @@ def test_delete_instance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_instance(**mock_args) @@ -17038,6 +17068,7 @@ def test_failover_instance_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.failover_instance(request) @@ -17083,6 +17114,7 @@ def test_failover_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.failover_instance(**mock_args) @@ -17214,6 +17246,7 @@ def test_inject_fault_rest_required_fields(request_type=service.InjectFaultReque response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.inject_fault(request) @@ -17268,6 +17301,7 @@ def test_inject_fault_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.inject_fault(**mock_args) @@ -17404,6 +17438,7 @@ def test_restart_instance_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.restart_instance(request) @@ -17449,6 +17484,7 @@ def test_restart_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.restart_instance(**mock_args) @@ -17591,6 +17627,7 @@ def test_execute_sql_rest_required_fields(request_type=service.ExecuteSqlRequest response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.execute_sql(request) @@ -17651,6 +17688,7 @@ def test_execute_sql_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.execute_sql(**mock_args) @@ -17793,6 +17831,7 @@ def test_list_backups_rest_required_fields(request_type=service.ListBackupsReque response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_backups(request) @@ -17848,6 +17887,7 @@ def test_list_backups_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_backups(**mock_args) @@ -18037,6 +18077,7 @@ def test_get_backup_rest_required_fields(request_type=service.GetBackupRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_backup(request) @@ -18082,6 +18123,7 @@ def test_get_backup_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_backup(**mock_args) @@ -18227,6 +18269,7 @@ def test_create_backup_rest_required_fields(request_type=service.CreateBackupReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_backup(request) @@ -18293,6 +18336,7 @@ def test_create_backup_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_backup(**mock_args) @@ -18429,6 +18473,7 @@ def test_update_backup_rest_required_fields(request_type=service.UpdateBackupReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_backup(request) @@ -18485,6 +18530,7 @@ def test_update_backup_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_backup(**mock_args) @@ -18624,6 +18670,7 @@ def test_delete_backup_rest_required_fields(request_type=service.DeleteBackupReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_backup(request) @@ -18676,6 +18723,7 @@ def test_delete_backup_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_backup(**mock_args) @@ -18818,6 +18866,7 @@ def test_list_supported_database_flags_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_supported_database_flags(request) @@ -18873,6 +18922,7 @@ def test_list_supported_database_flags_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_supported_database_flags(**mock_args) @@ -19073,6 +19123,7 @@ def test_generate_client_certificate_rest_required_fields( response_value._content = json_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_client_certificate(request) @@ -19120,6 +19171,7 @@ def test_generate_client_certificate_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_client_certificate(**mock_args) @@ -19257,6 +19309,7 @@ def test_get_connection_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_connection_info(request) @@ -19304,6 +19357,7 @@ def test_get_connection_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_connection_info(**mock_args) @@ -19442,6 +19496,7 @@ def test_list_users_rest_required_fields(request_type=service.ListUsersRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_users(request) @@ -19499,6 +19554,7 @@ def test_list_users_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_users(**mock_args) @@ -19691,6 +19747,7 @@ def test_get_user_rest_required_fields(request_type=service.GetUserRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_user(request) @@ -19738,6 +19795,7 @@ def test_get_user_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_user(**mock_args) @@ -19883,6 +19941,7 @@ def test_create_user_rest_required_fields(request_type=service.CreateUserRequest response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_user(request) @@ -19953,6 +20012,7 @@ def test_create_user_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_user(**mock_args) @@ -20089,6 +20149,7 @@ def test_update_user_rest_required_fields(request_type=service.UpdateUserRequest response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_user(request) @@ -20149,6 +20210,7 @@ def test_update_user_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_user(**mock_args) @@ -20283,6 +20345,7 @@ def test_delete_user_rest_required_fields(request_type=service.DeleteUserRequest response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_user(request) @@ -20336,6 +20399,7 @@ def test_delete_user_rest_flattened(): json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_user(**mock_args) @@ -20473,6 +20537,7 @@ def test_list_databases_rest_required_fields(request_type=service.ListDatabasesR response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_databases(request) @@ -20529,6 +20594,7 @@ def test_list_databases_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_databases(**mock_args) @@ -22443,6 +22509,7 @@ def test_list_clusters_rest_bad_request(request_type=service.ListClustersRequest response_value.status_code = 400 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) @@ -22479,6 +22546,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. @@ -22518,6 +22586,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 = service.ListClustersResponse.to_json( service.ListClustersResponse() ) @@ -22562,6 +22631,7 @@ def test_get_cluster_rest_bad_request(request_type=service.GetClusterRequest): response_value.status_code = 400 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) @@ -22607,6 +22677,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. @@ -22655,6 +22726,7 @@ def test_get_cluster_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = resources.Cluster.to_json(resources.Cluster()) req.return_value.content = return_value @@ -22697,6 +22769,7 @@ def test_create_cluster_rest_bad_request(request_type=service.CreateClusterReque response_value.status_code = 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) @@ -22879,6 +22952,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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. @@ -22918,6 +22992,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 @@ -22962,6 +23037,7 @@ def test_update_cluster_rest_bad_request(request_type=service.UpdateClusterReque response_value.status_code = 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) @@ -23146,6 +23222,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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. @@ -23185,6 +23262,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 @@ -23227,6 +23305,7 @@ def test_delete_cluster_rest_bad_request(request_type=service.DeleteClusterReque response_value.status_code = 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) @@ -23257,6 +23336,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. @@ -23296,6 +23376,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 @@ -23338,6 +23419,7 @@ def test_promote_cluster_rest_bad_request(request_type=service.PromoteClusterReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.promote_cluster(request) @@ -23368,6 +23450,7 @@ def test_promote_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.promote_cluster(request) # Establish that the response is the type that we expect. @@ -23407,6 +23490,7 @@ def test_promote_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 @@ -23451,6 +23535,7 @@ def test_switchover_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.switchover_cluster(request) @@ -23481,6 +23566,7 @@ def test_switchover_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.switchover_cluster(request) # Establish that the response is the type that we expect. @@ -23522,6 +23608,7 @@ def test_switchover_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 @@ -23564,6 +23651,7 @@ def test_restore_cluster_rest_bad_request(request_type=service.RestoreClusterReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.restore_cluster(request) @@ -23594,6 +23682,7 @@ def test_restore_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.restore_cluster(request) # Establish that the response is the type that we expect. @@ -23633,6 +23722,7 @@ def test_restore_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 @@ -23677,6 +23767,7 @@ def test_create_secondary_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_secondary_cluster(request) @@ -23859,6 +23950,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_secondary_cluster(request) # Establish that the response is the type that we expect. @@ -23900,6 +23992,7 @@ def test_create_secondary_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 @@ -23942,6 +24035,7 @@ def test_list_instances_rest_bad_request(request_type=service.ListInstancesReque response_value.status_code = 400 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) @@ -23978,6 +24072,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. @@ -24017,6 +24112,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 = service.ListInstancesResponse.to_json( service.ListInstancesResponse() ) @@ -24063,6 +24159,7 @@ def test_get_instance_rest_bad_request(request_type=service.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) @@ -24112,6 +24209,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. @@ -24164,6 +24262,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 = resources.Instance.to_json(resources.Instance()) req.return_value.content = return_value @@ -24206,6 +24305,7 @@ def test_create_instance_rest_bad_request(request_type=service.CreateInstanceReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_instance(request) @@ -24359,6 +24459,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_instance(request) # Establish that the response is the type that we expect. @@ -24398,6 +24499,7 @@ def test_create_instance_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -24442,6 +24544,7 @@ def test_create_secondary_instance_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_secondary_instance(request) @@ -24595,6 +24698,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_secondary_instance(request) # Establish that the response is the type that we expect. @@ -24636,6 +24740,7 @@ def test_create_secondary_instance_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -24680,6 +24785,7 @@ def test_batch_create_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.batch_create_instances(request) @@ -24845,6 +24951,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_instances(request) # Establish that the response is the type that we expect. @@ -24886,6 +24993,7 @@ def test_batch_create_instances_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -24932,6 +25040,7 @@ def test_update_instance_rest_bad_request(request_type=service.UpdateInstanceReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_instance(request) @@ -25089,6 +25198,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_instance(request) # Establish that the response is the type that we expect. @@ -25128,6 +25238,7 @@ def test_update_instance_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -25172,6 +25283,7 @@ def test_delete_instance_rest_bad_request(request_type=service.DeleteInstanceReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_instance(request) @@ -25204,6 +25316,7 @@ def test_delete_instance_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_instance(request) # Establish that the response is the type that we expect. @@ -25243,6 +25356,7 @@ def test_delete_instance_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -25289,6 +25403,7 @@ def test_failover_instance_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.failover_instance(request) @@ -25321,6 +25436,7 @@ def test_failover_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.failover_instance(request) # Establish that the response is the type that we expect. @@ -25362,6 +25478,7 @@ def test_failover_instance_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -25406,6 +25523,7 @@ def test_inject_fault_rest_bad_request(request_type=service.InjectFaultRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.inject_fault(request) @@ -25438,6 +25556,7 @@ def test_inject_fault_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.inject_fault(request) # Establish that the response is the type that we expect. @@ -25477,6 +25596,7 @@ def test_inject_fault_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -25521,6 +25641,7 @@ def test_restart_instance_rest_bad_request(request_type=service.RestartInstanceR response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.restart_instance(request) @@ -25553,6 +25674,7 @@ def test_restart_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.restart_instance(request) # Establish that the response is the type that we expect. @@ -25592,6 +25714,7 @@ def test_restart_instance_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -25636,6 +25759,7 @@ def test_execute_sql_rest_bad_request(request_type=service.ExecuteSqlRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.execute_sql(request) @@ -25671,6 +25795,7 @@ def test_execute_sql_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.execute_sql(request) # Establish that the response is the type that we expect. @@ -25708,6 +25833,7 @@ def test_execute_sql_rest_interceptors(null_interceptor): req.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.ExecuteSqlResponse.to_json(service.ExecuteSqlResponse()) req.return_value.content = return_value @@ -25750,6 +25876,7 @@ def test_list_backups_rest_bad_request(request_type=service.ListBackupsRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_backups(request) @@ -25786,6 +25913,7 @@ def test_list_backups_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_backups(request) # Establish that the response is the type that we expect. @@ -25825,6 +25953,7 @@ def test_list_backups_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = service.ListBackupsResponse.to_json( service.ListBackupsResponse() ) @@ -25869,6 +25998,7 @@ def test_get_backup_rest_bad_request(request_type=service.GetBackupRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_backup(request) @@ -25916,6 +26046,7 @@ def test_get_backup_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_backup(request) # Establish that the response is the type that we expect. @@ -25966,6 +26097,7 @@ def test_get_backup_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = resources.Backup.to_json(resources.Backup()) req.return_value.content = return_value @@ -26008,6 +26140,7 @@ def test_create_backup_rest_bad_request(request_type=service.CreateBackupRequest response_value.status_code = 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_backup(request) @@ -26133,6 +26266,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_backup(request) # Establish that the response is the type that we expect. @@ -26172,6 +26306,7 @@ def test_create_backup_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -26216,6 +26351,7 @@ def test_update_backup_rest_bad_request(request_type=service.UpdateBackupRequest response_value.status_code = 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_backup(request) @@ -26343,6 +26479,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_backup(request) # Establish that the response is the type that we expect. @@ -26382,6 +26519,7 @@ def test_update_backup_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -26424,6 +26562,7 @@ def test_delete_backup_rest_bad_request(request_type=service.DeleteBackupRequest response_value.status_code = 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_backup(request) @@ -26454,6 +26593,7 @@ def test_delete_backup_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_backup(request) # Establish that the response is the type that we expect. @@ -26493,6 +26633,7 @@ def test_delete_backup_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -26537,6 +26678,7 @@ def test_list_supported_database_flags_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_supported_database_flags(request) @@ -26572,6 +26714,7 @@ def test_list_supported_database_flags_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_supported_database_flags(request) # Establish that the response is the type that we expect. @@ -26612,6 +26755,7 @@ def test_list_supported_database_flags_rest_interceptors(null_interceptor): req.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.ListSupportedDatabaseFlagsResponse.to_json( service.ListSupportedDatabaseFlagsResponse() ) @@ -26658,6 +26802,7 @@ def test_generate_client_certificate_rest_bad_request( response_value.status_code = 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_client_certificate(request) @@ -26694,6 +26839,7 @@ def test_generate_client_certificate_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_client_certificate(request) # Establish that the response is the type that we expect. @@ -26735,6 +26881,7 @@ def test_generate_client_certificate_rest_interceptors(null_interceptor): req.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.GenerateClientCertificateResponse.to_json( service.GenerateClientCertificateResponse() ) @@ -26783,6 +26930,7 @@ def test_get_connection_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_connection_info(request) @@ -26823,6 +26971,7 @@ def test_get_connection_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_connection_info(request) # Establish that the response is the type that we expect. @@ -26866,6 +27015,7 @@ def test_get_connection_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 = resources.ConnectionInfo.to_json(resources.ConnectionInfo()) req.return_value.content = return_value @@ -26908,6 +27058,7 @@ def test_list_users_rest_bad_request(request_type=service.ListUsersRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_users(request) @@ -26944,6 +27095,7 @@ def test_list_users_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_users(request) # Establish that the response is the type that we expect. @@ -26983,6 +27135,7 @@ def test_list_users_rest_interceptors(null_interceptor): req.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.ListUsersResponse.to_json(service.ListUsersResponse()) req.return_value.content = return_value @@ -27027,6 +27180,7 @@ def test_get_user_rest_bad_request(request_type=service.GetUserRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_user(request) @@ -27068,6 +27222,7 @@ def test_get_user_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_user(request) # Establish that the response is the type that we expect. @@ -27110,6 +27265,7 @@ def test_get_user_rest_interceptors(null_interceptor): req.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.User.to_json(resources.User()) req.return_value.content = return_value @@ -27152,6 +27308,7 @@ def test_create_user_rest_bad_request(request_type=service.CreateUserRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_user(request) @@ -27265,6 +27422,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_user(request) # Establish that the response is the type that we expect. @@ -27307,6 +27465,7 @@ def test_create_user_rest_interceptors(null_interceptor): req.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.User.to_json(resources.User()) req.return_value.content = return_value @@ -27353,6 +27512,7 @@ def test_update_user_rest_bad_request(request_type=service.UpdateUserRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_user(request) @@ -27470,6 +27630,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_user(request) # Establish that the response is the type that we expect. @@ -27512,6 +27673,7 @@ def test_update_user_rest_interceptors(null_interceptor): req.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.User.to_json(resources.User()) req.return_value.content = return_value @@ -27556,6 +27718,7 @@ def test_delete_user_rest_bad_request(request_type=service.DeleteUserRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_user(request) @@ -27588,6 +27751,7 @@ def test_delete_user_rest_call_success(request_type): json_return_value = "" response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_user(request) # Establish that the response is the type that we expect. @@ -27622,6 +27786,7 @@ def test_delete_user_rest_interceptors(null_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.DeleteUserRequest() metadata = [ @@ -27660,6 +27825,7 @@ def test_list_databases_rest_bad_request(request_type=service.ListDatabasesReque response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_databases(request) @@ -27695,6 +27861,7 @@ def test_list_databases_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_databases(request) # Establish that the response is the type that we expect. @@ -27733,6 +27900,7 @@ def test_list_databases_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = service.ListDatabasesResponse.to_json( service.ListDatabasesResponse() ) @@ -27779,6 +27947,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) @@ -27809,6 +27978,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) @@ -27837,6 +28007,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) @@ -27867,6 +28038,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) @@ -27897,6 +28069,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) @@ -27927,6 +28100,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) @@ -27957,6 +28131,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) @@ -27987,6 +28162,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) @@ -28017,6 +28193,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) @@ -28047,6 +28224,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) @@ -28077,6 +28255,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) @@ -28107,6 +28286,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-alloydb/tests/unit/gapic/alloydb_v1alpha/test_alloy_db_admin.py b/packages/google-cloud-alloydb/tests/unit/gapic/alloydb_v1alpha/test_alloy_db_admin.py index 01eeddae08d1..5935432e7a1f 100644 --- a/packages/google-cloud-alloydb/tests/unit/gapic/alloydb_v1alpha/test_alloy_db_admin.py +++ b/packages/google-cloud-alloydb/tests/unit/gapic/alloydb_v1alpha/test_alloy_db_admin.py @@ -14262,6 +14262,7 @@ def test_list_clusters_rest_required_fields(request_type=service.ListClustersReq response_value._content = json_return_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) @@ -14317,6 +14318,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) @@ -14509,6 +14511,7 @@ def test_get_cluster_rest_required_fields(request_type=service.GetClusterRequest response_value._content = json_return_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) @@ -14554,6 +14557,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) @@ -14700,6 +14704,7 @@ def test_create_cluster_rest_required_fields(request_type=service.CreateClusterR response_value._content = json_return_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) @@ -14768,6 +14773,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) @@ -14907,6 +14913,7 @@ def test_update_cluster_rest_required_fields(request_type=service.UpdateClusterR response_value._content = json_return_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) @@ -14965,6 +14972,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) @@ -15101,6 +15109,7 @@ def test_upgrade_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.upgrade_cluster(request) @@ -15153,6 +15162,7 @@ def test_upgrade_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.upgrade_cluster(**mock_args) @@ -15293,6 +15303,7 @@ def test_delete_cluster_rest_required_fields(request_type=service.DeleteClusterR response_value._content = json_return_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) @@ -15346,6 +15357,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) @@ -15479,6 +15491,7 @@ def test_promote_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.promote_cluster(request) @@ -15522,6 +15535,7 @@ def test_promote_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.promote_cluster(**mock_args) @@ -15659,6 +15673,7 @@ def test_switchover_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.switchover_cluster(request) @@ -15702,6 +15717,7 @@ def test_switchover_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.switchover_cluster(**mock_args) @@ -15839,6 +15855,7 @@ def test_restore_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.restore_cluster(request) @@ -15989,6 +16006,7 @@ def test_create_secondary_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_secondary_cluster(request) @@ -16057,6 +16075,7 @@ def test_create_secondary_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_secondary_cluster(**mock_args) @@ -16199,6 +16218,7 @@ def test_list_instances_rest_required_fields(request_type=service.ListInstancesR response_value._content = json_return_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) @@ -16256,6 +16276,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) @@ -16450,6 +16471,7 @@ def test_get_instance_rest_required_fields(request_type=service.GetInstanceReque response_value._content = json_return_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) @@ -16497,6 +16519,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) @@ -16645,6 +16668,7 @@ def test_create_instance_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_instance(request) @@ -16713,6 +16737,7 @@ def test_create_instance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_instance(**mock_args) @@ -16868,6 +16893,7 @@ def test_create_secondary_instance_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_secondary_instance(request) @@ -16936,6 +16962,7 @@ def test_create_secondary_instance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_secondary_instance(**mock_args) @@ -17078,6 +17105,7 @@ def test_batch_create_instances_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.batch_create_instances(request) @@ -17211,6 +17239,7 @@ def test_update_instance_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_instance(request) @@ -17269,6 +17298,7 @@ def test_update_instance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_instance(**mock_args) @@ -17410,6 +17440,7 @@ def test_delete_instance_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_instance(request) @@ -17464,6 +17495,7 @@ def test_delete_instance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_instance(**mock_args) @@ -17599,6 +17631,7 @@ def test_failover_instance_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.failover_instance(request) @@ -17644,6 +17677,7 @@ def test_failover_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.failover_instance(**mock_args) @@ -17775,6 +17809,7 @@ def test_inject_fault_rest_required_fields(request_type=service.InjectFaultReque response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.inject_fault(request) @@ -17829,6 +17864,7 @@ def test_inject_fault_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.inject_fault(**mock_args) @@ -17965,6 +18001,7 @@ def test_restart_instance_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.restart_instance(request) @@ -18010,6 +18047,7 @@ def test_restart_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.restart_instance(**mock_args) @@ -18152,6 +18190,7 @@ def test_execute_sql_rest_required_fields(request_type=service.ExecuteSqlRequest response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.execute_sql(request) @@ -18212,6 +18251,7 @@ def test_execute_sql_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.execute_sql(**mock_args) @@ -18354,6 +18394,7 @@ def test_list_backups_rest_required_fields(request_type=service.ListBackupsReque response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_backups(request) @@ -18409,6 +18450,7 @@ def test_list_backups_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_backups(**mock_args) @@ -18599,6 +18641,7 @@ def test_get_backup_rest_required_fields(request_type=service.GetBackupRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_backup(request) @@ -18644,6 +18687,7 @@ def test_get_backup_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_backup(**mock_args) @@ -18790,6 +18834,7 @@ def test_create_backup_rest_required_fields(request_type=service.CreateBackupReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_backup(request) @@ -18856,6 +18901,7 @@ def test_create_backup_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_backup(**mock_args) @@ -18993,6 +19039,7 @@ def test_update_backup_rest_required_fields(request_type=service.UpdateBackupReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_backup(request) @@ -19049,6 +19096,7 @@ def test_update_backup_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_backup(**mock_args) @@ -19188,6 +19236,7 @@ def test_delete_backup_rest_required_fields(request_type=service.DeleteBackupReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_backup(request) @@ -19240,6 +19289,7 @@ def test_delete_backup_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_backup(**mock_args) @@ -19383,6 +19433,7 @@ def test_list_supported_database_flags_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_supported_database_flags(request) @@ -19438,6 +19489,7 @@ def test_list_supported_database_flags_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_supported_database_flags(**mock_args) @@ -19638,6 +19690,7 @@ def test_generate_client_certificate_rest_required_fields( response_value._content = json_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_client_certificate(request) @@ -19685,6 +19738,7 @@ def test_generate_client_certificate_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_client_certificate(**mock_args) @@ -19822,6 +19876,7 @@ def test_get_connection_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_connection_info(request) @@ -19869,6 +19924,7 @@ def test_get_connection_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_connection_info(**mock_args) @@ -20007,6 +20063,7 @@ def test_list_users_rest_required_fields(request_type=service.ListUsersRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_users(request) @@ -20064,6 +20121,7 @@ def test_list_users_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_users(**mock_args) @@ -20256,6 +20314,7 @@ def test_get_user_rest_required_fields(request_type=service.GetUserRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_user(request) @@ -20303,6 +20362,7 @@ def test_get_user_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_user(**mock_args) @@ -20448,6 +20508,7 @@ def test_create_user_rest_required_fields(request_type=service.CreateUserRequest response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_user(request) @@ -20518,6 +20579,7 @@ def test_create_user_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_user(**mock_args) @@ -20654,6 +20716,7 @@ def test_update_user_rest_required_fields(request_type=service.UpdateUserRequest response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_user(request) @@ -20714,6 +20777,7 @@ def test_update_user_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_user(**mock_args) @@ -20848,6 +20912,7 @@ def test_delete_user_rest_required_fields(request_type=service.DeleteUserRequest response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_user(request) @@ -20901,6 +20966,7 @@ def test_delete_user_rest_flattened(): json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_user(**mock_args) @@ -21038,6 +21104,7 @@ def test_list_databases_rest_required_fields(request_type=service.ListDatabasesR response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_databases(request) @@ -21094,6 +21161,7 @@ def test_list_databases_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_databases(**mock_args) @@ -23060,6 +23128,7 @@ def test_list_clusters_rest_bad_request(request_type=service.ListClustersRequest response_value.status_code = 400 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) @@ -23096,6 +23165,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. @@ -23135,6 +23205,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 = service.ListClustersResponse.to_json( service.ListClustersResponse() ) @@ -23179,6 +23250,7 @@ def test_get_cluster_rest_bad_request(request_type=service.GetClusterRequest): response_value.status_code = 400 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) @@ -23225,6 +23297,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. @@ -23274,6 +23347,7 @@ def test_get_cluster_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = resources.Cluster.to_json(resources.Cluster()) req.return_value.content = return_value @@ -23316,6 +23390,7 @@ def test_create_cluster_rest_bad_request(request_type=service.CreateClusterReque response_value.status_code = 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) @@ -23505,6 +23580,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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. @@ -23544,6 +23620,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 @@ -23588,6 +23665,7 @@ def test_update_cluster_rest_bad_request(request_type=service.UpdateClusterReque response_value.status_code = 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) @@ -23779,6 +23857,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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. @@ -23818,6 +23897,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 @@ -23860,6 +23940,7 @@ def test_upgrade_cluster_rest_bad_request(request_type=service.UpgradeClusterReq response_value.status_code = 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_cluster(request) @@ -23890,6 +23971,7 @@ def test_upgrade_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.upgrade_cluster(request) # Establish that the response is the type that we expect. @@ -23929,6 +24011,7 @@ def test_upgrade_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 @@ -23971,6 +24054,7 @@ def test_delete_cluster_rest_bad_request(request_type=service.DeleteClusterReque response_value.status_code = 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) @@ -24001,6 +24085,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. @@ -24040,6 +24125,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 @@ -24082,6 +24168,7 @@ def test_promote_cluster_rest_bad_request(request_type=service.PromoteClusterReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.promote_cluster(request) @@ -24112,6 +24199,7 @@ def test_promote_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.promote_cluster(request) # Establish that the response is the type that we expect. @@ -24151,6 +24239,7 @@ def test_promote_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 @@ -24195,6 +24284,7 @@ def test_switchover_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.switchover_cluster(request) @@ -24225,6 +24315,7 @@ def test_switchover_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.switchover_cluster(request) # Establish that the response is the type that we expect. @@ -24266,6 +24357,7 @@ def test_switchover_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 @@ -24308,6 +24400,7 @@ def test_restore_cluster_rest_bad_request(request_type=service.RestoreClusterReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.restore_cluster(request) @@ -24338,6 +24431,7 @@ def test_restore_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.restore_cluster(request) # Establish that the response is the type that we expect. @@ -24377,6 +24471,7 @@ def test_restore_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 @@ -24421,6 +24516,7 @@ def test_create_secondary_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_secondary_cluster(request) @@ -24610,6 +24706,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_secondary_cluster(request) # Establish that the response is the type that we expect. @@ -24651,6 +24748,7 @@ def test_create_secondary_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 @@ -24693,6 +24791,7 @@ def test_list_instances_rest_bad_request(request_type=service.ListInstancesReque response_value.status_code = 400 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) @@ -24729,6 +24828,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. @@ -24768,6 +24868,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 = service.ListInstancesResponse.to_json( service.ListInstancesResponse() ) @@ -24814,6 +24915,7 @@ def test_get_instance_rest_bad_request(request_type=service.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) @@ -24864,6 +24966,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. @@ -24917,6 +25020,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 = resources.Instance.to_json(resources.Instance()) req.return_value.content = return_value @@ -24959,6 +25063,7 @@ def test_create_instance_rest_bad_request(request_type=service.CreateInstanceReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_instance(request) @@ -25129,6 +25234,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_instance(request) # Establish that the response is the type that we expect. @@ -25168,6 +25274,7 @@ def test_create_instance_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -25212,6 +25319,7 @@ def test_create_secondary_instance_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_secondary_instance(request) @@ -25382,6 +25490,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_secondary_instance(request) # Establish that the response is the type that we expect. @@ -25423,6 +25532,7 @@ def test_create_secondary_instance_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -25467,6 +25577,7 @@ def test_batch_create_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.batch_create_instances(request) @@ -25651,6 +25762,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_instances(request) # Establish that the response is the type that we expect. @@ -25692,6 +25804,7 @@ def test_batch_create_instances_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -25738,6 +25851,7 @@ def test_update_instance_rest_bad_request(request_type=service.UpdateInstanceReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_instance(request) @@ -25912,6 +26026,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_instance(request) # Establish that the response is the type that we expect. @@ -25951,6 +26066,7 @@ def test_update_instance_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -25995,6 +26111,7 @@ def test_delete_instance_rest_bad_request(request_type=service.DeleteInstanceReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_instance(request) @@ -26027,6 +26144,7 @@ def test_delete_instance_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_instance(request) # Establish that the response is the type that we expect. @@ -26066,6 +26184,7 @@ def test_delete_instance_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -26112,6 +26231,7 @@ def test_failover_instance_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.failover_instance(request) @@ -26144,6 +26264,7 @@ def test_failover_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.failover_instance(request) # Establish that the response is the type that we expect. @@ -26185,6 +26306,7 @@ def test_failover_instance_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -26229,6 +26351,7 @@ def test_inject_fault_rest_bad_request(request_type=service.InjectFaultRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.inject_fault(request) @@ -26261,6 +26384,7 @@ def test_inject_fault_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.inject_fault(request) # Establish that the response is the type that we expect. @@ -26300,6 +26424,7 @@ def test_inject_fault_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -26344,6 +26469,7 @@ def test_restart_instance_rest_bad_request(request_type=service.RestartInstanceR response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.restart_instance(request) @@ -26376,6 +26502,7 @@ def test_restart_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.restart_instance(request) # Establish that the response is the type that we expect. @@ -26415,6 +26542,7 @@ def test_restart_instance_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -26459,6 +26587,7 @@ def test_execute_sql_rest_bad_request(request_type=service.ExecuteSqlRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.execute_sql(request) @@ -26494,6 +26623,7 @@ def test_execute_sql_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.execute_sql(request) # Establish that the response is the type that we expect. @@ -26531,6 +26661,7 @@ def test_execute_sql_rest_interceptors(null_interceptor): req.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.ExecuteSqlResponse.to_json(service.ExecuteSqlResponse()) req.return_value.content = return_value @@ -26573,6 +26704,7 @@ def test_list_backups_rest_bad_request(request_type=service.ListBackupsRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_backups(request) @@ -26609,6 +26741,7 @@ def test_list_backups_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_backups(request) # Establish that the response is the type that we expect. @@ -26648,6 +26781,7 @@ def test_list_backups_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = service.ListBackupsResponse.to_json( service.ListBackupsResponse() ) @@ -26692,6 +26826,7 @@ def test_get_backup_rest_bad_request(request_type=service.GetBackupRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_backup(request) @@ -26740,6 +26875,7 @@ def test_get_backup_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_backup(request) # Establish that the response is the type that we expect. @@ -26791,6 +26927,7 @@ def test_get_backup_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = resources.Backup.to_json(resources.Backup()) req.return_value.content = return_value @@ -26833,6 +26970,7 @@ def test_create_backup_rest_bad_request(request_type=service.CreateBackupRequest response_value.status_code = 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_backup(request) @@ -26959,6 +27097,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_backup(request) # Establish that the response is the type that we expect. @@ -26998,6 +27137,7 @@ def test_create_backup_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -27042,6 +27182,7 @@ def test_update_backup_rest_bad_request(request_type=service.UpdateBackupRequest response_value.status_code = 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_backup(request) @@ -27170,6 +27311,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_backup(request) # Establish that the response is the type that we expect. @@ -27209,6 +27351,7 @@ def test_update_backup_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -27251,6 +27394,7 @@ def test_delete_backup_rest_bad_request(request_type=service.DeleteBackupRequest response_value.status_code = 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_backup(request) @@ -27281,6 +27425,7 @@ def test_delete_backup_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_backup(request) # Establish that the response is the type that we expect. @@ -27320,6 +27465,7 @@ def test_delete_backup_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -27364,6 +27510,7 @@ def test_list_supported_database_flags_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_supported_database_flags(request) @@ -27399,6 +27546,7 @@ def test_list_supported_database_flags_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_supported_database_flags(request) # Establish that the response is the type that we expect. @@ -27439,6 +27587,7 @@ def test_list_supported_database_flags_rest_interceptors(null_interceptor): req.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.ListSupportedDatabaseFlagsResponse.to_json( service.ListSupportedDatabaseFlagsResponse() ) @@ -27485,6 +27634,7 @@ def test_generate_client_certificate_rest_bad_request( response_value.status_code = 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_client_certificate(request) @@ -27522,6 +27672,7 @@ def test_generate_client_certificate_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_client_certificate(request) # Establish that the response is the type that we expect. @@ -27564,6 +27715,7 @@ def test_generate_client_certificate_rest_interceptors(null_interceptor): req.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.GenerateClientCertificateResponse.to_json( service.GenerateClientCertificateResponse() ) @@ -27612,6 +27764,7 @@ def test_get_connection_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_connection_info(request) @@ -27654,6 +27807,7 @@ def test_get_connection_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_connection_info(request) # Establish that the response is the type that we expect. @@ -27699,6 +27853,7 @@ def test_get_connection_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 = resources.ConnectionInfo.to_json(resources.ConnectionInfo()) req.return_value.content = return_value @@ -27741,6 +27896,7 @@ def test_list_users_rest_bad_request(request_type=service.ListUsersRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_users(request) @@ -27777,6 +27933,7 @@ def test_list_users_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_users(request) # Establish that the response is the type that we expect. @@ -27816,6 +27973,7 @@ def test_list_users_rest_interceptors(null_interceptor): req.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.ListUsersResponse.to_json(service.ListUsersResponse()) req.return_value.content = return_value @@ -27860,6 +28018,7 @@ def test_get_user_rest_bad_request(request_type=service.GetUserRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_user(request) @@ -27901,6 +28060,7 @@ def test_get_user_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_user(request) # Establish that the response is the type that we expect. @@ -27943,6 +28103,7 @@ def test_get_user_rest_interceptors(null_interceptor): req.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.User.to_json(resources.User()) req.return_value.content = return_value @@ -27985,6 +28146,7 @@ def test_create_user_rest_bad_request(request_type=service.CreateUserRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_user(request) @@ -28098,6 +28260,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_user(request) # Establish that the response is the type that we expect. @@ -28140,6 +28303,7 @@ def test_create_user_rest_interceptors(null_interceptor): req.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.User.to_json(resources.User()) req.return_value.content = return_value @@ -28186,6 +28350,7 @@ def test_update_user_rest_bad_request(request_type=service.UpdateUserRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_user(request) @@ -28303,6 +28468,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_user(request) # Establish that the response is the type that we expect. @@ -28345,6 +28511,7 @@ def test_update_user_rest_interceptors(null_interceptor): req.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.User.to_json(resources.User()) req.return_value.content = return_value @@ -28389,6 +28556,7 @@ def test_delete_user_rest_bad_request(request_type=service.DeleteUserRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_user(request) @@ -28421,6 +28589,7 @@ def test_delete_user_rest_call_success(request_type): json_return_value = "" response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_user(request) # Establish that the response is the type that we expect. @@ -28455,6 +28624,7 @@ def test_delete_user_rest_interceptors(null_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.DeleteUserRequest() metadata = [ @@ -28493,6 +28663,7 @@ def test_list_databases_rest_bad_request(request_type=service.ListDatabasesReque response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_databases(request) @@ -28528,6 +28699,7 @@ def test_list_databases_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_databases(request) # Establish that the response is the type that we expect. @@ -28566,6 +28738,7 @@ def test_list_databases_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = service.ListDatabasesResponse.to_json( service.ListDatabasesResponse() ) @@ -28612,6 +28785,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) @@ -28642,6 +28816,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) @@ -28670,6 +28845,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) @@ -28700,6 +28876,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) @@ -28730,6 +28907,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) @@ -28760,6 +28938,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) @@ -28790,6 +28969,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) @@ -28820,6 +29000,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) @@ -28850,6 +29031,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) @@ -28880,6 +29062,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) @@ -28910,6 +29093,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) @@ -28940,6 +29124,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-alloydb/tests/unit/gapic/alloydb_v1beta/test_alloy_db_admin.py b/packages/google-cloud-alloydb/tests/unit/gapic/alloydb_v1beta/test_alloy_db_admin.py index 3083343db32a..c5907e0a6acf 100644 --- a/packages/google-cloud-alloydb/tests/unit/gapic/alloydb_v1beta/test_alloy_db_admin.py +++ b/packages/google-cloud-alloydb/tests/unit/gapic/alloydb_v1beta/test_alloy_db_admin.py @@ -14250,6 +14250,7 @@ def test_list_clusters_rest_required_fields(request_type=service.ListClustersReq response_value._content = json_return_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) @@ -14305,6 +14306,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) @@ -14497,6 +14499,7 @@ def test_get_cluster_rest_required_fields(request_type=service.GetClusterRequest response_value._content = json_return_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) @@ -14542,6 +14545,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) @@ -14688,6 +14692,7 @@ def test_create_cluster_rest_required_fields(request_type=service.CreateClusterR response_value._content = json_return_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) @@ -14756,6 +14761,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) @@ -14895,6 +14901,7 @@ def test_update_cluster_rest_required_fields(request_type=service.UpdateClusterR response_value._content = json_return_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) @@ -14953,6 +14960,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) @@ -15089,6 +15097,7 @@ def test_upgrade_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.upgrade_cluster(request) @@ -15141,6 +15150,7 @@ def test_upgrade_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.upgrade_cluster(**mock_args) @@ -15281,6 +15291,7 @@ def test_delete_cluster_rest_required_fields(request_type=service.DeleteClusterR response_value._content = json_return_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) @@ -15334,6 +15345,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) @@ -15467,6 +15479,7 @@ def test_promote_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.promote_cluster(request) @@ -15510,6 +15523,7 @@ def test_promote_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.promote_cluster(**mock_args) @@ -15647,6 +15661,7 @@ def test_switchover_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.switchover_cluster(request) @@ -15690,6 +15705,7 @@ def test_switchover_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.switchover_cluster(**mock_args) @@ -15827,6 +15843,7 @@ def test_restore_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.restore_cluster(request) @@ -15977,6 +15994,7 @@ def test_create_secondary_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_secondary_cluster(request) @@ -16045,6 +16063,7 @@ def test_create_secondary_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_secondary_cluster(**mock_args) @@ -16187,6 +16206,7 @@ def test_list_instances_rest_required_fields(request_type=service.ListInstancesR response_value._content = json_return_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) @@ -16244,6 +16264,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) @@ -16438,6 +16459,7 @@ def test_get_instance_rest_required_fields(request_type=service.GetInstanceReque response_value._content = json_return_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) @@ -16485,6 +16507,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) @@ -16633,6 +16656,7 @@ def test_create_instance_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_instance(request) @@ -16701,6 +16725,7 @@ def test_create_instance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_instance(**mock_args) @@ -16856,6 +16881,7 @@ def test_create_secondary_instance_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_secondary_instance(request) @@ -16924,6 +16950,7 @@ def test_create_secondary_instance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_secondary_instance(**mock_args) @@ -17066,6 +17093,7 @@ def test_batch_create_instances_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.batch_create_instances(request) @@ -17199,6 +17227,7 @@ def test_update_instance_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_instance(request) @@ -17257,6 +17286,7 @@ def test_update_instance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_instance(**mock_args) @@ -17398,6 +17428,7 @@ def test_delete_instance_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_instance(request) @@ -17452,6 +17483,7 @@ def test_delete_instance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_instance(**mock_args) @@ -17587,6 +17619,7 @@ def test_failover_instance_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.failover_instance(request) @@ -17632,6 +17665,7 @@ def test_failover_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.failover_instance(**mock_args) @@ -17763,6 +17797,7 @@ def test_inject_fault_rest_required_fields(request_type=service.InjectFaultReque response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.inject_fault(request) @@ -17817,6 +17852,7 @@ def test_inject_fault_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.inject_fault(**mock_args) @@ -17953,6 +17989,7 @@ def test_restart_instance_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.restart_instance(request) @@ -17998,6 +18035,7 @@ def test_restart_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.restart_instance(**mock_args) @@ -18140,6 +18178,7 @@ def test_execute_sql_rest_required_fields(request_type=service.ExecuteSqlRequest response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.execute_sql(request) @@ -18200,6 +18239,7 @@ def test_execute_sql_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.execute_sql(**mock_args) @@ -18342,6 +18382,7 @@ def test_list_backups_rest_required_fields(request_type=service.ListBackupsReque response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_backups(request) @@ -18397,6 +18438,7 @@ def test_list_backups_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_backups(**mock_args) @@ -18587,6 +18629,7 @@ def test_get_backup_rest_required_fields(request_type=service.GetBackupRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_backup(request) @@ -18632,6 +18675,7 @@ def test_get_backup_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_backup(**mock_args) @@ -18778,6 +18822,7 @@ def test_create_backup_rest_required_fields(request_type=service.CreateBackupReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_backup(request) @@ -18844,6 +18889,7 @@ def test_create_backup_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_backup(**mock_args) @@ -18981,6 +19027,7 @@ def test_update_backup_rest_required_fields(request_type=service.UpdateBackupReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_backup(request) @@ -19037,6 +19084,7 @@ def test_update_backup_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_backup(**mock_args) @@ -19176,6 +19224,7 @@ def test_delete_backup_rest_required_fields(request_type=service.DeleteBackupReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_backup(request) @@ -19228,6 +19277,7 @@ def test_delete_backup_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_backup(**mock_args) @@ -19371,6 +19421,7 @@ def test_list_supported_database_flags_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_supported_database_flags(request) @@ -19426,6 +19477,7 @@ def test_list_supported_database_flags_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_supported_database_flags(**mock_args) @@ -19626,6 +19678,7 @@ def test_generate_client_certificate_rest_required_fields( response_value._content = json_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_client_certificate(request) @@ -19673,6 +19726,7 @@ def test_generate_client_certificate_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_client_certificate(**mock_args) @@ -19810,6 +19864,7 @@ def test_get_connection_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_connection_info(request) @@ -19857,6 +19912,7 @@ def test_get_connection_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_connection_info(**mock_args) @@ -19995,6 +20051,7 @@ def test_list_users_rest_required_fields(request_type=service.ListUsersRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_users(request) @@ -20052,6 +20109,7 @@ def test_list_users_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_users(**mock_args) @@ -20244,6 +20302,7 @@ def test_get_user_rest_required_fields(request_type=service.GetUserRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_user(request) @@ -20291,6 +20350,7 @@ def test_get_user_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_user(**mock_args) @@ -20436,6 +20496,7 @@ def test_create_user_rest_required_fields(request_type=service.CreateUserRequest response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_user(request) @@ -20506,6 +20567,7 @@ def test_create_user_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_user(**mock_args) @@ -20642,6 +20704,7 @@ def test_update_user_rest_required_fields(request_type=service.UpdateUserRequest response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_user(request) @@ -20702,6 +20765,7 @@ def test_update_user_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_user(**mock_args) @@ -20836,6 +20900,7 @@ def test_delete_user_rest_required_fields(request_type=service.DeleteUserRequest response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_user(request) @@ -20889,6 +20954,7 @@ def test_delete_user_rest_flattened(): json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_user(**mock_args) @@ -21026,6 +21092,7 @@ def test_list_databases_rest_required_fields(request_type=service.ListDatabasesR response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_databases(request) @@ -21082,6 +21149,7 @@ def test_list_databases_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_databases(**mock_args) @@ -23045,6 +23113,7 @@ def test_list_clusters_rest_bad_request(request_type=service.ListClustersRequest response_value.status_code = 400 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) @@ -23081,6 +23150,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. @@ -23120,6 +23190,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 = service.ListClustersResponse.to_json( service.ListClustersResponse() ) @@ -23164,6 +23235,7 @@ def test_get_cluster_rest_bad_request(request_type=service.GetClusterRequest): response_value.status_code = 400 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) @@ -23209,6 +23281,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. @@ -23257,6 +23330,7 @@ def test_get_cluster_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = resources.Cluster.to_json(resources.Cluster()) req.return_value.content = return_value @@ -23299,6 +23373,7 @@ def test_create_cluster_rest_bad_request(request_type=service.CreateClusterReque response_value.status_code = 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) @@ -23487,6 +23562,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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. @@ -23526,6 +23602,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 @@ -23570,6 +23647,7 @@ def test_update_cluster_rest_bad_request(request_type=service.UpdateClusterReque response_value.status_code = 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) @@ -23760,6 +23838,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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. @@ -23799,6 +23878,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 @@ -23841,6 +23921,7 @@ def test_upgrade_cluster_rest_bad_request(request_type=service.UpgradeClusterReq response_value.status_code = 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_cluster(request) @@ -23871,6 +23952,7 @@ def test_upgrade_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.upgrade_cluster(request) # Establish that the response is the type that we expect. @@ -23910,6 +23992,7 @@ def test_upgrade_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 @@ -23952,6 +24035,7 @@ def test_delete_cluster_rest_bad_request(request_type=service.DeleteClusterReque response_value.status_code = 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) @@ -23982,6 +24066,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. @@ -24021,6 +24106,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 @@ -24063,6 +24149,7 @@ def test_promote_cluster_rest_bad_request(request_type=service.PromoteClusterReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.promote_cluster(request) @@ -24093,6 +24180,7 @@ def test_promote_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.promote_cluster(request) # Establish that the response is the type that we expect. @@ -24132,6 +24220,7 @@ def test_promote_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 @@ -24176,6 +24265,7 @@ def test_switchover_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.switchover_cluster(request) @@ -24206,6 +24296,7 @@ def test_switchover_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.switchover_cluster(request) # Establish that the response is the type that we expect. @@ -24247,6 +24338,7 @@ def test_switchover_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 @@ -24289,6 +24381,7 @@ def test_restore_cluster_rest_bad_request(request_type=service.RestoreClusterReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.restore_cluster(request) @@ -24319,6 +24412,7 @@ def test_restore_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.restore_cluster(request) # Establish that the response is the type that we expect. @@ -24358,6 +24452,7 @@ def test_restore_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 @@ -24402,6 +24497,7 @@ def test_create_secondary_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_secondary_cluster(request) @@ -24590,6 +24686,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_secondary_cluster(request) # Establish that the response is the type that we expect. @@ -24631,6 +24728,7 @@ def test_create_secondary_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 @@ -24673,6 +24771,7 @@ def test_list_instances_rest_bad_request(request_type=service.ListInstancesReque response_value.status_code = 400 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) @@ -24709,6 +24808,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. @@ -24748,6 +24848,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 = service.ListInstancesResponse.to_json( service.ListInstancesResponse() ) @@ -24794,6 +24895,7 @@ def test_get_instance_rest_bad_request(request_type=service.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) @@ -24843,6 +24945,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. @@ -24895,6 +24998,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 = resources.Instance.to_json(resources.Instance()) req.return_value.content = return_value @@ -24937,6 +25041,7 @@ def test_create_instance_rest_bad_request(request_type=service.CreateInstanceReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_instance(request) @@ -25103,6 +25208,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_instance(request) # Establish that the response is the type that we expect. @@ -25142,6 +25248,7 @@ def test_create_instance_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -25186,6 +25293,7 @@ def test_create_secondary_instance_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_secondary_instance(request) @@ -25352,6 +25460,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_secondary_instance(request) # Establish that the response is the type that we expect. @@ -25393,6 +25502,7 @@ def test_create_secondary_instance_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -25437,6 +25547,7 @@ def test_batch_create_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.batch_create_instances(request) @@ -25615,6 +25726,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_instances(request) # Establish that the response is the type that we expect. @@ -25656,6 +25768,7 @@ def test_batch_create_instances_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -25702,6 +25815,7 @@ def test_update_instance_rest_bad_request(request_type=service.UpdateInstanceReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_instance(request) @@ -25872,6 +25986,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_instance(request) # Establish that the response is the type that we expect. @@ -25911,6 +26026,7 @@ def test_update_instance_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -25955,6 +26071,7 @@ def test_delete_instance_rest_bad_request(request_type=service.DeleteInstanceReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_instance(request) @@ -25987,6 +26104,7 @@ def test_delete_instance_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_instance(request) # Establish that the response is the type that we expect. @@ -26026,6 +26144,7 @@ def test_delete_instance_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -26072,6 +26191,7 @@ def test_failover_instance_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.failover_instance(request) @@ -26104,6 +26224,7 @@ def test_failover_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.failover_instance(request) # Establish that the response is the type that we expect. @@ -26145,6 +26266,7 @@ def test_failover_instance_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -26189,6 +26311,7 @@ def test_inject_fault_rest_bad_request(request_type=service.InjectFaultRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.inject_fault(request) @@ -26221,6 +26344,7 @@ def test_inject_fault_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.inject_fault(request) # Establish that the response is the type that we expect. @@ -26260,6 +26384,7 @@ def test_inject_fault_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -26304,6 +26429,7 @@ def test_restart_instance_rest_bad_request(request_type=service.RestartInstanceR response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.restart_instance(request) @@ -26336,6 +26462,7 @@ def test_restart_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.restart_instance(request) # Establish that the response is the type that we expect. @@ -26375,6 +26502,7 @@ def test_restart_instance_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -26419,6 +26547,7 @@ def test_execute_sql_rest_bad_request(request_type=service.ExecuteSqlRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.execute_sql(request) @@ -26454,6 +26583,7 @@ def test_execute_sql_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.execute_sql(request) # Establish that the response is the type that we expect. @@ -26491,6 +26621,7 @@ def test_execute_sql_rest_interceptors(null_interceptor): req.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.ExecuteSqlResponse.to_json(service.ExecuteSqlResponse()) req.return_value.content = return_value @@ -26533,6 +26664,7 @@ def test_list_backups_rest_bad_request(request_type=service.ListBackupsRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_backups(request) @@ -26569,6 +26701,7 @@ def test_list_backups_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_backups(request) # Establish that the response is the type that we expect. @@ -26608,6 +26741,7 @@ def test_list_backups_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = service.ListBackupsResponse.to_json( service.ListBackupsResponse() ) @@ -26652,6 +26786,7 @@ def test_get_backup_rest_bad_request(request_type=service.GetBackupRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_backup(request) @@ -26699,6 +26834,7 @@ def test_get_backup_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_backup(request) # Establish that the response is the type that we expect. @@ -26749,6 +26885,7 @@ def test_get_backup_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = resources.Backup.to_json(resources.Backup()) req.return_value.content = return_value @@ -26791,6 +26928,7 @@ def test_create_backup_rest_bad_request(request_type=service.CreateBackupRequest response_value.status_code = 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_backup(request) @@ -26916,6 +27054,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_backup(request) # Establish that the response is the type that we expect. @@ -26955,6 +27094,7 @@ def test_create_backup_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -26999,6 +27139,7 @@ def test_update_backup_rest_bad_request(request_type=service.UpdateBackupRequest response_value.status_code = 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_backup(request) @@ -27126,6 +27267,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_backup(request) # Establish that the response is the type that we expect. @@ -27165,6 +27307,7 @@ def test_update_backup_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -27207,6 +27350,7 @@ def test_delete_backup_rest_bad_request(request_type=service.DeleteBackupRequest response_value.status_code = 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_backup(request) @@ -27237,6 +27381,7 @@ def test_delete_backup_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_backup(request) # Establish that the response is the type that we expect. @@ -27276,6 +27421,7 @@ def test_delete_backup_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -27320,6 +27466,7 @@ def test_list_supported_database_flags_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_supported_database_flags(request) @@ -27355,6 +27502,7 @@ def test_list_supported_database_flags_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_supported_database_flags(request) # Establish that the response is the type that we expect. @@ -27395,6 +27543,7 @@ def test_list_supported_database_flags_rest_interceptors(null_interceptor): req.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.ListSupportedDatabaseFlagsResponse.to_json( service.ListSupportedDatabaseFlagsResponse() ) @@ -27441,6 +27590,7 @@ def test_generate_client_certificate_rest_bad_request( response_value.status_code = 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_client_certificate(request) @@ -27478,6 +27628,7 @@ def test_generate_client_certificate_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_client_certificate(request) # Establish that the response is the type that we expect. @@ -27520,6 +27671,7 @@ def test_generate_client_certificate_rest_interceptors(null_interceptor): req.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.GenerateClientCertificateResponse.to_json( service.GenerateClientCertificateResponse() ) @@ -27568,6 +27720,7 @@ def test_get_connection_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_connection_info(request) @@ -27610,6 +27763,7 @@ def test_get_connection_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_connection_info(request) # Establish that the response is the type that we expect. @@ -27655,6 +27809,7 @@ def test_get_connection_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 = resources.ConnectionInfo.to_json(resources.ConnectionInfo()) req.return_value.content = return_value @@ -27697,6 +27852,7 @@ def test_list_users_rest_bad_request(request_type=service.ListUsersRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_users(request) @@ -27733,6 +27889,7 @@ def test_list_users_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_users(request) # Establish that the response is the type that we expect. @@ -27772,6 +27929,7 @@ def test_list_users_rest_interceptors(null_interceptor): req.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.ListUsersResponse.to_json(service.ListUsersResponse()) req.return_value.content = return_value @@ -27816,6 +27974,7 @@ def test_get_user_rest_bad_request(request_type=service.GetUserRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_user(request) @@ -27857,6 +28016,7 @@ def test_get_user_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_user(request) # Establish that the response is the type that we expect. @@ -27899,6 +28059,7 @@ def test_get_user_rest_interceptors(null_interceptor): req.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.User.to_json(resources.User()) req.return_value.content = return_value @@ -27941,6 +28102,7 @@ def test_create_user_rest_bad_request(request_type=service.CreateUserRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_user(request) @@ -28054,6 +28216,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_user(request) # Establish that the response is the type that we expect. @@ -28096,6 +28259,7 @@ def test_create_user_rest_interceptors(null_interceptor): req.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.User.to_json(resources.User()) req.return_value.content = return_value @@ -28142,6 +28306,7 @@ def test_update_user_rest_bad_request(request_type=service.UpdateUserRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_user(request) @@ -28259,6 +28424,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_user(request) # Establish that the response is the type that we expect. @@ -28301,6 +28467,7 @@ def test_update_user_rest_interceptors(null_interceptor): req.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.User.to_json(resources.User()) req.return_value.content = return_value @@ -28345,6 +28512,7 @@ def test_delete_user_rest_bad_request(request_type=service.DeleteUserRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_user(request) @@ -28377,6 +28545,7 @@ def test_delete_user_rest_call_success(request_type): json_return_value = "" response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_user(request) # Establish that the response is the type that we expect. @@ -28411,6 +28580,7 @@ def test_delete_user_rest_interceptors(null_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.DeleteUserRequest() metadata = [ @@ -28449,6 +28619,7 @@ def test_list_databases_rest_bad_request(request_type=service.ListDatabasesReque response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_databases(request) @@ -28484,6 +28655,7 @@ def test_list_databases_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_databases(request) # Establish that the response is the type that we expect. @@ -28522,6 +28694,7 @@ def test_list_databases_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = service.ListDatabasesResponse.to_json( service.ListDatabasesResponse() ) @@ -28568,6 +28741,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) @@ -28598,6 +28772,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) @@ -28626,6 +28801,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) @@ -28656,6 +28832,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) @@ -28686,6 +28863,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) @@ -28716,6 +28894,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) @@ -28746,6 +28925,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) @@ -28776,6 +28956,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) @@ -28806,6 +28987,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) @@ -28836,6 +29018,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) @@ -28866,6 +29049,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) @@ -28896,6 +29080,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-api-gateway/google/cloud/apigateway/gapic_version.py b/packages/google-cloud-api-gateway/google/cloud/apigateway/gapic_version.py index f1d827b5c728..558c8aab67c5 100644 --- a/packages/google-cloud-api-gateway/google/cloud/apigateway/gapic_version.py +++ b/packages/google-cloud-api-gateway/google/cloud/apigateway/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.10.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-api-gateway/google/cloud/apigateway_v1/gapic_version.py b/packages/google-cloud-api-gateway/google/cloud/apigateway_v1/gapic_version.py index f1d827b5c728..558c8aab67c5 100644 --- a/packages/google-cloud-api-gateway/google/cloud/apigateway_v1/gapic_version.py +++ b/packages/google-cloud-api-gateway/google/cloud/apigateway_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.10.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-api-gateway/google/cloud/apigateway_v1/services/api_gateway_service/async_client.py b/packages/google-cloud-api-gateway/google/cloud/apigateway_v1/services/api_gateway_service/async_client.py index 1a2af4b47dea..e7f46b5f3470 100644 --- a/packages/google-cloud-api-gateway/google/cloud/apigateway_v1/services/api_gateway_service/async_client.py +++ b/packages/google-cloud-api-gateway/google/cloud/apigateway_v1/services/api_gateway_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, ApiGatewayServiceTransport from .transports.grpc_asyncio import ApiGatewayServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class ApiGatewayServiceAsyncClient: """The API Gateway Service is the interface for managing API @@ -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.apigateway_v1.ApiGatewayServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.apigateway.v1.ApiGatewayService", + "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.apigateway.v1.ApiGatewayService", + "credentialsType": None, + }, + ) + async def list_gateways( self, request: Optional[Union[apigateway.ListGatewaysRequest, dict]] = None, @@ -287,7 +319,7 @@ async def list_gateways( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListGatewaysAsyncPager: r"""Lists Gateways in a given project and location. @@ -332,8 +364,10 @@ async def sample_list_gateways(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigateway_v1.services.api_gateway_service.pagers.ListGatewaysAsyncPager: @@ -408,7 +442,7 @@ async def get_gateway( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apigateway.Gateway: r"""Gets details of a single Gateway. @@ -452,8 +486,10 @@ async def sample_get_gateway(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigateway_v1.types.Gateway: @@ -520,7 +556,7 @@ async def create_gateway( gateway_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 Gateway in a given project and location. @@ -587,8 +623,10 @@ async def sample_create_gateway(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -666,7 +704,7 @@ async def update_gateway( 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 Gateway. @@ -726,8 +764,10 @@ async def sample_update_gateway(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -804,7 +844,7 @@ async def delete_gateway( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 Gateway. @@ -852,8 +892,10 @@ async def sample_delete_gateway(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -932,7 +974,7 @@ async def list_apis( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListApisAsyncPager: r"""Lists Apis in a given project and location. @@ -977,8 +1019,10 @@ async def sample_list_apis(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigateway_v1.services.api_gateway_service.pagers.ListApisAsyncPager: @@ -1053,7 +1097,7 @@ async def get_api( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apigateway.Api: r"""Gets details of a single Api. @@ -1097,8 +1141,10 @@ async def sample_get_api(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigateway_v1.types.Api: @@ -1159,7 +1205,7 @@ async def create_api( api_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 Api in a given project and location. @@ -1221,8 +1267,10 @@ async def sample_create_api(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -1299,7 +1347,7 @@ async def update_api( 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 Api. @@ -1355,8 +1403,10 @@ async def sample_update_api(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -1430,7 +1480,7 @@ async def delete_api( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 Api. @@ -1478,8 +1528,10 @@ async def sample_delete_api(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -1558,7 +1610,7 @@ async def list_api_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.ListApiConfigsAsyncPager: r"""Lists ApiConfigs in a given project and location. @@ -1603,8 +1655,10 @@ async def sample_list_api_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.apigateway_v1.services.api_gateway_service.pagers.ListApiConfigsAsyncPager: @@ -1679,7 +1733,7 @@ async def get_api_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]]] = (), ) -> apigateway.ApiConfig: r"""Gets details of a single ApiConfig. @@ -1723,8 +1777,10 @@ async def sample_get_api_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.apigateway_v1.types.ApiConfig: @@ -1788,7 +1844,7 @@ async def create_api_config( api_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 ApiConfig in a given project and location. @@ -1851,8 +1907,10 @@ async def sample_create_api_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: @@ -1928,7 +1986,7 @@ async def update_api_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 parameters of a single ApiConfig. @@ -1984,8 +2042,10 @@ async def sample_update_api_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: @@ -2060,7 +2120,7 @@ async def delete_api_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 a single ApiConfig. @@ -2108,8 +2168,10 @@ async def sample_delete_api_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: diff --git a/packages/google-cloud-api-gateway/google/cloud/apigateway_v1/services/api_gateway_service/client.py b/packages/google-cloud-api-gateway/google/cloud/apigateway_v1/services/api_gateway_service/client.py index 83f187d100d2..d32a2005b0a7 100644 --- a/packages/google-cloud-api-gateway/google/cloud/apigateway_v1/services/api_gateway_service/client.py +++ b/packages/google-cloud-api-gateway/google/cloud/apigateway_v1/services/api_gateway_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.protobuf import empty_pb2 # type: ignore @@ -683,6 +693,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( @@ -749,6 +763,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.apigateway_v1.ApiGatewayServiceClient`.", + extra={ + "serviceName": "google.cloud.apigateway.v1.ApiGatewayService", + "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.apigateway.v1.ApiGatewayService", + "credentialsType": None, + }, + ) + def list_gateways( self, request: Optional[Union[apigateway.ListGatewaysRequest, dict]] = None, @@ -756,7 +793,7 @@ def list_gateways( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListGatewaysPager: r"""Lists Gateways in a given project and location. @@ -801,8 +838,10 @@ def sample_list_gateways(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigateway_v1.services.api_gateway_service.pagers.ListGatewaysPager: @@ -874,7 +913,7 @@ def get_gateway( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apigateway.Gateway: r"""Gets details of a single Gateway. @@ -918,8 +957,10 @@ def sample_get_gateway(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigateway_v1.types.Gateway: @@ -983,7 +1024,7 @@ def create_gateway( gateway_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 Gateway in a given project and location. @@ -1050,8 +1091,10 @@ def sample_create_gateway(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -1126,7 +1169,7 @@ def update_gateway( 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 Gateway. @@ -1186,8 +1229,10 @@ def sample_update_gateway(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -1261,7 +1306,7 @@ def delete_gateway( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 Gateway. @@ -1309,8 +1354,10 @@ def sample_delete_gateway(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -1386,7 +1433,7 @@ def list_apis( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListApisPager: r"""Lists Apis in a given project and location. @@ -1431,8 +1478,10 @@ def sample_list_apis(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigateway_v1.services.api_gateway_service.pagers.ListApisPager: @@ -1504,7 +1553,7 @@ def get_api( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apigateway.Api: r"""Gets details of a single Api. @@ -1548,8 +1597,10 @@ def sample_get_api(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigateway_v1.types.Api: @@ -1609,7 +1660,7 @@ def create_api( api_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 Api in a given project and location. @@ -1671,8 +1722,10 @@ def sample_create_api(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -1746,7 +1799,7 @@ def update_api( 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 Api. @@ -1802,8 +1855,10 @@ def sample_update_api(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `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 +1929,7 @@ def delete_api( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 Api. @@ -1922,8 +1977,10 @@ def sample_delete_api(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -1999,7 +2056,7 @@ def list_api_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.ListApiConfigsPager: r"""Lists ApiConfigs in a given project and location. @@ -2044,8 +2101,10 @@ def sample_list_api_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.apigateway_v1.services.api_gateway_service.pagers.ListApiConfigsPager: @@ -2117,7 +2176,7 @@ def get_api_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]]] = (), ) -> apigateway.ApiConfig: r"""Gets details of a single ApiConfig. @@ -2161,8 +2220,10 @@ def sample_get_api_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.apigateway_v1.types.ApiConfig: @@ -2223,7 +2284,7 @@ def create_api_config( api_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 ApiConfig in a given project and location. @@ -2286,8 +2347,10 @@ def sample_create_api_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: @@ -2360,7 +2423,7 @@ def update_api_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 parameters of a single ApiConfig. @@ -2416,8 +2479,10 @@ def sample_update_api_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: @@ -2489,7 +2554,7 @@ def delete_api_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 a single ApiConfig. @@ -2537,8 +2602,10 @@ def sample_delete_api_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: diff --git a/packages/google-cloud-api-gateway/google/cloud/apigateway_v1/services/api_gateway_service/pagers.py b/packages/google-cloud-api-gateway/google/cloud/apigateway_v1/services/api_gateway_service/pagers.py index 314c145f8a22..ce7a4c6d3ea2 100644 --- a/packages/google-cloud-api-gateway/google/cloud/apigateway_v1/services/api_gateway_service/pagers.py +++ b/packages/google-cloud-api-gateway/google/cloud/apigateway_v1/services/api_gateway_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 = apigateway.ListGatewaysRequest(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 = apigateway.ListGatewaysRequest(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 = apigateway.ListApisRequest(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 = apigateway.ListApisRequest(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 = apigateway.ListApiConfigsRequest(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 = apigateway.ListApiConfigsRequest(request) diff --git a/packages/google-cloud-api-gateway/google/cloud/apigateway_v1/services/api_gateway_service/transports/grpc.py b/packages/google-cloud-api-gateway/google/cloud/apigateway_v1/services/api_gateway_service/transports/grpc.py index b00923f520ca..5ab5c4ed1e06 100644 --- a/packages/google-cloud-api-gateway/google/cloud/apigateway_v1/services/api_gateway_service/transports/grpc.py +++ b/packages/google-cloud-api-gateway/google/cloud/apigateway_v1/services/api_gateway_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.apigateway_v1.types import apigateway from .base import DEFAULT_CLIENT_INFO, ApiGatewayServiceTransport +try: + from google.api_core import client_logging # 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.apigateway.v1.ApiGatewayService", + "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.apigateway.v1.ApiGatewayService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ApiGatewayServiceGrpcTransport(ApiGatewayServiceTransport): """gRPC backend transport for ApiGatewayService. @@ -182,7 +263,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientInterceptor() + self._logged_channel = grpc.intercept_channel( + self._grpc_channel, self._interceptor + ) + + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @classmethod @@ -246,7 +332,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -270,7 +358,7 @@ def list_gateways( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_gateways" not in self._stubs: - self._stubs["list_gateways"] = self.grpc_channel.unary_unary( + self._stubs["list_gateways"] = self._logged_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/ListGateways", request_serializer=apigateway.ListGatewaysRequest.serialize, response_deserializer=apigateway.ListGatewaysResponse.deserialize, @@ -296,7 +384,7 @@ def get_gateway( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_gateway" not in self._stubs: - self._stubs["get_gateway"] = self.grpc_channel.unary_unary( + self._stubs["get_gateway"] = self._logged_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/GetGateway", request_serializer=apigateway.GetGatewayRequest.serialize, response_deserializer=apigateway.Gateway.deserialize, @@ -323,7 +411,7 @@ def create_gateway( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_gateway" not in self._stubs: - self._stubs["create_gateway"] = self.grpc_channel.unary_unary( + self._stubs["create_gateway"] = self._logged_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/CreateGateway", request_serializer=apigateway.CreateGatewayRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -349,7 +437,7 @@ def update_gateway( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_gateway" not in self._stubs: - self._stubs["update_gateway"] = self.grpc_channel.unary_unary( + self._stubs["update_gateway"] = self._logged_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/UpdateGateway", request_serializer=apigateway.UpdateGatewayRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -375,7 +463,7 @@ def delete_gateway( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_gateway" not in self._stubs: - self._stubs["delete_gateway"] = self.grpc_channel.unary_unary( + self._stubs["delete_gateway"] = self._logged_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/DeleteGateway", request_serializer=apigateway.DeleteGatewayRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -401,7 +489,7 @@ def list_apis( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_apis" not in self._stubs: - self._stubs["list_apis"] = self.grpc_channel.unary_unary( + self._stubs["list_apis"] = self._logged_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/ListApis", request_serializer=apigateway.ListApisRequest.serialize, response_deserializer=apigateway.ListApisResponse.deserialize, @@ -425,7 +513,7 @@ def get_api(self) -> Callable[[apigateway.GetApiRequest], apigateway.Api]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_api" not in self._stubs: - self._stubs["get_api"] = self.grpc_channel.unary_unary( + self._stubs["get_api"] = self._logged_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/GetApi", request_serializer=apigateway.GetApiRequest.serialize, response_deserializer=apigateway.Api.deserialize, @@ -451,7 +539,7 @@ def create_api( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_api" not in self._stubs: - self._stubs["create_api"] = self.grpc_channel.unary_unary( + self._stubs["create_api"] = self._logged_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/CreateApi", request_serializer=apigateway.CreateApiRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -477,7 +565,7 @@ def update_api( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_api" not in self._stubs: - self._stubs["update_api"] = self.grpc_channel.unary_unary( + self._stubs["update_api"] = self._logged_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/UpdateApi", request_serializer=apigateway.UpdateApiRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -503,7 +591,7 @@ def delete_api( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_api" not in self._stubs: - self._stubs["delete_api"] = self.grpc_channel.unary_unary( + self._stubs["delete_api"] = self._logged_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/DeleteApi", request_serializer=apigateway.DeleteApiRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -531,7 +619,7 @@ def list_api_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_api_configs" not in self._stubs: - self._stubs["list_api_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_api_configs"] = self._logged_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/ListApiConfigs", request_serializer=apigateway.ListApiConfigsRequest.serialize, response_deserializer=apigateway.ListApiConfigsResponse.deserialize, @@ -557,7 +645,7 @@ def get_api_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_api_config" not in self._stubs: - self._stubs["get_api_config"] = self.grpc_channel.unary_unary( + self._stubs["get_api_config"] = self._logged_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/GetApiConfig", request_serializer=apigateway.GetApiConfigRequest.serialize, response_deserializer=apigateway.ApiConfig.deserialize, @@ -584,7 +672,7 @@ def create_api_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_api_config" not in self._stubs: - self._stubs["create_api_config"] = self.grpc_channel.unary_unary( + self._stubs["create_api_config"] = self._logged_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/CreateApiConfig", request_serializer=apigateway.CreateApiConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -610,7 +698,7 @@ def update_api_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_api_config" not in self._stubs: - self._stubs["update_api_config"] = self.grpc_channel.unary_unary( + self._stubs["update_api_config"] = self._logged_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/UpdateApiConfig", request_serializer=apigateway.UpdateApiConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -636,7 +724,7 @@ def delete_api_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_api_config" not in self._stubs: - self._stubs["delete_api_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_api_config"] = self._logged_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/DeleteApiConfig", request_serializer=apigateway.DeleteApiConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -644,7 +732,7 @@ def delete_api_config( return self._stubs["delete_api_config"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-api-gateway/google/cloud/apigateway_v1/services/api_gateway_service/transports/grpc_asyncio.py b/packages/google-cloud-api-gateway/google/cloud/apigateway_v1/services/api_gateway_service/transports/grpc_asyncio.py index 0bfbb3c25dee..cd0acee81d91 100644 --- a/packages/google-cloud-api-gateway/google/cloud/apigateway_v1/services/api_gateway_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-api-gateway/google/cloud/apigateway_v1/services/api_gateway_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.apigateway_v1.types import apigateway from .base import DEFAULT_CLIENT_INFO, ApiGatewayServiceTransport from .grpc import ApiGatewayServiceGrpcTransport +try: + from google.api_core import client_logging # 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.apigateway.v1.ApiGatewayService", + "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.apigateway.v1.ApiGatewayService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ApiGatewayServiceGrpcAsyncIOTransport(ApiGatewayServiceTransport): """gRPC AsyncIO backend transport for ApiGatewayService. @@ -229,10 +311,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientAIOInterceptor() + self._grpc_channel._unary_unary_interceptors.append(self._interceptor) + self._logged_channel = self._grpc_channel self._wrap_with_kind = ( "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters ) + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @property @@ -255,7 +340,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -282,7 +367,7 @@ def list_gateways( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_gateways" not in self._stubs: - self._stubs["list_gateways"] = self.grpc_channel.unary_unary( + self._stubs["list_gateways"] = self._logged_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/ListGateways", request_serializer=apigateway.ListGatewaysRequest.serialize, response_deserializer=apigateway.ListGatewaysResponse.deserialize, @@ -308,7 +393,7 @@ def get_gateway( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_gateway" not in self._stubs: - self._stubs["get_gateway"] = self.grpc_channel.unary_unary( + self._stubs["get_gateway"] = self._logged_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/GetGateway", request_serializer=apigateway.GetGatewayRequest.serialize, response_deserializer=apigateway.Gateway.deserialize, @@ -337,7 +422,7 @@ def create_gateway( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_gateway" not in self._stubs: - self._stubs["create_gateway"] = self.grpc_channel.unary_unary( + self._stubs["create_gateway"] = self._logged_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/CreateGateway", request_serializer=apigateway.CreateGatewayRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -365,7 +450,7 @@ def update_gateway( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_gateway" not in self._stubs: - self._stubs["update_gateway"] = self.grpc_channel.unary_unary( + self._stubs["update_gateway"] = self._logged_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/UpdateGateway", request_serializer=apigateway.UpdateGatewayRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -393,7 +478,7 @@ def delete_gateway( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_gateway" not in self._stubs: - self._stubs["delete_gateway"] = self.grpc_channel.unary_unary( + self._stubs["delete_gateway"] = self._logged_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/DeleteGateway", request_serializer=apigateway.DeleteGatewayRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -419,7 +504,7 @@ def list_apis( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_apis" not in self._stubs: - self._stubs["list_apis"] = self.grpc_channel.unary_unary( + self._stubs["list_apis"] = self._logged_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/ListApis", request_serializer=apigateway.ListApisRequest.serialize, response_deserializer=apigateway.ListApisResponse.deserialize, @@ -445,7 +530,7 @@ def get_api( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_api" not in self._stubs: - self._stubs["get_api"] = self.grpc_channel.unary_unary( + self._stubs["get_api"] = self._logged_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/GetApi", request_serializer=apigateway.GetApiRequest.serialize, response_deserializer=apigateway.Api.deserialize, @@ -471,7 +556,7 @@ def create_api( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_api" not in self._stubs: - self._stubs["create_api"] = self.grpc_channel.unary_unary( + self._stubs["create_api"] = self._logged_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/CreateApi", request_serializer=apigateway.CreateApiRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -497,7 +582,7 @@ def update_api( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_api" not in self._stubs: - self._stubs["update_api"] = self.grpc_channel.unary_unary( + self._stubs["update_api"] = self._logged_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/UpdateApi", request_serializer=apigateway.UpdateApiRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -523,7 +608,7 @@ def delete_api( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_api" not in self._stubs: - self._stubs["delete_api"] = self.grpc_channel.unary_unary( + self._stubs["delete_api"] = self._logged_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/DeleteApi", request_serializer=apigateway.DeleteApiRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -551,7 +636,7 @@ def list_api_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_api_configs" not in self._stubs: - self._stubs["list_api_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_api_configs"] = self._logged_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/ListApiConfigs", request_serializer=apigateway.ListApiConfigsRequest.serialize, response_deserializer=apigateway.ListApiConfigsResponse.deserialize, @@ -577,7 +662,7 @@ def get_api_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_api_config" not in self._stubs: - self._stubs["get_api_config"] = self.grpc_channel.unary_unary( + self._stubs["get_api_config"] = self._logged_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/GetApiConfig", request_serializer=apigateway.GetApiConfigRequest.serialize, response_deserializer=apigateway.ApiConfig.deserialize, @@ -606,7 +691,7 @@ def create_api_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_api_config" not in self._stubs: - self._stubs["create_api_config"] = self.grpc_channel.unary_unary( + self._stubs["create_api_config"] = self._logged_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/CreateApiConfig", request_serializer=apigateway.CreateApiConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -634,7 +719,7 @@ def update_api_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_api_config" not in self._stubs: - self._stubs["update_api_config"] = self.grpc_channel.unary_unary( + self._stubs["update_api_config"] = self._logged_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/UpdateApiConfig", request_serializer=apigateway.UpdateApiConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -662,7 +747,7 @@ def delete_api_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_api_config" not in self._stubs: - self._stubs["delete_api_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_api_config"] = self._logged_channel.unary_unary( "/google.cloud.apigateway.v1.ApiGatewayService/DeleteApiConfig", request_serializer=apigateway.DeleteApiConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -845,7 +930,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-api-gateway/google/cloud/apigateway_v1/services/api_gateway_service/transports/rest.py b/packages/google-cloud-api-gateway/google/cloud/apigateway_v1/services/api_gateway_service/transports/rest.py index 75507300e12b..ca7f2fcc2254 100644 --- a/packages/google-cloud-api-gateway/google/cloud/apigateway_v1/services/api_gateway_service/transports/rest.py +++ b/packages/google-cloud-api-gateway/google/cloud/apigateway_v1/services/api_gateway_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, @@ -188,8 +196,10 @@ def post_update_gateway(self, response): """ def pre_create_api( - self, request: apigateway.CreateApiRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[apigateway.CreateApiRequest, Sequence[Tuple[str, str]]]: + self, + request: apigateway.CreateApiRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[apigateway.CreateApiRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_api Override in a subclass to manipulate the request or metadata @@ -211,8 +221,10 @@ def post_create_api( def pre_create_api_config( self, request: apigateway.CreateApiConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apigateway.CreateApiConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apigateway.CreateApiConfigRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_api_config Override in a subclass to manipulate the request or metadata @@ -234,8 +246,10 @@ def post_create_api_config( def pre_create_gateway( self, request: apigateway.CreateGatewayRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apigateway.CreateGatewayRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apigateway.CreateGatewayRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_gateway Override in a subclass to manipulate the request or metadata @@ -255,8 +269,10 @@ def post_create_gateway( return response def pre_delete_api( - self, request: apigateway.DeleteApiRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[apigateway.DeleteApiRequest, Sequence[Tuple[str, str]]]: + self, + request: apigateway.DeleteApiRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[apigateway.DeleteApiRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_api Override in a subclass to manipulate the request or metadata @@ -278,8 +294,10 @@ def post_delete_api( def pre_delete_api_config( self, request: apigateway.DeleteApiConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apigateway.DeleteApiConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apigateway.DeleteApiConfigRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_api_config Override in a subclass to manipulate the request or metadata @@ -301,8 +319,10 @@ def post_delete_api_config( def pre_delete_gateway( self, request: apigateway.DeleteGatewayRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apigateway.DeleteGatewayRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apigateway.DeleteGatewayRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_gateway Override in a subclass to manipulate the request or metadata @@ -322,8 +342,10 @@ def post_delete_gateway( return response def pre_get_api( - self, request: apigateway.GetApiRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[apigateway.GetApiRequest, Sequence[Tuple[str, str]]]: + self, + request: apigateway.GetApiRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[apigateway.GetApiRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_api Override in a subclass to manipulate the request or metadata @@ -343,8 +365,8 @@ def post_get_api(self, response: apigateway.Api) -> apigateway.Api: def pre_get_api_config( self, request: apigateway.GetApiConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apigateway.GetApiConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[apigateway.GetApiConfigRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_api_config Override in a subclass to manipulate the request or metadata @@ -364,8 +386,10 @@ def post_get_api_config( return response def pre_get_gateway( - self, request: apigateway.GetGatewayRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[apigateway.GetGatewayRequest, Sequence[Tuple[str, str]]]: + self, + request: apigateway.GetGatewayRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[apigateway.GetGatewayRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_gateway Override in a subclass to manipulate the request or metadata @@ -385,8 +409,10 @@ def post_get_gateway(self, response: apigateway.Gateway) -> apigateway.Gateway: def pre_list_api_configs( self, request: apigateway.ListApiConfigsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apigateway.ListApiConfigsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apigateway.ListApiConfigsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_api_configs Override in a subclass to manipulate the request or metadata @@ -406,8 +432,10 @@ def post_list_api_configs( return response def pre_list_apis( - self, request: apigateway.ListApisRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[apigateway.ListApisRequest, Sequence[Tuple[str, str]]]: + self, + request: apigateway.ListApisRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[apigateway.ListApisRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_apis Override in a subclass to manipulate the request or metadata @@ -429,8 +457,8 @@ def post_list_apis( def pre_list_gateways( self, request: apigateway.ListGatewaysRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apigateway.ListGatewaysRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[apigateway.ListGatewaysRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_gateways Override in a subclass to manipulate the request or metadata @@ -450,8 +478,10 @@ def post_list_gateways( return response def pre_update_api( - self, request: apigateway.UpdateApiRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[apigateway.UpdateApiRequest, Sequence[Tuple[str, str]]]: + self, + request: apigateway.UpdateApiRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[apigateway.UpdateApiRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_api Override in a subclass to manipulate the request or metadata @@ -473,8 +503,10 @@ def post_update_api( def pre_update_api_config( self, request: apigateway.UpdateApiConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apigateway.UpdateApiConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apigateway.UpdateApiConfigRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_api_config Override in a subclass to manipulate the request or metadata @@ -496,8 +528,10 @@ def post_update_api_config( def pre_update_gateway( self, request: apigateway.UpdateGatewayRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apigateway.UpdateGatewayRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apigateway.UpdateGatewayRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_gateway Override in a subclass to manipulate the request or metadata @@ -693,7 +727,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create api method over HTTP. @@ -704,8 +738,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -718,6 +754,7 @@ def __call__( http_options = ( _BaseApiGatewayServiceRestTransport._BaseCreateApi._get_http_options() ) + request, metadata = self._interceptor.pre_create_api(request, metadata) transcoded_request = _BaseApiGatewayServiceRestTransport._BaseCreateApi._get_transcoded_request( http_options, request @@ -732,6 +769,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigateway_v1.ApiGatewayServiceClient.CreateApi", + extra={ + "serviceName": "google.cloud.apigateway.v1.ApiGatewayService", + "rpcName": "CreateApi", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiGatewayServiceRestTransport._CreateApi._get_response( self._host, @@ -751,7 +815,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_api(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigateway_v1.ApiGatewayServiceClient.create_api", + extra={ + "serviceName": "google.cloud.apigateway.v1.ApiGatewayService", + "rpcName": "CreateApi", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateApiConfig( @@ -790,7 +876,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 api config method over HTTP. @@ -801,8 +887,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -815,6 +903,7 @@ def __call__( http_options = ( _BaseApiGatewayServiceRestTransport._BaseCreateApiConfig._get_http_options() ) + request, metadata = self._interceptor.pre_create_api_config( request, metadata ) @@ -831,6 +920,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigateway_v1.ApiGatewayServiceClient.CreateApiConfig", + extra={ + "serviceName": "google.cloud.apigateway.v1.ApiGatewayService", + "rpcName": "CreateApiConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiGatewayServiceRestTransport._CreateApiConfig._get_response( self._host, @@ -850,7 +966,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_api_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.apigateway_v1.ApiGatewayServiceClient.create_api_config", + extra={ + "serviceName": "google.cloud.apigateway.v1.ApiGatewayService", + "rpcName": "CreateApiConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateGateway( @@ -889,7 +1027,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create gateway method over HTTP. @@ -900,8 +1038,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -914,6 +1054,7 @@ def __call__( http_options = ( _BaseApiGatewayServiceRestTransport._BaseCreateGateway._get_http_options() ) + request, metadata = self._interceptor.pre_create_gateway(request, metadata) transcoded_request = _BaseApiGatewayServiceRestTransport._BaseCreateGateway._get_transcoded_request( http_options, request @@ -928,6 +1069,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigateway_v1.ApiGatewayServiceClient.CreateGateway", + extra={ + "serviceName": "google.cloud.apigateway.v1.ApiGatewayService", + "rpcName": "CreateGateway", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiGatewayServiceRestTransport._CreateGateway._get_response( self._host, @@ -947,7 +1115,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_gateway(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigateway_v1.ApiGatewayServiceClient.create_gateway", + extra={ + "serviceName": "google.cloud.apigateway.v1.ApiGatewayService", + "rpcName": "CreateGateway", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteApi( @@ -984,7 +1174,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete api method over HTTP. @@ -995,8 +1185,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1009,6 +1201,7 @@ def __call__( http_options = ( _BaseApiGatewayServiceRestTransport._BaseDeleteApi._get_http_options() ) + request, metadata = self._interceptor.pre_delete_api(request, metadata) transcoded_request = _BaseApiGatewayServiceRestTransport._BaseDeleteApi._get_transcoded_request( http_options, request @@ -1019,6 +1212,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigateway_v1.ApiGatewayServiceClient.DeleteApi", + extra={ + "serviceName": "google.cloud.apigateway.v1.ApiGatewayService", + "rpcName": "DeleteApi", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiGatewayServiceRestTransport._DeleteApi._get_response( self._host, @@ -1037,7 +1257,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_api(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigateway_v1.ApiGatewayServiceClient.delete_api", + extra={ + "serviceName": "google.cloud.apigateway.v1.ApiGatewayService", + "rpcName": "DeleteApi", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteApiConfig( @@ -1075,7 +1317,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 api config method over HTTP. @@ -1086,8 +1328,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1100,6 +1344,7 @@ def __call__( http_options = ( _BaseApiGatewayServiceRestTransport._BaseDeleteApiConfig._get_http_options() ) + request, metadata = self._interceptor.pre_delete_api_config( request, metadata ) @@ -1112,6 +1357,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigateway_v1.ApiGatewayServiceClient.DeleteApiConfig", + extra={ + "serviceName": "google.cloud.apigateway.v1.ApiGatewayService", + "rpcName": "DeleteApiConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiGatewayServiceRestTransport._DeleteApiConfig._get_response( self._host, @@ -1130,7 +1402,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_api_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.apigateway_v1.ApiGatewayServiceClient.delete_api_config", + extra={ + "serviceName": "google.cloud.apigateway.v1.ApiGatewayService", + "rpcName": "DeleteApiConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteGateway( @@ -1168,7 +1462,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 gateway method over HTTP. @@ -1179,8 +1473,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1193,6 +1489,7 @@ def __call__( http_options = ( _BaseApiGatewayServiceRestTransport._BaseDeleteGateway._get_http_options() ) + request, metadata = self._interceptor.pre_delete_gateway(request, metadata) transcoded_request = _BaseApiGatewayServiceRestTransport._BaseDeleteGateway._get_transcoded_request( http_options, request @@ -1203,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 = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigateway_v1.ApiGatewayServiceClient.DeleteGateway", + extra={ + "serviceName": "google.cloud.apigateway.v1.ApiGatewayService", + "rpcName": "DeleteGateway", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiGatewayServiceRestTransport._DeleteGateway._get_response( self._host, @@ -1221,7 +1545,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_gateway(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigateway_v1.ApiGatewayServiceClient.delete_gateway", + extra={ + "serviceName": "google.cloud.apigateway.v1.ApiGatewayService", + "rpcName": "DeleteGateway", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetApi( @@ -1258,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]]] = (), ) -> apigateway.Api: r"""Call the get api method over HTTP. @@ -1269,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: ~.apigateway.Api: @@ -1282,6 +1630,7 @@ def __call__( http_options = ( _BaseApiGatewayServiceRestTransport._BaseGetApi._get_http_options() ) + request, metadata = self._interceptor.pre_get_api(request, metadata) transcoded_request = ( _BaseApiGatewayServiceRestTransport._BaseGetApi._get_transcoded_request( @@ -1296,6 +1645,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigateway_v1.ApiGatewayServiceClient.GetApi", + extra={ + "serviceName": "google.cloud.apigateway.v1.ApiGatewayService", + "rpcName": "GetApi", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiGatewayServiceRestTransport._GetApi._get_response( self._host, @@ -1316,7 +1692,29 @@ def __call__( pb_resp = apigateway.Api.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_api(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = apigateway.Api.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigateway_v1.ApiGatewayServiceClient.get_api", + extra={ + "serviceName": "google.cloud.apigateway.v1.ApiGatewayService", + "rpcName": "GetApi", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetApiConfig( @@ -1353,7 +1751,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apigateway.ApiConfig: r"""Call the get api config method over HTTP. @@ -1364,8 +1762,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.apigateway.ApiConfig: @@ -1378,6 +1778,7 @@ def __call__( http_options = ( _BaseApiGatewayServiceRestTransport._BaseGetApiConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_api_config(request, metadata) transcoded_request = _BaseApiGatewayServiceRestTransport._BaseGetApiConfig._get_transcoded_request( http_options, request @@ -1388,6 +1789,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigateway_v1.ApiGatewayServiceClient.GetApiConfig", + extra={ + "serviceName": "google.cloud.apigateway.v1.ApiGatewayService", + "rpcName": "GetApiConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiGatewayServiceRestTransport._GetApiConfig._get_response( self._host, @@ -1408,7 +1836,29 @@ def __call__( pb_resp = apigateway.ApiConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_api_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = apigateway.ApiConfig.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigateway_v1.ApiGatewayServiceClient.get_api_config", + extra={ + "serviceName": "google.cloud.apigateway.v1.ApiGatewayService", + "rpcName": "GetApiConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetGateway( @@ -1445,7 +1895,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apigateway.Gateway: r"""Call the get gateway method over HTTP. @@ -1456,8 +1906,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.apigateway.Gateway: @@ -1473,6 +1925,7 @@ def __call__( http_options = ( _BaseApiGatewayServiceRestTransport._BaseGetGateway._get_http_options() ) + request, metadata = self._interceptor.pre_get_gateway(request, metadata) transcoded_request = _BaseApiGatewayServiceRestTransport._BaseGetGateway._get_transcoded_request( http_options, request @@ -1483,6 +1936,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigateway_v1.ApiGatewayServiceClient.GetGateway", + extra={ + "serviceName": "google.cloud.apigateway.v1.ApiGatewayService", + "rpcName": "GetGateway", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiGatewayServiceRestTransport._GetGateway._get_response( self._host, @@ -1503,7 +1983,29 @@ def __call__( pb_resp = apigateway.Gateway.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_gateway(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = apigateway.Gateway.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigateway_v1.ApiGatewayServiceClient.get_gateway", + extra={ + "serviceName": "google.cloud.apigateway.v1.ApiGatewayService", + "rpcName": "GetGateway", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListApiConfigs( @@ -1541,7 +2043,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apigateway.ListApiConfigsResponse: r"""Call the list api configs method over HTTP. @@ -1552,8 +2054,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.apigateway.ListApiConfigsResponse: @@ -1565,6 +2069,7 @@ def __call__( http_options = ( _BaseApiGatewayServiceRestTransport._BaseListApiConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_api_configs( request, metadata ) @@ -1577,6 +2082,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigateway_v1.ApiGatewayServiceClient.ListApiConfigs", + extra={ + "serviceName": "google.cloud.apigateway.v1.ApiGatewayService", + "rpcName": "ListApiConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiGatewayServiceRestTransport._ListApiConfigs._get_response( self._host, @@ -1597,7 +2129,31 @@ def __call__( pb_resp = apigateway.ListApiConfigsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_api_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = apigateway.ListApiConfigsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigateway_v1.ApiGatewayServiceClient.list_api_configs", + extra={ + "serviceName": "google.cloud.apigateway.v1.ApiGatewayService", + "rpcName": "ListApiConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListApis( @@ -1634,7 +2190,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apigateway.ListApisResponse: r"""Call the list apis method over HTTP. @@ -1645,8 +2201,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.apigateway.ListApisResponse: @@ -1658,6 +2216,7 @@ def __call__( http_options = ( _BaseApiGatewayServiceRestTransport._BaseListApis._get_http_options() ) + request, metadata = self._interceptor.pre_list_apis(request, metadata) transcoded_request = _BaseApiGatewayServiceRestTransport._BaseListApis._get_transcoded_request( http_options, request @@ -1668,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.apigateway_v1.ApiGatewayServiceClient.ListApis", + extra={ + "serviceName": "google.cloud.apigateway.v1.ApiGatewayService", + "rpcName": "ListApis", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiGatewayServiceRestTransport._ListApis._get_response( self._host, @@ -1688,7 +2274,29 @@ def __call__( pb_resp = apigateway.ListApisResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_apis(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = apigateway.ListApisResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigateway_v1.ApiGatewayServiceClient.list_apis", + extra={ + "serviceName": "google.cloud.apigateway.v1.ApiGatewayService", + "rpcName": "ListApis", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListGateways( @@ -1725,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]]] = (), ) -> apigateway.ListGatewaysResponse: r"""Call the list gateways method over HTTP. @@ -1736,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: ~.apigateway.ListGatewaysResponse: @@ -1749,6 +2359,7 @@ def __call__( http_options = ( _BaseApiGatewayServiceRestTransport._BaseListGateways._get_http_options() ) + request, metadata = self._interceptor.pre_list_gateways(request, metadata) transcoded_request = _BaseApiGatewayServiceRestTransport._BaseListGateways._get_transcoded_request( http_options, request @@ -1759,6 +2370,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigateway_v1.ApiGatewayServiceClient.ListGateways", + extra={ + "serviceName": "google.cloud.apigateway.v1.ApiGatewayService", + "rpcName": "ListGateways", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiGatewayServiceRestTransport._ListGateways._get_response( self._host, @@ -1779,7 +2417,29 @@ def __call__( pb_resp = apigateway.ListGatewaysResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_gateways(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = apigateway.ListGatewaysResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigateway_v1.ApiGatewayServiceClient.list_gateways", + extra={ + "serviceName": "google.cloud.apigateway.v1.ApiGatewayService", + "rpcName": "ListGateways", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateApi( @@ -1817,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]]] = (), ) -> operations_pb2.Operation: r"""Call the update api method over HTTP. @@ -1828,8 +2488,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1842,6 +2504,7 @@ def __call__( http_options = ( _BaseApiGatewayServiceRestTransport._BaseUpdateApi._get_http_options() ) + request, metadata = self._interceptor.pre_update_api(request, metadata) transcoded_request = _BaseApiGatewayServiceRestTransport._BaseUpdateApi._get_transcoded_request( http_options, request @@ -1856,6 +2519,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigateway_v1.ApiGatewayServiceClient.UpdateApi", + extra={ + "serviceName": "google.cloud.apigateway.v1.ApiGatewayService", + "rpcName": "UpdateApi", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiGatewayServiceRestTransport._UpdateApi._get_response( self._host, @@ -1875,7 +2565,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_api(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigateway_v1.ApiGatewayServiceClient.update_api", + extra={ + "serviceName": "google.cloud.apigateway.v1.ApiGatewayService", + "rpcName": "UpdateApi", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateApiConfig( @@ -1914,7 +2626,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 api config method over HTTP. @@ -1925,8 +2637,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1939,6 +2653,7 @@ def __call__( http_options = ( _BaseApiGatewayServiceRestTransport._BaseUpdateApiConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_api_config( request, metadata ) @@ -1955,6 +2670,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigateway_v1.ApiGatewayServiceClient.UpdateApiConfig", + extra={ + "serviceName": "google.cloud.apigateway.v1.ApiGatewayService", + "rpcName": "UpdateApiConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiGatewayServiceRestTransport._UpdateApiConfig._get_response( self._host, @@ -1974,7 +2716,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_api_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.apigateway_v1.ApiGatewayServiceClient.update_api_config", + extra={ + "serviceName": "google.cloud.apigateway.v1.ApiGatewayService", + "rpcName": "UpdateApiConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateGateway( @@ -2013,7 +2777,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 gateway method over HTTP. @@ -2024,8 +2788,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2038,6 +2804,7 @@ def __call__( http_options = ( _BaseApiGatewayServiceRestTransport._BaseUpdateGateway._get_http_options() ) + request, metadata = self._interceptor.pre_update_gateway(request, metadata) transcoded_request = _BaseApiGatewayServiceRestTransport._BaseUpdateGateway._get_transcoded_request( http_options, request @@ -2052,6 +2819,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigateway_v1.ApiGatewayServiceClient.UpdateGateway", + extra={ + "serviceName": "google.cloud.apigateway.v1.ApiGatewayService", + "rpcName": "UpdateGateway", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiGatewayServiceRestTransport._UpdateGateway._get_response( self._host, @@ -2071,7 +2865,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_gateway(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigateway_v1.ApiGatewayServiceClient.update_gateway", + extra={ + "serviceName": "google.cloud.apigateway.v1.ApiGatewayService", + "rpcName": "UpdateGateway", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-api-gateway/samples/generated_samples/snippet_metadata_google.cloud.apigateway.v1.json b/packages/google-cloud-api-gateway/samples/generated_samples/snippet_metadata_google.cloud.apigateway.v1.json index 8a5e1a18b8e1..0d3028a33f91 100644 --- a/packages/google-cloud-api-gateway/samples/generated_samples/snippet_metadata_google.cloud.apigateway.v1.json +++ b/packages/google-cloud-api-gateway/samples/generated_samples/snippet_metadata_google.cloud.apigateway.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-api-gateway", - "version": "1.10.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", @@ -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.apigateway_v1.types.ApiConfig", @@ -1141,7 +1141,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigateway_v1.types.ApiConfig", @@ -1222,7 +1222,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigateway_v1.types.Api", @@ -1302,7 +1302,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigateway_v1.types.Api", @@ -1383,7 +1383,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigateway_v1.types.Gateway", @@ -1463,7 +1463,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigateway_v1.types.Gateway", @@ -1544,7 +1544,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigateway_v1.services.api_gateway_service.pagers.ListApiConfigsAsyncPager", @@ -1624,7 +1624,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigateway_v1.services.api_gateway_service.pagers.ListApiConfigsPager", @@ -1705,7 +1705,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigateway_v1.services.api_gateway_service.pagers.ListApisAsyncPager", @@ -1785,7 +1785,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigateway_v1.services.api_gateway_service.pagers.ListApisPager", @@ -1866,7 +1866,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigateway_v1.services.api_gateway_service.pagers.ListGatewaysAsyncPager", @@ -1946,7 +1946,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigateway_v1.services.api_gateway_service.pagers.ListGatewaysPager", @@ -2031,7 +2031,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2115,7 +2115,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2200,7 +2200,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2284,7 +2284,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2369,7 +2369,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2453,7 +2453,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-api-gateway/tests/unit/gapic/apigateway_v1/test_api_gateway_service.py b/packages/google-cloud-api-gateway/tests/unit/gapic/apigateway_v1/test_api_gateway_service.py index 2dfe86359e2c..a64e1d0615a4 100644 --- a/packages/google-cloud-api-gateway/tests/unit/gapic/apigateway_v1/test_api_gateway_service.py +++ b/packages/google-cloud-api-gateway/tests/unit/gapic/apigateway_v1/test_api_gateway_service.py @@ -6875,6 +6875,7 @@ def test_list_gateways_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_gateways(request) @@ -6930,6 +6931,7 @@ def test_list_gateways_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_gateways(**mock_args) @@ -7119,6 +7121,7 @@ def test_get_gateway_rest_required_fields(request_type=apigateway.GetGatewayRequ response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_gateway(request) @@ -7164,6 +7167,7 @@ def test_get_gateway_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_gateway(**mock_args) @@ -7305,6 +7309,7 @@ def test_create_gateway_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_gateway(request) @@ -7365,6 +7370,7 @@ def test_create_gateway_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_gateway(**mock_args) @@ -7496,6 +7502,7 @@ def test_update_gateway_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_gateway(request) @@ -7542,6 +7549,7 @@ def test_update_gateway_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_gateway(**mock_args) @@ -7675,6 +7683,7 @@ def test_delete_gateway_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_gateway(request) @@ -7718,6 +7727,7 @@ def test_delete_gateway_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_gateway(**mock_args) @@ -7855,6 +7865,7 @@ def test_list_apis_rest_required_fields(request_type=apigateway.ListApisRequest) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_apis(request) @@ -7910,6 +7921,7 @@ def test_list_apis_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_apis(**mock_args) @@ -8099,6 +8111,7 @@ def test_get_api_rest_required_fields(request_type=apigateway.GetApiRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_api(request) @@ -8144,6 +8157,7 @@ def test_get_api_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_api(**mock_args) @@ -8283,6 +8297,7 @@ def test_create_api_rest_required_fields(request_type=apigateway.CreateApiReques response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_api(request) @@ -8343,6 +8358,7 @@ def test_create_api_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_api(**mock_args) @@ -8472,6 +8488,7 @@ def test_update_api_rest_required_fields(request_type=apigateway.UpdateApiReques response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_api(request) @@ -8518,6 +8535,7 @@ def test_update_api_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_api(**mock_args) @@ -8648,6 +8666,7 @@ def test_delete_api_rest_required_fields(request_type=apigateway.DeleteApiReques response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_api(request) @@ -8691,6 +8710,7 @@ def test_delete_api_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_api(**mock_args) @@ -8832,6 +8852,7 @@ def test_list_api_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_api_configs(request) @@ -8887,6 +8908,7 @@ def test_list_api_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_api_configs(**mock_args) @@ -9081,6 +9103,7 @@ def test_get_api_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_api_config(request) @@ -9128,6 +9151,7 @@ def test_get_api_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_api_config(**mock_args) @@ -9272,6 +9296,7 @@ def test_create_api_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_api_config(request) @@ -9332,6 +9357,7 @@ def test_create_api_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_api_config(**mock_args) @@ -9466,6 +9492,7 @@ def test_update_api_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_api_config(request) @@ -9514,6 +9541,7 @@ def test_update_api_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_api_config(**mock_args) @@ -9649,6 +9677,7 @@ def test_delete_api_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_api_config(request) @@ -9694,6 +9723,7 @@ def test_delete_api_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_api_config(**mock_args) @@ -10597,6 +10627,7 @@ def test_list_gateways_rest_bad_request(request_type=apigateway.ListGatewaysRequ response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_gateways(request) @@ -10633,6 +10664,7 @@ def test_list_gateways_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_gateways(request) # Establish that the response is the type that we expect. @@ -10672,6 +10704,7 @@ def test_list_gateways_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = apigateway.ListGatewaysResponse.to_json( apigateway.ListGatewaysResponse() ) @@ -10716,6 +10749,7 @@ def test_get_gateway_rest_bad_request(request_type=apigateway.GetGatewayRequest) response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_gateway(request) @@ -10755,6 +10789,7 @@ def test_get_gateway_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_gateway(request) # Establish that the response is the type that we expect. @@ -10797,6 +10832,7 @@ def test_get_gateway_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = apigateway.Gateway.to_json(apigateway.Gateway()) req.return_value.content = return_value @@ -10839,6 +10875,7 @@ def test_create_gateway_rest_bad_request(request_type=apigateway.CreateGatewayRe response_value.status_code = 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_gateway(request) @@ -10946,6 +10983,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_gateway(request) # Establish that the response is the type that we expect. @@ -10987,6 +11025,7 @@ def test_create_gateway_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -11031,6 +11070,7 @@ def test_update_gateway_rest_bad_request(request_type=apigateway.UpdateGatewayRe response_value.status_code = 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_gateway(request) @@ -11140,6 +11180,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_gateway(request) # Establish that the response is the type that we expect. @@ -11181,6 +11222,7 @@ def test_update_gateway_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -11223,6 +11265,7 @@ def test_delete_gateway_rest_bad_request(request_type=apigateway.DeleteGatewayRe response_value.status_code = 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_gateway(request) @@ -11253,6 +11296,7 @@ def test_delete_gateway_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_gateway(request) # Establish that the response is the type that we expect. @@ -11294,6 +11338,7 @@ def test_delete_gateway_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -11336,6 +11381,7 @@ def test_list_apis_rest_bad_request(request_type=apigateway.ListApisRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_apis(request) @@ -11372,6 +11418,7 @@ def test_list_apis_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_apis(request) # Establish that the response is the type that we expect. @@ -11411,6 +11458,7 @@ def test_list_apis_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = apigateway.ListApisResponse.to_json( apigateway.ListApisResponse() ) @@ -11455,6 +11503,7 @@ def test_get_api_rest_bad_request(request_type=apigateway.GetApiRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_api(request) @@ -11493,6 +11542,7 @@ def test_get_api_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_api(request) # Establish that the response is the type that we expect. @@ -11534,6 +11584,7 @@ def test_get_api_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = apigateway.Api.to_json(apigateway.Api()) req.return_value.content = return_value @@ -11576,6 +11627,7 @@ def test_create_api_rest_bad_request(request_type=apigateway.CreateApiRequest): response_value.status_code = 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_api(request) @@ -11682,6 +11734,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_api(request) # Establish that the response is the type that we expect. @@ -11721,6 +11774,7 @@ def test_create_api_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -11763,6 +11817,7 @@ def test_update_api_rest_bad_request(request_type=apigateway.UpdateApiRequest): response_value.status_code = 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_api(request) @@ -11869,6 +11924,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_api(request) # Establish that the response is the type that we expect. @@ -11908,6 +11964,7 @@ def test_update_api_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -11950,6 +12007,7 @@ def test_delete_api_rest_bad_request(request_type=apigateway.DeleteApiRequest): response_value.status_code = 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_api(request) @@ -11980,6 +12038,7 @@ def test_delete_api_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_api(request) # Establish that the response is the type that we expect. @@ -12019,6 +12078,7 @@ def test_delete_api_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -12063,6 +12123,7 @@ def test_list_api_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_api_configs(request) @@ -12099,6 +12160,7 @@ def test_list_api_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_api_configs(request) # Establish that the response is the type that we expect. @@ -12140,6 +12202,7 @@ def test_list_api_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 = apigateway.ListApiConfigsResponse.to_json( apigateway.ListApiConfigsResponse() ) @@ -12186,6 +12249,7 @@ def test_get_api_config_rest_bad_request(request_type=apigateway.GetApiConfigReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_api_config(request) @@ -12227,6 +12291,7 @@ def test_get_api_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_api_config(request) # Establish that the response is the type that we expect. @@ -12269,6 +12334,7 @@ def test_get_api_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 = apigateway.ApiConfig.to_json(apigateway.ApiConfig()) req.return_value.content = return_value @@ -12313,6 +12379,7 @@ def test_create_api_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_api_config(request) @@ -12425,6 +12492,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_api_config(request) # Establish that the response is the type that we expect. @@ -12466,6 +12534,7 @@ def test_create_api_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 @@ -12514,6 +12583,7 @@ def test_update_api_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_api_config(request) @@ -12630,6 +12700,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_api_config(request) # Establish that the response is the type that we expect. @@ -12671,6 +12742,7 @@ def test_update_api_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 @@ -12717,6 +12789,7 @@ def test_delete_api_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_api_config(request) @@ -12749,6 +12822,7 @@ def test_delete_api_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_api_config(request) # Establish that the response is the type that we expect. @@ -12790,6 +12864,7 @@ def test_delete_api_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 diff --git a/packages/google-cloud-api-keys/google/cloud/api_keys/gapic_version.py b/packages/google-cloud-api-keys/google/cloud/api_keys/gapic_version.py index bf678492aaad..558c8aab67c5 100644 --- a/packages/google-cloud-api-keys/google/cloud/api_keys/gapic_version.py +++ b/packages/google-cloud-api-keys/google/cloud/api_keys/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.5.13" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-api-keys/google/cloud/api_keys_v2/gapic_version.py b/packages/google-cloud-api-keys/google/cloud/api_keys_v2/gapic_version.py index bf678492aaad..558c8aab67c5 100644 --- a/packages/google-cloud-api-keys/google/cloud/api_keys_v2/gapic_version.py +++ b/packages/google-cloud-api-keys/google/cloud/api_keys_v2/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.5.13" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-api-keys/google/cloud/api_keys_v2/services/api_keys/async_client.py b/packages/google-cloud-api-keys/google/cloud/api_keys_v2/services/api_keys/async_client.py index 5a085b0cfc6e..7b4da0b0fa0a 100644 --- a/packages/google-cloud-api-keys/google/cloud/api_keys_v2/services/api_keys/async_client.py +++ b/packages/google-cloud-api-keys/google/cloud/api_keys_v2/services/api_keys/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, ApiKeysTransport from .transports.grpc_asyncio import ApiKeysGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class ApiKeysAsyncClient: """Manages the API keys associated with projects.""" @@ -253,6 +263,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.api.apikeys_v2.ApiKeysAsyncClient`.", + extra={ + "serviceName": "google.api.apikeys.v2.ApiKeys", + "universeDomain": getattr( + self._client._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._client._transport._credentials).__module__}.{type(self._client._transport._credentials).__qualname__}", + "credentialsInfo": getattr( + self.transport._credentials, "get_cred_info", lambda: None + )(), + } + if hasattr(self._client._transport, "_credentials") + else { + "serviceName": "google.api.apikeys.v2.ApiKeys", + "credentialsType": None, + }, + ) + async def create_key( self, request: Optional[Union[apikeys.CreateKeyRequest, dict]] = None, @@ -262,7 +294,7 @@ async def create_key( 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 API key. @@ -335,8 +367,10 @@ async def sample_create_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: @@ -412,7 +446,7 @@ async def list_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.ListKeysAsyncPager: r"""Lists the API keys owned by a project. The key string of the API key isn't included in the response. @@ -460,8 +494,10 @@ async def sample_list_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.api_keys_v2.services.api_keys.pagers.ListKeysAsyncPager: @@ -535,7 +571,7 @@ async def get_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]]] = (), ) -> resources.Key: r"""Gets the metadata for an API key. The key string of the API key isn't included in the response. @@ -582,8 +618,10 @@ async def sample_get_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.api_keys_v2.types.Key: @@ -642,7 +680,7 @@ async def get_key_string( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apikeys.GetKeyStringResponse: r"""Get the key string for an API key. @@ -688,8 +726,10 @@ async def sample_get_key_string(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.api_keys_v2.types.GetKeyStringResponse: @@ -749,7 +789,7 @@ async def update_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"""Patches the modifiable fields of an API key. The key string of the API key isn't included in the response. @@ -814,8 +854,10 @@ async def sample_update_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: @@ -889,7 +931,7 @@ async def delete_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 an API key. Deleted key can be retrieved within 30 days of deletion. Afterward, key will be purged from the project. @@ -940,8 +982,10 @@ async def sample_delete_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: @@ -1012,7 +1056,7 @@ async def undelete_key( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Undeletes an API key which was deleted within 30 days. @@ -1055,8 +1099,10 @@ async def sample_undelete_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: @@ -1113,7 +1159,7 @@ async def lookup_key( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apikeys.LookupKeyResponse: r"""Find the parent project and resource name of the API key that matches the key string in the request. If the API key has been @@ -1153,8 +1199,10 @@ async def sample_lookup_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.api_keys_v2.types.LookupKeyResponse: @@ -1192,7 +1240,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. @@ -1203,8 +1251,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-api-keys/google/cloud/api_keys_v2/services/api_keys/client.py b/packages/google-cloud-api-keys/google/cloud/api_keys_v2/services/api_keys/client.py index 544a083e78ed..a526124aaff9 100644 --- a/packages/google-cloud-api-keys/google/cloud/api_keys_v2/services/api_keys/client.py +++ b/packages/google-cloud-api-keys/google/cloud/api_keys_v2/services/api_keys/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 @@ -583,6 +593,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -645,6 +659,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.api.apikeys_v2.ApiKeysClient`.", + extra={ + "serviceName": "google.api.apikeys.v2.ApiKeys", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__module__}.{type(self._transport._credentials).__qualname__}", + "credentialsInfo": getattr( + self.transport._credentials, "get_cred_info", lambda: None + )(), + } + if hasattr(self._transport, "_credentials") + else { + "serviceName": "google.api.apikeys.v2.ApiKeys", + "credentialsType": None, + }, + ) + def create_key( self, request: Optional[Union[apikeys.CreateKeyRequest, dict]] = None, @@ -654,7 +691,7 @@ def create_key( 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 API key. @@ -727,8 +764,10 @@ def sample_create_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: @@ -801,7 +840,7 @@ def list_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.ListKeysPager: r"""Lists the API keys owned by a project. The key string of the API key isn't included in the response. @@ -849,8 +888,10 @@ def sample_list_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.api_keys_v2.services.api_keys.pagers.ListKeysPager: @@ -921,7 +962,7 @@ def get_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]]] = (), ) -> resources.Key: r"""Gets the metadata for an API key. The key string of the API key isn't included in the response. @@ -968,8 +1009,10 @@ def sample_get_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.api_keys_v2.types.Key: @@ -1027,7 +1070,7 @@ def get_key_string( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apikeys.GetKeyStringResponse: r"""Get the key string for an API key. @@ -1073,8 +1116,10 @@ def sample_get_key_string(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.api_keys_v2.types.GetKeyStringResponse: @@ -1131,7 +1176,7 @@ def update_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"""Patches the modifiable fields of an API key. The key string of the API key isn't included in the response. @@ -1196,8 +1241,10 @@ def sample_update_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: @@ -1268,7 +1315,7 @@ def delete_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 an API key. Deleted key can be retrieved within 30 days of deletion. Afterward, key will be purged from the project. @@ -1319,8 +1366,10 @@ def sample_delete_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: @@ -1388,7 +1437,7 @@ def undelete_key( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Undeletes an API key which was deleted within 30 days. @@ -1431,8 +1480,10 @@ def sample_undelete_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: @@ -1487,7 +1538,7 @@ def lookup_key( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apikeys.LookupKeyResponse: r"""Find the parent project and resource name of the API key that matches the key string in the request. If the API key has been @@ -1527,8 +1578,10 @@ def sample_lookup_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.api_keys_v2.types.LookupKeyResponse: @@ -1577,7 +1630,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. @@ -1588,8 +1641,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-api-keys/google/cloud/api_keys_v2/services/api_keys/pagers.py b/packages/google-cloud-api-keys/google/cloud/api_keys_v2/services/api_keys/pagers.py index 7b043ccc2811..c489cfa01192 100644 --- a/packages/google-cloud-api-keys/google/cloud/api_keys_v2/services/api_keys/pagers.py +++ b/packages/google-cloud-api-keys/google/cloud/api_keys_v2/services/api_keys/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 = apikeys.ListKeysRequest(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 = apikeys.ListKeysRequest(request) diff --git a/packages/google-cloud-api-keys/google/cloud/api_keys_v2/services/api_keys/transports/grpc.py b/packages/google-cloud-api-keys/google/cloud/api_keys_v2/services/api_keys/transports/grpc.py index d0c4f9ce1b1b..9a95bc661ccc 100644 --- a/packages/google-cloud-api-keys/google/cloud/api_keys_v2/services/api_keys/transports/grpc.py +++ b/packages/google-cloud-api-keys/google/cloud/api_keys_v2/services/api_keys/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.api_keys_v2.types import apikeys, resources from .base import DEFAULT_CLIENT_INFO, ApiKeysTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + + +class _LoggingClientInterceptor(grpc.UnaryUnaryClientInterceptor): # pragma: NO COVER + def intercept_unary_unary(self, continuation, client_call_details, request): + logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ) + if logging_enabled: # pragma: NO COVER + request_metadata = client_call_details.metadata + if isinstance(request, proto.Message): + request_payload = type(request).to_json(request) + elif isinstance(request, google.protobuf.message.Message): + request_payload = MessageToJson(request) + else: + request_payload = f"{type(request).__name__}: {pickle.dumps(request)}" + + request_metadata = { + key: value.decode("utf-8") if isinstance(value, bytes) else value + for key, value in request_metadata + } + grpc_request = { + "payload": request_payload, + "requestMethod": "grpc", + "metadata": dict(request_metadata), + } + _LOGGER.debug( + f"Sending request for {client_call_details.method}", + extra={ + "serviceName": "google.api.apikeys.v2.ApiKeys", + "rpcName": client_call_details.method, + "request": grpc_request, + "metadata": grpc_request["metadata"], + }, + ) + + response = continuation(client_call_details, request) + if logging_enabled: # pragma: NO COVER + response_metadata = response.trailing_metadata() + # Convert gRPC metadata `` to list of tuples + metadata = ( + dict([(k, str(v)) for k, v in response_metadata]) + if response_metadata + else None + ) + result = response.result() + if isinstance(result, proto.Message): + response_payload = type(result).to_json(result) + elif isinstance(result, google.protobuf.message.Message): + response_payload = MessageToJson(result) + else: + response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" + grpc_response = { + "payload": response_payload, + "metadata": metadata, + "status": "OK", + } + _LOGGER.debug( + f"Received response for {client_call_details.method}.", + extra={ + "serviceName": "google.api.apikeys.v2.ApiKeys", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ApiKeysGrpcTransport(ApiKeysTransport): """gRPC backend transport for ApiKeys. @@ -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 create_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_key" not in self._stubs: - self._stubs["create_key"] = self.grpc_channel.unary_unary( + self._stubs["create_key"] = self._logged_channel.unary_unary( "/google.api.apikeys.v2.ApiKeys/CreateKey", request_serializer=apikeys.CreateKeyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -302,7 +390,7 @@ def list_keys( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_keys" not in self._stubs: - self._stubs["list_keys"] = self.grpc_channel.unary_unary( + self._stubs["list_keys"] = self._logged_channel.unary_unary( "/google.api.apikeys.v2.ApiKeys/ListKeys", request_serializer=apikeys.ListKeysRequest.serialize, response_deserializer=apikeys.ListKeysResponse.deserialize, @@ -330,7 +418,7 @@ def get_key(self) -> Callable[[apikeys.GetKeyRequest], resources.Key]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_key" not in self._stubs: - self._stubs["get_key"] = self.grpc_channel.unary_unary( + self._stubs["get_key"] = self._logged_channel.unary_unary( "/google.api.apikeys.v2.ApiKeys/GetKey", request_serializer=apikeys.GetKeyRequest.serialize, response_deserializer=resources.Key.deserialize, @@ -359,7 +447,7 @@ def get_key_string( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_key_string" not in self._stubs: - self._stubs["get_key_string"] = self.grpc_channel.unary_unary( + self._stubs["get_key_string"] = self._logged_channel.unary_unary( "/google.api.apikeys.v2.ApiKeys/GetKeyString", request_serializer=apikeys.GetKeyStringRequest.serialize, response_deserializer=apikeys.GetKeyStringResponse.deserialize, @@ -389,7 +477,7 @@ def update_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_key" not in self._stubs: - self._stubs["update_key"] = self.grpc_channel.unary_unary( + self._stubs["update_key"] = self._logged_channel.unary_unary( "/google.api.apikeys.v2.ApiKeys/UpdateKey", request_serializer=apikeys.UpdateKeyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -419,7 +507,7 @@ def delete_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_key" not in self._stubs: - self._stubs["delete_key"] = self.grpc_channel.unary_unary( + self._stubs["delete_key"] = self._logged_channel.unary_unary( "/google.api.apikeys.v2.ApiKeys/DeleteKey", request_serializer=apikeys.DeleteKeyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -448,7 +536,7 @@ def undelete_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "undelete_key" not in self._stubs: - self._stubs["undelete_key"] = self.grpc_channel.unary_unary( + self._stubs["undelete_key"] = self._logged_channel.unary_unary( "/google.api.apikeys.v2.ApiKeys/UndeleteKey", request_serializer=apikeys.UndeleteKeyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -478,7 +566,7 @@ def lookup_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "lookup_key" not in self._stubs: - self._stubs["lookup_key"] = self.grpc_channel.unary_unary( + self._stubs["lookup_key"] = self._logged_channel.unary_unary( "/google.api.apikeys.v2.ApiKeys/LookupKey", request_serializer=apikeys.LookupKeyRequest.serialize, response_deserializer=apikeys.LookupKeyResponse.deserialize, @@ -486,7 +574,7 @@ def lookup_key( return self._stubs["lookup_key"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -498,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-api-keys/google/cloud/api_keys_v2/services/api_keys/transports/grpc_asyncio.py b/packages/google-cloud-api-keys/google/cloud/api_keys_v2/services/api_keys/transports/grpc_asyncio.py index a127ab4ffc14..70e012f2533e 100644 --- a/packages/google-cloud-api-keys/google/cloud/api_keys_v2/services/api_keys/transports/grpc_asyncio.py +++ b/packages/google-cloud-api-keys/google/cloud/api_keys_v2/services/api_keys/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.api_keys_v2.types import apikeys, resources from .base import DEFAULT_CLIENT_INFO, ApiKeysTransport from .grpc import ApiKeysGrpcTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + + +class _LoggingClientAIOInterceptor( + grpc.aio.UnaryUnaryClientInterceptor +): # pragma: NO COVER + async def intercept_unary_unary(self, continuation, client_call_details, request): + logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ) + if logging_enabled: # pragma: NO COVER + request_metadata = client_call_details.metadata + if isinstance(request, proto.Message): + request_payload = type(request).to_json(request) + elif isinstance(request, google.protobuf.message.Message): + request_payload = MessageToJson(request) + else: + request_payload = f"{type(request).__name__}: {pickle.dumps(request)}" + + request_metadata = { + key: value.decode("utf-8") if isinstance(value, bytes) else value + for key, value in request_metadata + } + grpc_request = { + "payload": request_payload, + "requestMethod": "grpc", + "metadata": dict(request_metadata), + } + _LOGGER.debug( + f"Sending request for {client_call_details.method}", + extra={ + "serviceName": "google.api.apikeys.v2.ApiKeys", + "rpcName": str(client_call_details.method), + "request": grpc_request, + "metadata": grpc_request["metadata"], + }, + ) + response = await continuation(client_call_details, request) + if logging_enabled: # pragma: NO COVER + response_metadata = await response.trailing_metadata() + # Convert gRPC metadata `` to list of tuples + metadata = ( + dict([(k, str(v)) for k, v in response_metadata]) + if response_metadata + else None + ) + result = await response + if isinstance(result, proto.Message): + response_payload = type(result).to_json(result) + elif isinstance(result, google.protobuf.message.Message): + response_payload = MessageToJson(result) + else: + response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" + grpc_response = { + "payload": response_payload, + "metadata": metadata, + "status": "OK", + } + _LOGGER.debug( + f"Received response to rpc {client_call_details.method}.", + extra={ + "serviceName": "google.api.apikeys.v2.ApiKeys", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ApiKeysGrpcAsyncIOTransport(ApiKeysTransport): """gRPC AsyncIO backend transport for ApiKeys. @@ -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 create_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_key" not in self._stubs: - self._stubs["create_key"] = self.grpc_channel.unary_unary( + self._stubs["create_key"] = self._logged_channel.unary_unary( "/google.api.apikeys.v2.ApiKeys/CreateKey", request_serializer=apikeys.CreateKeyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -312,7 +397,7 @@ def list_keys( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_keys" not in self._stubs: - self._stubs["list_keys"] = self.grpc_channel.unary_unary( + self._stubs["list_keys"] = self._logged_channel.unary_unary( "/google.api.apikeys.v2.ApiKeys/ListKeys", request_serializer=apikeys.ListKeysRequest.serialize, response_deserializer=apikeys.ListKeysResponse.deserialize, @@ -340,7 +425,7 @@ def get_key(self) -> Callable[[apikeys.GetKeyRequest], Awaitable[resources.Key]] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_key" not in self._stubs: - self._stubs["get_key"] = self.grpc_channel.unary_unary( + self._stubs["get_key"] = self._logged_channel.unary_unary( "/google.api.apikeys.v2.ApiKeys/GetKey", request_serializer=apikeys.GetKeyRequest.serialize, response_deserializer=resources.Key.deserialize, @@ -371,7 +456,7 @@ def get_key_string( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_key_string" not in self._stubs: - self._stubs["get_key_string"] = self.grpc_channel.unary_unary( + self._stubs["get_key_string"] = self._logged_channel.unary_unary( "/google.api.apikeys.v2.ApiKeys/GetKeyString", request_serializer=apikeys.GetKeyStringRequest.serialize, response_deserializer=apikeys.GetKeyStringResponse.deserialize, @@ -401,7 +486,7 @@ def update_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_key" not in self._stubs: - self._stubs["update_key"] = self.grpc_channel.unary_unary( + self._stubs["update_key"] = self._logged_channel.unary_unary( "/google.api.apikeys.v2.ApiKeys/UpdateKey", request_serializer=apikeys.UpdateKeyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -431,7 +516,7 @@ def delete_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_key" not in self._stubs: - self._stubs["delete_key"] = self.grpc_channel.unary_unary( + self._stubs["delete_key"] = self._logged_channel.unary_unary( "/google.api.apikeys.v2.ApiKeys/DeleteKey", request_serializer=apikeys.DeleteKeyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -460,7 +545,7 @@ def undelete_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "undelete_key" not in self._stubs: - self._stubs["undelete_key"] = self.grpc_channel.unary_unary( + self._stubs["undelete_key"] = self._logged_channel.unary_unary( "/google.api.apikeys.v2.ApiKeys/UndeleteKey", request_serializer=apikeys.UndeleteKeyRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -490,7 +575,7 @@ def lookup_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "lookup_key" not in self._stubs: - self._stubs["lookup_key"] = self.grpc_channel.unary_unary( + self._stubs["lookup_key"] = self._logged_channel.unary_unary( "/google.api.apikeys.v2.ApiKeys/LookupKey", request_serializer=apikeys.LookupKeyRequest.serialize, response_deserializer=apikeys.LookupKeyResponse.deserialize, @@ -553,7 +638,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: @@ -569,7 +654,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-api-keys/google/cloud/api_keys_v2/services/api_keys/transports/rest.py b/packages/google-cloud-api-keys/google/cloud/api_keys_v2/services/api_keys/transports/rest.py index bf6bfc18d529..bb2a6dbffd8a 100644 --- a/packages/google-cloud-api-keys/google/cloud/api_keys_v2/services/api_keys/transports/rest.py +++ b/packages/google-cloud-api-keys/google/cloud/api_keys_v2/services/api_keys/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, @@ -132,8 +140,10 @@ def post_update_key(self, response): """ def pre_create_key( - self, request: apikeys.CreateKeyRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[apikeys.CreateKeyRequest, Sequence[Tuple[str, str]]]: + self, + request: apikeys.CreateKeyRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[apikeys.CreateKeyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_key Override in a subclass to manipulate the request or metadata @@ -153,8 +163,10 @@ def post_create_key( return response def pre_delete_key( - self, request: apikeys.DeleteKeyRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[apikeys.DeleteKeyRequest, Sequence[Tuple[str, str]]]: + self, + request: apikeys.DeleteKeyRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[apikeys.DeleteKeyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_key Override in a subclass to manipulate the request or metadata @@ -174,8 +186,10 @@ def post_delete_key( return response def pre_get_key( - self, request: apikeys.GetKeyRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[apikeys.GetKeyRequest, Sequence[Tuple[str, str]]]: + self, + request: apikeys.GetKeyRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[apikeys.GetKeyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_key Override in a subclass to manipulate the request or metadata @@ -193,8 +207,10 @@ def post_get_key(self, response: resources.Key) -> resources.Key: return response def pre_get_key_string( - self, request: apikeys.GetKeyStringRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[apikeys.GetKeyStringRequest, Sequence[Tuple[str, str]]]: + self, + request: apikeys.GetKeyStringRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[apikeys.GetKeyStringRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_key_string Override in a subclass to manipulate the request or metadata @@ -214,8 +230,10 @@ def post_get_key_string( return response def pre_list_keys( - self, request: apikeys.ListKeysRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[apikeys.ListKeysRequest, Sequence[Tuple[str, str]]]: + self, + request: apikeys.ListKeysRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[apikeys.ListKeysRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_keys Override in a subclass to manipulate the request or metadata @@ -235,8 +253,10 @@ def post_list_keys( return response def pre_lookup_key( - self, request: apikeys.LookupKeyRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[apikeys.LookupKeyRequest, Sequence[Tuple[str, str]]]: + self, + request: apikeys.LookupKeyRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[apikeys.LookupKeyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for lookup_key Override in a subclass to manipulate the request or metadata @@ -256,8 +276,10 @@ def post_lookup_key( return response def pre_undelete_key( - self, request: apikeys.UndeleteKeyRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[apikeys.UndeleteKeyRequest, Sequence[Tuple[str, str]]]: + self, + request: apikeys.UndeleteKeyRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[apikeys.UndeleteKeyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for undelete_key Override in a subclass to manipulate the request or metadata @@ -277,8 +299,10 @@ def post_undelete_key( return response def pre_update_key( - self, request: apikeys.UpdateKeyRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[apikeys.UpdateKeyRequest, Sequence[Tuple[str, str]]]: + self, + request: apikeys.UpdateKeyRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[apikeys.UpdateKeyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_key Override in a subclass to manipulate the request or metadata @@ -300,8 +324,10 @@ def post_update_key( 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 @@ -475,7 +501,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create key method over HTTP. @@ -485,8 +511,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -497,6 +525,7 @@ def __call__( """ http_options = _BaseApiKeysRestTransport._BaseCreateKey._get_http_options() + request, metadata = self._interceptor.pre_create_key(request, metadata) transcoded_request = ( _BaseApiKeysRestTransport._BaseCreateKey._get_transcoded_request( @@ -515,6 +544,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.api.apikeys_v2.ApiKeysClient.CreateKey", + extra={ + "serviceName": "google.api.apikeys.v2.ApiKeys", + "rpcName": "CreateKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiKeysRestTransport._CreateKey._get_response( self._host, @@ -534,7 +590,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_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.api.apikeys_v2.ApiKeysClient.create_key", + extra={ + "serviceName": "google.api.apikeys.v2.ApiKeys", + "rpcName": "CreateKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteKey(_BaseApiKeysRestTransport._BaseDeleteKey, ApiKeysRestStub): @@ -569,7 +647,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete key method over HTTP. @@ -579,8 +657,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -591,6 +671,7 @@ def __call__( """ http_options = _BaseApiKeysRestTransport._BaseDeleteKey._get_http_options() + request, metadata = self._interceptor.pre_delete_key(request, metadata) transcoded_request = ( _BaseApiKeysRestTransport._BaseDeleteKey._get_transcoded_request( @@ -605,6 +686,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.api.apikeys_v2.ApiKeysClient.DeleteKey", + extra={ + "serviceName": "google.api.apikeys.v2.ApiKeys", + "rpcName": "DeleteKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiKeysRestTransport._DeleteKey._get_response( self._host, @@ -623,7 +731,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_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.api.apikeys_v2.ApiKeysClient.delete_key", + extra={ + "serviceName": "google.api.apikeys.v2.ApiKeys", + "rpcName": "DeleteKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetKey(_BaseApiKeysRestTransport._BaseGetKey, ApiKeysRestStub): @@ -658,7 +788,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Key: r"""Call the get key method over HTTP. @@ -668,8 +798,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.resources.Key: @@ -679,6 +811,7 @@ def __call__( """ http_options = _BaseApiKeysRestTransport._BaseGetKey._get_http_options() + request, metadata = self._interceptor.pre_get_key(request, metadata) transcoded_request = ( _BaseApiKeysRestTransport._BaseGetKey._get_transcoded_request( @@ -691,6 +824,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.api.apikeys_v2.ApiKeysClient.GetKey", + extra={ + "serviceName": "google.api.apikeys.v2.ApiKeys", + "rpcName": "GetKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiKeysRestTransport._GetKey._get_response( self._host, @@ -711,7 +871,29 @@ def __call__( pb_resp = resources.Key.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_key(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Key.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.api.apikeys_v2.ApiKeysClient.get_key", + extra={ + "serviceName": "google.api.apikeys.v2.ApiKeys", + "rpcName": "GetKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetKeyString(_BaseApiKeysRestTransport._BaseGetKeyString, ApiKeysRestStub): @@ -746,7 +928,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apikeys.GetKeyStringResponse: r"""Call the get key string method over HTTP. @@ -756,8 +938,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.apikeys.GetKeyStringResponse: @@ -767,6 +951,7 @@ def __call__( http_options = ( _BaseApiKeysRestTransport._BaseGetKeyString._get_http_options() ) + request, metadata = self._interceptor.pre_get_key_string(request, metadata) transcoded_request = ( _BaseApiKeysRestTransport._BaseGetKeyString._get_transcoded_request( @@ -781,6 +966,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.api.apikeys_v2.ApiKeysClient.GetKeyString", + extra={ + "serviceName": "google.api.apikeys.v2.ApiKeys", + "rpcName": "GetKeyString", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiKeysRestTransport._GetKeyString._get_response( self._host, @@ -801,7 +1013,29 @@ def __call__( pb_resp = apikeys.GetKeyStringResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_key_string(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = apikeys.GetKeyStringResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.api.apikeys_v2.ApiKeysClient.get_key_string", + extra={ + "serviceName": "google.api.apikeys.v2.ApiKeys", + "rpcName": "GetKeyString", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListKeys(_BaseApiKeysRestTransport._BaseListKeys, ApiKeysRestStub): @@ -836,7 +1070,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apikeys.ListKeysResponse: r"""Call the list keys method over HTTP. @@ -846,8 +1080,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.apikeys.ListKeysResponse: @@ -855,6 +1091,7 @@ def __call__( """ http_options = _BaseApiKeysRestTransport._BaseListKeys._get_http_options() + request, metadata = self._interceptor.pre_list_keys(request, metadata) transcoded_request = ( _BaseApiKeysRestTransport._BaseListKeys._get_transcoded_request( @@ -869,6 +1106,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.api.apikeys_v2.ApiKeysClient.ListKeys", + extra={ + "serviceName": "google.api.apikeys.v2.ApiKeys", + "rpcName": "ListKeys", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiKeysRestTransport._ListKeys._get_response( self._host, @@ -889,7 +1153,29 @@ def __call__( pb_resp = apikeys.ListKeysResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_keys(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = apikeys.ListKeysResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.api.apikeys_v2.ApiKeysClient.list_keys", + extra={ + "serviceName": "google.api.apikeys.v2.ApiKeys", + "rpcName": "ListKeys", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _LookupKey(_BaseApiKeysRestTransport._BaseLookupKey, ApiKeysRestStub): @@ -924,7 +1210,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apikeys.LookupKeyResponse: r"""Call the lookup key method over HTTP. @@ -934,8 +1220,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.apikeys.LookupKeyResponse: @@ -943,6 +1231,7 @@ def __call__( """ http_options = _BaseApiKeysRestTransport._BaseLookupKey._get_http_options() + request, metadata = self._interceptor.pre_lookup_key(request, metadata) transcoded_request = ( _BaseApiKeysRestTransport._BaseLookupKey._get_transcoded_request( @@ -957,6 +1246,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.api.apikeys_v2.ApiKeysClient.LookupKey", + extra={ + "serviceName": "google.api.apikeys.v2.ApiKeys", + "rpcName": "LookupKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiKeysRestTransport._LookupKey._get_response( self._host, @@ -977,7 +1293,29 @@ def __call__( pb_resp = apikeys.LookupKeyResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_lookup_key(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = apikeys.LookupKeyResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.api.apikeys_v2.ApiKeysClient.lookup_key", + extra={ + "serviceName": "google.api.apikeys.v2.ApiKeys", + "rpcName": "LookupKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UndeleteKey(_BaseApiKeysRestTransport._BaseUndeleteKey, ApiKeysRestStub): @@ -1013,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]]] = (), ) -> operations_pb2.Operation: r"""Call the undelete key method over HTTP. @@ -1023,8 +1361,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1037,6 +1377,7 @@ def __call__( http_options = ( _BaseApiKeysRestTransport._BaseUndeleteKey._get_http_options() ) + request, metadata = self._interceptor.pre_undelete_key(request, metadata) transcoded_request = ( _BaseApiKeysRestTransport._BaseUndeleteKey._get_transcoded_request( @@ -1055,6 +1396,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.api.apikeys_v2.ApiKeysClient.UndeleteKey", + extra={ + "serviceName": "google.api.apikeys.v2.ApiKeys", + "rpcName": "UndeleteKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiKeysRestTransport._UndeleteKey._get_response( self._host, @@ -1074,7 +1442,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_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.api.apikeys_v2.ApiKeysClient.undelete_key", + extra={ + "serviceName": "google.api.apikeys.v2.ApiKeys", + "rpcName": "UndeleteKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateKey(_BaseApiKeysRestTransport._BaseUpdateKey, ApiKeysRestStub): @@ -1110,7 +1500,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 key method over HTTP. @@ -1120,8 +1510,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1132,6 +1524,7 @@ def __call__( """ http_options = _BaseApiKeysRestTransport._BaseUpdateKey._get_http_options() + request, metadata = self._interceptor.pre_update_key(request, metadata) transcoded_request = ( _BaseApiKeysRestTransport._BaseUpdateKey._get_transcoded_request( @@ -1150,6 +1543,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.api.apikeys_v2.ApiKeysClient.UpdateKey", + extra={ + "serviceName": "google.api.apikeys.v2.ApiKeys", + "rpcName": "UpdateKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiKeysRestTransport._UpdateKey._get_response( self._host, @@ -1169,7 +1589,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_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.api.apikeys_v2.ApiKeysClient.update_key", + extra={ + "serviceName": "google.api.apikeys.v2.ApiKeys", + "rpcName": "UpdateKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1270,7 +1712,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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. @@ -1280,8 +1722,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: operations_pb2.Operation: Response from GetOperation method. @@ -1290,6 +1734,7 @@ def __call__( http_options = ( _BaseApiKeysRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseApiKeysRestTransport._BaseGetOperation._get_transcoded_request( @@ -1304,6 +1749,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.api.apikeys_v2.ApiKeysClient.GetOperation", + extra={ + "serviceName": "google.api.apikeys.v2.ApiKeys", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiKeysRestTransport._GetOperation._get_response( self._host, @@ -1323,6 +1795,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.api.apikeys_v2.ApiKeysAsyncClient.GetOperation", + extra={ + "serviceName": "google.api.apikeys.v2.ApiKeys", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-api-keys/samples/generated_samples/snippet_metadata_google.api.apikeys.v2.json b/packages/google-cloud-api-keys/samples/generated_samples/snippet_metadata_google.api.apikeys.v2.json index da595c436b65..3f1f9841f3c1 100644 --- a/packages/google-cloud-api-keys/samples/generated_samples/snippet_metadata_google.api.apikeys.v2.json +++ b/packages/google-cloud-api-keys/samples/generated_samples/snippet_metadata_google.api.apikeys.v2.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-api-keys", - "version": "0.5.13" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -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.api_keys_v2.types.GetKeyStringResponse", @@ -465,7 +465,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.api_keys_v2.types.GetKeyStringResponse", @@ -546,7 +546,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.api_keys_v2.types.Key", @@ -626,7 +626,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.api_keys_v2.types.Key", @@ -707,7 +707,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.api_keys_v2.services.api_keys.pagers.ListKeysAsyncPager", @@ -787,7 +787,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.api_keys_v2.services.api_keys.pagers.ListKeysPager", @@ -864,7 +864,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.api_keys_v2.types.LookupKeyResponse", @@ -940,7 +940,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.api_keys_v2.types.LookupKeyResponse", @@ -1017,7 +1017,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1093,7 +1093,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1178,7 +1178,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1262,7 +1262,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-api-keys/tests/unit/gapic/api_keys_v2/test_api_keys.py b/packages/google-cloud-api-keys/tests/unit/gapic/api_keys_v2/test_api_keys.py index 699bfd1d45fa..5c44698b7fe6 100644 --- a/packages/google-cloud-api-keys/tests/unit/gapic/api_keys_v2/test_api_keys.py +++ b/packages/google-cloud-api-keys/tests/unit/gapic/api_keys_v2/test_api_keys.py @@ -3720,6 +3720,7 @@ def test_create_key_rest_required_fields(request_type=apikeys.CreateKeyRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_key(request) @@ -3773,6 +3774,7 @@ def test_create_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_key(**mock_args) @@ -3911,6 +3913,7 @@ def test_list_keys_rest_required_fields(request_type=apikeys.ListKeysRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_keys(request) @@ -3965,6 +3968,7 @@ def test_list_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_keys(**mock_args) @@ -4154,6 +4158,7 @@ def test_get_key_rest_required_fields(request_type=apikeys.GetKeyRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_key(request) @@ -4199,6 +4204,7 @@ def test_get_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_key(**mock_args) @@ -4327,6 +4333,7 @@ def test_get_key_string_rest_required_fields(request_type=apikeys.GetKeyStringRe response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_key_string(request) @@ -4372,6 +4379,7 @@ def test_get_key_string_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_key_string(**mock_args) @@ -4500,6 +4508,7 @@ def test_update_key_rest_required_fields(request_type=apikeys.UpdateKeyRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_key(request) @@ -4546,6 +4555,7 @@ def test_update_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.update_key(**mock_args) @@ -4678,6 +4688,7 @@ def test_delete_key_rest_required_fields(request_type=apikeys.DeleteKeyRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_key(request) @@ -4721,6 +4732,7 @@ def test_delete_key_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_key(**mock_args) @@ -4851,6 +4863,7 @@ def test_undelete_key_rest_required_fields(request_type=apikeys.UndeleteKeyReque response_value._content = json_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_key(request) @@ -4973,6 +4986,7 @@ def test_lookup_key_rest_required_fields(request_type=apikeys.LookupKeyRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.lookup_key(request) @@ -5523,6 +5537,7 @@ def test_create_key_rest_bad_request(request_type=apikeys.CreateKeyRequest): response_value.status_code = 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_key(request) @@ -5662,6 +5677,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_key(request) # Establish that the response is the type that we expect. @@ -5699,6 +5715,7 @@ def test_create_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 @@ -5741,6 +5758,7 @@ def test_list_keys_rest_bad_request(request_type=apikeys.ListKeysRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_keys(request) @@ -5776,6 +5794,7 @@ def test_list_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_keys(request) # Establish that the response is the type that we expect. @@ -5812,6 +5831,7 @@ def test_list_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 = apikeys.ListKeysResponse.to_json(apikeys.ListKeysResponse()) req.return_value.content = return_value @@ -5854,6 +5874,7 @@ def test_get_key_rest_bad_request(request_type=apikeys.GetKeyRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_key(request) @@ -5893,6 +5914,7 @@ def test_get_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_key(request) # Establish that the response is the type that we expect. @@ -5933,6 +5955,7 @@ def test_get_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 = resources.Key.to_json(resources.Key()) req.return_value.content = return_value @@ -5975,6 +5998,7 @@ def test_get_key_string_rest_bad_request(request_type=apikeys.GetKeyStringReques response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_key_string(request) @@ -6010,6 +6034,7 @@ def test_get_key_string_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_key_string(request) # Establish that the response is the type that we expect. @@ -6046,6 +6071,7 @@ def test_get_key_string_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = apikeys.GetKeyStringResponse.to_json( apikeys.GetKeyStringResponse() ) @@ -6090,6 +6116,7 @@ def test_update_key_rest_bad_request(request_type=apikeys.UpdateKeyRequest): response_value.status_code = 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_key(request) @@ -6229,6 +6256,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_key(request) # Establish that the response is the type that we expect. @@ -6266,6 +6294,7 @@ def test_update_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 @@ -6308,6 +6337,7 @@ def test_delete_key_rest_bad_request(request_type=apikeys.DeleteKeyRequest): response_value.status_code = 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_key(request) @@ -6338,6 +6368,7 @@ def test_delete_key_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_key(request) # Establish that the response is the type that we expect. @@ -6375,6 +6406,7 @@ def test_delete_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 @@ -6417,6 +6449,7 @@ def test_undelete_key_rest_bad_request(request_type=apikeys.UndeleteKeyRequest): response_value.status_code = 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_key(request) @@ -6447,6 +6480,7 @@ def test_undelete_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.undelete_key(request) # Establish that the response is the type that we expect. @@ -6484,6 +6518,7 @@ def test_undelete_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 @@ -6526,6 +6561,7 @@ def test_lookup_key_rest_bad_request(request_type=apikeys.LookupKeyRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.lookup_key(request) @@ -6562,6 +6598,7 @@ def test_lookup_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.lookup_key(request) # Establish that the response is the type that we expect. @@ -6599,6 +6636,7 @@ def test_lookup_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 = apikeys.LookupKeyResponse.to_json(apikeys.LookupKeyResponse()) req.return_value.content = return_value @@ -6643,6 +6681,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) @@ -6673,6 +6712,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-apigee-connect/google/cloud/apigeeconnect/gapic_version.py b/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect/gapic_version.py index f1d827b5c728..558c8aab67c5 100644 --- a/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect/gapic_version.py +++ b/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.10.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/gapic_version.py b/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/gapic_version.py index f1d827b5c728..558c8aab67c5 100644 --- a/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/gapic_version.py +++ b/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.10.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/connection_service/async_client.py b/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/connection_service/async_client.py index 692a5b47d977..903fbd0dbb78 100644 --- a/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/connection_service/async_client.py +++ b/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/connection_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, ConnectionServiceTransport from .transports.grpc_asyncio import ConnectionServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class ConnectionServiceAsyncClient: """Service Interface for the Apigee Connect connection @@ -260,6 +270,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.apigeeconnect_v1.ConnectionServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.apigeeconnect.v1.ConnectionService", + "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.apigeeconnect.v1.ConnectionService", + "credentialsType": None, + }, + ) + async def list_connections( self, request: Optional[Union[connection.ListConnectionsRequest, dict]] = None, @@ -267,7 +299,7 @@ async def list_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.ListConnectionsAsyncPager: r"""Lists connections that are currently active for the given Apigee Connect endpoint. @@ -313,8 +345,10 @@ async def sample_list_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.apigeeconnect_v1.services.connection_service.pagers.ListConnectionsAsyncPager: diff --git a/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/connection_service/client.py b/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/connection_service/client.py index 57386b00cd6d..b57059b8dea1 100644 --- a/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/connection_service/client.py +++ b/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/connection_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.apigeeconnect_v1.services.connection_service import pagers from google.cloud.apigeeconnect_v1.types import connection @@ -577,6 +587,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -643,6 +657,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.apigeeconnect_v1.ConnectionServiceClient`.", + extra={ + "serviceName": "google.cloud.apigeeconnect.v1.ConnectionService", + "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.apigeeconnect.v1.ConnectionService", + "credentialsType": None, + }, + ) + def list_connections( self, request: Optional[Union[connection.ListConnectionsRequest, dict]] = None, @@ -650,7 +687,7 @@ def list_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.ListConnectionsPager: r"""Lists connections that are currently active for the given Apigee Connect endpoint. @@ -696,8 +733,10 @@ def sample_list_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.apigeeconnect_v1.services.connection_service.pagers.ListConnectionsPager: diff --git a/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/connection_service/pagers.py b/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/connection_service/pagers.py index 9ca0640a023a..becf65724183 100644 --- a/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/connection_service/pagers.py +++ b/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/connection_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 = connection.ListConnectionsRequest(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 = connection.ListConnectionsRequest(request) diff --git a/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/connection_service/transports/grpc.py b/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/connection_service/transports/grpc.py index 8a42da542443..504949ff153f 100644 --- a/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/connection_service/transports/grpc.py +++ b/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/connection_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.apigeeconnect_v1.types import connection from .base import DEFAULT_CLIENT_INFO, ConnectionServiceTransport +try: + from google.api_core import client_logging # 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.apigeeconnect.v1.ConnectionService", + "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.apigeeconnect.v1.ConnectionService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ConnectionServiceGrpcTransport(ConnectionServiceTransport): """gRPC backend transport for ConnectionService. @@ -180,7 +261,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientInterceptor() + self._logged_channel = grpc.intercept_channel( + self._grpc_channel, self._interceptor + ) + + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @classmethod @@ -257,7 +343,7 @@ def list_connections( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_connections" not in self._stubs: - self._stubs["list_connections"] = self.grpc_channel.unary_unary( + self._stubs["list_connections"] = self._logged_channel.unary_unary( "/google.cloud.apigeeconnect.v1.ConnectionService/ListConnections", request_serializer=connection.ListConnectionsRequest.serialize, response_deserializer=connection.ListConnectionsResponse.deserialize, @@ -265,7 +351,7 @@ def list_connections( return self._stubs["list_connections"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/connection_service/transports/grpc_asyncio.py b/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/connection_service/transports/grpc_asyncio.py index 5fc7670fcbeb..27a0e41ad996 100644 --- a/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/connection_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/connection_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.apigeeconnect_v1.types import connection from .base import DEFAULT_CLIENT_INFO, ConnectionServiceTransport from .grpc import ConnectionServiceGrpcTransport +try: + from google.api_core import client_logging # 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.apigeeconnect.v1.ConnectionService", + "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.apigeeconnect.v1.ConnectionService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ConnectionServiceGrpcAsyncIOTransport(ConnectionServiceTransport): """gRPC AsyncIO backend transport for ConnectionService. @@ -227,10 +309,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientAIOInterceptor() + self._grpc_channel._unary_unary_interceptors.append(self._interceptor) + self._logged_channel = self._grpc_channel self._wrap_with_kind = ( "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters ) + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @property @@ -266,7 +351,7 @@ def list_connections( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_connections" not in self._stubs: - self._stubs["list_connections"] = self.grpc_channel.unary_unary( + self._stubs["list_connections"] = self._logged_channel.unary_unary( "/google.cloud.apigeeconnect.v1.ConnectionService/ListConnections", request_serializer=connection.ListConnectionsRequest.serialize, response_deserializer=connection.ListConnectionsResponse.deserialize, @@ -299,7 +384,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-apigee-connect/google/cloud/apigeeconnect_v1/services/tether/async_client.py b/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/tether/async_client.py index a9d118e68dcb..5576c8661013 100644 --- a/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/tether/async_client.py +++ b/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/tether/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, @@ -53,6 +54,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, TetherTransport from .transports.grpc_asyncio import TetherGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class TetherAsyncClient: """Tether provides a way for the control plane to send HTTP API @@ -250,13 +260,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.apigeeconnect_v1.TetherAsyncClient`.", + extra={ + "serviceName": "google.cloud.apigeeconnect.v1.Tether", + "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.apigeeconnect.v1.Tether", + "credentialsType": None, + }, + ) + def egress( self, requests: Optional[AsyncIterator[tether.EgressResponse]] = None, *, retry: OptionalRetry = 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[tether.EgressRequest]]: r"""Egress streams egress requests and responses. Logically, this is not actually a streaming request, but @@ -310,8 +342,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.apigeeconnect_v1.types.EgressRequest]: diff --git a/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/tether/client.py b/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/tether/client.py index 76e2ab733e96..4c037bad3e35 100644 --- a/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/tether/client.py +++ b/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/tether/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.protobuf import duration_pb2 # type: ignore from google.cloud.apigeeconnect_v1.types import tether @@ -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( @@ -621,13 +635,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.apigeeconnect_v1.TetherClient`.", + extra={ + "serviceName": "google.cloud.apigeeconnect.v1.Tether", + "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.apigeeconnect.v1.Tether", + "credentialsType": None, + }, + ) + def egress( self, requests: Optional[Iterator[tether.EgressResponse]] = None, *, retry: OptionalRetry = 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[tether.EgressRequest]: r"""Egress streams egress requests and responses. Logically, this is not actually a streaming request, but @@ -681,8 +718,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.apigeeconnect_v1.types.EgressRequest]: diff --git a/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/tether/transports/grpc.py b/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/tether/transports/grpc.py index bdaea571a9fa..5c4a9e874536 100644 --- a/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/tether/transports/grpc.py +++ b/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/tether/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.apigeeconnect_v1.types import tether from .base import DEFAULT_CLIENT_INFO, TetherTransport +try: + from google.api_core import client_logging # 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.apigeeconnect.v1.Tether", + "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.apigeeconnect.v1.Tether", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TetherGrpcTransport(TetherTransport): """gRPC backend transport for Tether. @@ -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 @@ -262,7 +348,7 @@ def egress(self) -> Callable[[tether.EgressResponse], tether.EgressRequest]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "egress" not in self._stubs: - self._stubs["egress"] = self.grpc_channel.stream_stream( + self._stubs["egress"] = self._logged_channel.stream_stream( "/google.cloud.apigeeconnect.v1.Tether/Egress", request_serializer=tether.EgressResponse.serialize, response_deserializer=tether.EgressRequest.deserialize, @@ -270,7 +356,7 @@ def egress(self) -> Callable[[tether.EgressResponse], tether.EgressRequest]: return self._stubs["egress"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/tether/transports/grpc_asyncio.py b/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/tether/transports/grpc_asyncio.py index 3ad4935e9c44..4125564ca6e5 100644 --- a/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/tether/transports/grpc_asyncio.py +++ b/packages/google-cloud-apigee-connect/google/cloud/apigeeconnect_v1/services/tether/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.apigeeconnect_v1.types import tether from .base import DEFAULT_CLIENT_INFO, TetherTransport from .grpc import TetherGrpcTransport +try: + from google.api_core import client_logging # 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.apigeeconnect.v1.Tether", + "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.apigeeconnect.v1.Tether", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class TetherGrpcAsyncIOTransport(TetherTransport): """gRPC AsyncIO backend transport for Tether. @@ -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 @@ -272,7 +357,7 @@ def egress( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "egress" not in self._stubs: - self._stubs["egress"] = self.grpc_channel.stream_stream( + self._stubs["egress"] = self._logged_channel.stream_stream( "/google.cloud.apigeeconnect.v1.Tether/Egress", request_serializer=tether.EgressResponse.serialize, response_deserializer=tether.EgressRequest.deserialize, @@ -295,7 +380,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-apigee-connect/samples/generated_samples/snippet_metadata_google.cloud.apigeeconnect.v1.json b/packages/google-cloud-apigee-connect/samples/generated_samples/snippet_metadata_google.cloud.apigeeconnect.v1.json index c859fe599d2a..ce1973950a71 100644 --- a/packages/google-cloud-apigee-connect/samples/generated_samples/snippet_metadata_google.cloud.apigeeconnect.v1.json +++ b/packages/google-cloud-apigee-connect/samples/generated_samples/snippet_metadata_google.cloud.apigeeconnect.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-apigee-connect", - "version": "1.10.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.apigeeconnect_v1.services.connection_service.pagers.ListConnectionsAsyncPager", @@ -127,7 +127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigeeconnect_v1.services.connection_service.pagers.ListConnectionsPager", @@ -204,7 +204,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.apigeeconnect_v1.types.EgressRequest]", @@ -280,7 +280,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "Iterable[google.cloud.apigeeconnect_v1.types.EgressRequest]", diff --git a/packages/google-cloud-apigee-registry/google/cloud/apigee_registry/gapic_version.py b/packages/google-cloud-apigee-registry/google/cloud/apigee_registry/gapic_version.py index b72badcc1eca..558c8aab67c5 100644 --- a/packages/google-cloud-apigee-registry/google/cloud/apigee_registry/gapic_version.py +++ b/packages/google-cloud-apigee-registry/google/cloud/apigee_registry/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.6.13" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/gapic_version.py b/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/gapic_version.py index b72badcc1eca..558c8aab67c5 100644 --- a/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/gapic_version.py +++ b/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.6.13" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/provisioning/async_client.py b/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/provisioning/async_client.py index ca5274fc7e40..f62e4b947ecf 100644 --- a/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/provisioning/async_client.py +++ b/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/provisioning/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, ProvisioningTransport from .transports.grpc_asyncio import ProvisioningGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class ProvisioningAsyncClient: """The service that is used for managing the data plane @@ -260,6 +270,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.apigeeregistry_v1.ProvisioningAsyncClient`.", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Provisioning", + "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.apigeeregistry.v1.Provisioning", + "credentialsType": None, + }, + ) + async def create_instance( self, request: Optional[ @@ -271,7 +303,7 @@ async def create_instance( instance_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Provisions instance resources for the Registry. @@ -336,8 +368,10 @@ async def sample_create_instance(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -415,7 +449,7 @@ async def delete_instance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes the Registry instance. @@ -462,8 +496,10 @@ async def sample_delete_instance(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -542,7 +578,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]]] = (), ) -> provisioning_service.Instance: r"""Gets details of a single Instance. @@ -585,8 +621,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.apigee_registry_v1.types.Instance: @@ -648,7 +686,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. @@ -659,8 +697,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. @@ -701,7 +741,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. @@ -712,8 +752,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. @@ -754,7 +796,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. @@ -770,8 +812,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 """ @@ -808,7 +852,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. @@ -823,8 +867,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 """ @@ -861,7 +907,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. @@ -874,8 +920,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. @@ -980,7 +1028,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. @@ -994,8 +1042,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. @@ -1100,7 +1150,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. @@ -1115,8 +1165,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. @@ -1160,7 +1212,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. @@ -1171,8 +1223,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. @@ -1213,7 +1267,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. @@ -1224,8 +1278,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-apigee-registry/google/cloud/apigee_registry_v1/services/provisioning/client.py b/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/provisioning/client.py index aeaea4f8ba3f..a7110deae9eb 100644 --- a/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/provisioning/client.py +++ b/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/provisioning/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore @@ -586,6 +596,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -648,6 +662,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.apigeeregistry_v1.ProvisioningClient`.", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Provisioning", + "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.apigeeregistry.v1.Provisioning", + "credentialsType": None, + }, + ) + def create_instance( self, request: Optional[ @@ -659,7 +696,7 @@ def create_instance( instance_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Provisions instance resources for the Registry. @@ -724,8 +761,10 @@ def sample_create_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -800,7 +839,7 @@ def delete_instance( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes the Registry instance. @@ -847,8 +886,10 @@ def sample_delete_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -924,7 +965,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]]] = (), ) -> provisioning_service.Instance: r"""Gets details of a single Instance. @@ -967,8 +1008,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.apigee_registry_v1.types.Instance: @@ -1040,7 +1083,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. @@ -1051,8 +1094,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. @@ -1093,7 +1138,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. @@ -1104,8 +1149,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. @@ -1146,7 +1193,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. @@ -1162,8 +1209,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 """ @@ -1200,7 +1249,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. @@ -1215,8 +1264,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 """ @@ -1253,7 +1304,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. @@ -1266,8 +1317,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. @@ -1372,7 +1425,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. @@ -1386,8 +1439,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. @@ -1492,7 +1547,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. @@ -1507,8 +1562,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. @@ -1550,7 +1607,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. @@ -1561,8 +1618,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. @@ -1603,7 +1662,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. @@ -1614,8 +1673,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-apigee-registry/google/cloud/apigee_registry_v1/services/provisioning/transports/grpc.py b/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/provisioning/transports/grpc.py index 9b3bf6846042..fdef66b357ac 100644 --- a/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/provisioning/transports/grpc.py +++ b/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/provisioning/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.apigee_registry_v1.types import provisioning_service from .base import DEFAULT_CLIENT_INFO, ProvisioningTransport +try: + from google.api_core import client_logging # 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.apigeeregistry.v1.Provisioning", + "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.apigeeregistry.v1.Provisioning", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ProvisioningGrpcTransport(ProvisioningTransport): """gRPC backend transport for Provisioning. @@ -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 @@ -275,7 +363,7 @@ def create_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_instance" not in self._stubs: - self._stubs["create_instance"] = self.grpc_channel.unary_unary( + self._stubs["create_instance"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Provisioning/CreateInstance", request_serializer=provisioning_service.CreateInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -303,7 +391,7 @@ def delete_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_instance" not in self._stubs: - self._stubs["delete_instance"] = self.grpc_channel.unary_unary( + self._stubs["delete_instance"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Provisioning/DeleteInstance", request_serializer=provisioning_service.DeleteInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -331,7 +419,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.apigeeregistry.v1.Provisioning/GetInstance", request_serializer=provisioning_service.GetInstanceRequest.serialize, response_deserializer=provisioning_service.Instance.deserialize, @@ -339,7 +427,7 @@ def get_instance( return self._stubs["get_instance"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -351,7 +439,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, @@ -368,7 +456,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, @@ -385,7 +473,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, @@ -404,7 +492,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, @@ -423,7 +511,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, @@ -440,7 +528,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, @@ -465,7 +553,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, @@ -491,7 +579,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, @@ -520,7 +608,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-apigee-registry/google/cloud/apigee_registry_v1/services/provisioning/transports/grpc_asyncio.py b/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/provisioning/transports/grpc_asyncio.py index 4cb39ed08b28..8ffdd93f98d8 100644 --- a/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/provisioning/transports/grpc_asyncio.py +++ b/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/provisioning/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.apigee_registry_v1.types import provisioning_service from .base import DEFAULT_CLIENT_INFO, ProvisioningTransport from .grpc import ProvisioningGrpcTransport +try: + from google.api_core import client_logging # 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.apigeeregistry.v1.Provisioning", + "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.apigeeregistry.v1.Provisioning", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ProvisioningGrpcAsyncIOTransport(ProvisioningTransport): """gRPC AsyncIO backend transport for Provisioning. @@ -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. @@ -286,7 +371,7 @@ def create_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_instance" not in self._stubs: - self._stubs["create_instance"] = self.grpc_channel.unary_unary( + self._stubs["create_instance"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Provisioning/CreateInstance", request_serializer=provisioning_service.CreateInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -315,7 +400,7 @@ def delete_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_instance" not in self._stubs: - self._stubs["delete_instance"] = self.grpc_channel.unary_unary( + self._stubs["delete_instance"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Provisioning/DeleteInstance", request_serializer=provisioning_service.DeleteInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -344,7 +429,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.apigeeregistry.v1.Provisioning/GetInstance", request_serializer=provisioning_service.GetInstanceRequest.serialize, response_deserializer=provisioning_service.Instance.deserialize, @@ -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 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, @@ -455,7 +540,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, @@ -472,7 +557,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, @@ -491,7 +576,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, @@ -510,7 +595,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, @@ -527,7 +612,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, @@ -552,7 +637,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, @@ -578,7 +663,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, @@ -607,7 +692,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-apigee-registry/google/cloud/apigee_registry_v1/services/provisioning/transports/rest.py b/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/provisioning/transports/rest.py index 7c8d64ba5fed..4e00f6d48821 100644 --- a/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/provisioning/transports/rest.py +++ b/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/provisioning/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,11 @@ def post_get_instance(self, response): def pre_create_instance( self, request: provisioning_service.CreateInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[provisioning_service.CreateInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + provisioning_service.CreateInstanceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_instance Override in a subclass to manipulate the request or metadata @@ -120,8 +131,11 @@ def post_create_instance( def pre_delete_instance( self, request: provisioning_service.DeleteInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[provisioning_service.DeleteInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + provisioning_service.DeleteInstanceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_instance Override in a subclass to manipulate the request or metadata @@ -143,8 +157,10 @@ def post_delete_instance( def pre_get_instance( self, request: provisioning_service.GetInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[provisioning_service.GetInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + provisioning_service.GetInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_instance Override in a subclass to manipulate the request or metadata @@ -166,8 +182,10 @@ def post_get_instance( def pre_get_location( self, request: locations_pb2.GetLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -189,8 +207,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 +232,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 +255,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 +278,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 +304,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 +327,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 +350,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 +375,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 @@ -539,7 +574,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create instance method over HTTP. @@ -549,8 +584,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -563,6 +600,7 @@ def __call__( http_options = ( _BaseProvisioningRestTransport._BaseCreateInstance._get_http_options() ) + request, metadata = self._interceptor.pre_create_instance(request, metadata) transcoded_request = _BaseProvisioningRestTransport._BaseCreateInstance._get_transcoded_request( http_options, request @@ -577,6 +615,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.ProvisioningClient.CreateInstance", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Provisioning", + "rpcName": "CreateInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProvisioningRestTransport._CreateInstance._get_response( self._host, @@ -596,7 +661,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_instance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigeeregistry_v1.ProvisioningClient.create_instance", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Provisioning", + "rpcName": "CreateInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteInstance( @@ -633,7 +720,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete instance method over HTTP. @@ -643,8 +730,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -657,6 +746,7 @@ def __call__( http_options = ( _BaseProvisioningRestTransport._BaseDeleteInstance._get_http_options() ) + request, metadata = self._interceptor.pre_delete_instance(request, metadata) transcoded_request = _BaseProvisioningRestTransport._BaseDeleteInstance._get_transcoded_request( http_options, request @@ -667,6 +757,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.ProvisioningClient.DeleteInstance", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Provisioning", + "rpcName": "DeleteInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProvisioningRestTransport._DeleteInstance._get_response( self._host, @@ -685,7 +802,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_instance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigeeregistry_v1.ProvisioningClient.delete_instance", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Provisioning", + "rpcName": "DeleteInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetInstance( @@ -722,7 +861,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> provisioning_service.Instance: r"""Call the get instance method over HTTP. @@ -732,8 +871,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.provisioning_service.Instance: @@ -747,6 +888,7 @@ def __call__( http_options = ( _BaseProvisioningRestTransport._BaseGetInstance._get_http_options() ) + request, metadata = self._interceptor.pre_get_instance(request, metadata) transcoded_request = ( _BaseProvisioningRestTransport._BaseGetInstance._get_transcoded_request( @@ -761,6 +903,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.ProvisioningClient.GetInstance", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Provisioning", + "rpcName": "GetInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProvisioningRestTransport._GetInstance._get_response( self._host, @@ -781,7 +950,29 @@ def __call__( pb_resp = provisioning_service.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 = provisioning_service.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.apigeeregistry_v1.ProvisioningClient.get_instance", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Provisioning", + "rpcName": "GetInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -852,7 +1043,7 @@ 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. @@ -862,8 +1053,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -872,6 +1065,7 @@ def __call__( http_options = ( _BaseProvisioningRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseProvisioningRestTransport._BaseGetLocation._get_transcoded_request( @@ -886,6 +1080,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.ProvisioningClient.GetLocation", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Provisioning", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProvisioningRestTransport._GetLocation._get_response( self._host, @@ -905,6 +1126,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.apigeeregistry_v1.ProvisioningAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Provisioning", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -945,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]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -955,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: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -965,6 +1209,7 @@ def __call__( http_options = ( _BaseProvisioningRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseProvisioningRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -975,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.apigeeregistry_v1.ProvisioningClient.ListLocations", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Provisioning", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProvisioningRestTransport._ListLocations._get_response( self._host, @@ -994,6 +1266,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.apigeeregistry_v1.ProvisioningAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Provisioning", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1034,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]]] = (), ) -> policy_pb2.Policy: r"""Call the get iam policy method over HTTP. @@ -1044,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: policy_pb2.Policy: Response from GetIamPolicy method. @@ -1054,6 +1349,7 @@ def __call__( http_options = ( _BaseProvisioningRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseProvisioningRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -1066,6 +1362,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.ProvisioningClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Provisioning", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProvisioningRestTransport._GetIamPolicy._get_response( self._host, @@ -1085,6 +1408,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.apigeeregistry_v1.ProvisioningAsyncClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Provisioning", + "rpcName": "GetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1126,7 +1470,7 @@ 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. @@ -1136,8 +1480,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -1146,6 +1492,7 @@ def __call__( http_options = ( _BaseProvisioningRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseProvisioningRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -1164,6 +1511,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.ProvisioningClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Provisioning", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProvisioningRestTransport._SetIamPolicy._get_response( self._host, @@ -1184,6 +1558,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.apigeeregistry_v1.ProvisioningAsyncClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Provisioning", + "rpcName": "SetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1225,7 +1620,7 @@ 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. @@ -1235,8 +1630,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -1245,6 +1642,7 @@ def __call__( http_options = ( _BaseProvisioningRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1261,6 +1659,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.ProvisioningClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Provisioning", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProvisioningRestTransport._TestIamPermissions._get_response( self._host, @@ -1281,6 +1706,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.apigeeregistry_v1.ProvisioningAsyncClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Provisioning", + "rpcName": "TestIamPermissions", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1322,7 +1768,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1332,13 +1778,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 = ( _BaseProvisioningRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1355,6 +1804,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.ProvisioningClient.CancelOperation", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Provisioning", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProvisioningRestTransport._CancelOperation._get_response( self._host, @@ -1411,7 +1887,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -1421,13 +1897,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 = ( _BaseProvisioningRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -1440,6 +1919,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.ProvisioningClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Provisioning", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProvisioningRestTransport._DeleteOperation._get_response( self._host, @@ -1495,7 +2001,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1505,8 +2011,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -1515,6 +2023,7 @@ def __call__( http_options = ( _BaseProvisioningRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseProvisioningRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1527,6 +2036,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.ProvisioningClient.GetOperation", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Provisioning", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProvisioningRestTransport._GetOperation._get_response( self._host, @@ -1546,6 +2082,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.apigeeregistry_v1.ProvisioningAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Provisioning", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1586,7 +2143,7 @@ def __call__( *, 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. @@ -1596,8 +2153,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1606,6 +2165,7 @@ def __call__( http_options = ( _BaseProvisioningRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseProvisioningRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1616,6 +2176,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.ProvisioningClient.ListOperations", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Provisioning", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProvisioningRestTransport._ListOperations._get_response( self._host, @@ -1635,6 +2222,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.apigeeregistry_v1.ProvisioningAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Provisioning", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/registry/async_client.py b/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/registry/async_client.py index 5b297bff21ae..66481d83f1d9 100644 --- a/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/registry/async_client.py +++ b/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/registry/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, RegistryTransport from .transports.grpc_asyncio import RegistryGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class RegistryAsyncClient: """The Registry service allows teams to manage descriptions of @@ -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.apigeeregistry_v1.RegistryAsyncClient`.", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "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.apigeeregistry.v1.Registry", + "credentialsType": None, + }, + ) + async def list_apis( self, request: Optional[Union[registry_service.ListApisRequest, dict]] = None, @@ -272,7 +304,7 @@ async def list_apis( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListApisAsyncPager: r"""Returns matching APIs. @@ -316,8 +348,10 @@ async def sample_list_apis(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.services.registry.pagers.ListApisAsyncPager: @@ -392,7 +426,7 @@ async def get_api( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.Api: r"""Returns a specified API. @@ -435,8 +469,10 @@ async def sample_get_api(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.types.Api: @@ -498,7 +534,7 @@ async def create_api( api_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]]] = (), ) -> registry_models.Api: r"""Creates a specified API. @@ -559,8 +595,10 @@ async def sample_create_api(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.types.Api: @@ -627,7 +665,7 @@ async def update_api( 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]]] = (), ) -> registry_models.Api: r"""Used to modify a specified API. @@ -681,8 +719,10 @@ async def sample_update_api(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.types.Api: @@ -746,7 +786,7 @@ async def delete_api( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 specified API and all of the resources that it owns. @@ -787,8 +827,10 @@ async def sample_delete_api(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -840,7 +882,7 @@ async def list_api_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.ListApiVersionsAsyncPager: r"""Returns matching versions. @@ -884,8 +926,10 @@ async def sample_list_api_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.apigee_registry_v1.services.registry.pagers.ListApiVersionsAsyncPager: @@ -960,7 +1004,7 @@ async def get_api_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]]] = (), ) -> registry_models.ApiVersion: r"""Returns a specified version. @@ -1003,8 +1047,10 @@ async def sample_get_api_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.apigee_registry_v1.types.ApiVersion: @@ -1068,7 +1114,7 @@ async def create_api_version( api_version_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]]] = (), ) -> registry_models.ApiVersion: r"""Creates a specified version. @@ -1130,8 +1176,10 @@ async def sample_create_api_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.apigee_registry_v1.types.ApiVersion: @@ -1198,7 +1246,7 @@ async def update_api_version( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.ApiVersion: r"""Used to modify a specified version. @@ -1253,8 +1301,10 @@ async def sample_update_api_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.apigee_registry_v1.types.ApiVersion: @@ -1320,7 +1370,7 @@ async def delete_api_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Removes a specified version and all of the resources that it owns. @@ -1361,8 +1411,10 @@ async def sample_delete_api_version(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1414,7 +1466,7 @@ async def list_api_specs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListApiSpecsAsyncPager: r"""Returns matching specs. @@ -1459,8 +1511,10 @@ async def sample_list_api_specs(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.services.registry.pagers.ListApiSpecsAsyncPager: @@ -1535,7 +1589,7 @@ async def get_api_spec( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.ApiSpec: r"""Returns a specified spec. @@ -1578,8 +1632,10 @@ async def sample_get_api_spec(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.types.ApiSpec: @@ -1654,7 +1710,7 @@ async def get_api_spec_contents( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> httpbody_pb2.HttpBody: r"""Returns the contents of a specified spec. If specs are stored with GZip compression, the default behavior is to return the @@ -1702,8 +1758,10 @@ async def sample_get_api_spec_contents(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api.httpbody_pb2.HttpBody: @@ -1810,7 +1868,7 @@ async def create_api_spec( api_spec_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]]] = (), ) -> registry_models.ApiSpec: r"""Creates a specified spec. @@ -1872,8 +1930,10 @@ async def sample_create_api_spec(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.types.ApiSpec: @@ -1951,7 +2011,7 @@ async def update_api_spec( 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]]] = (), ) -> registry_models.ApiSpec: r"""Used to modify a specified spec. @@ -2006,8 +2066,10 @@ async def sample_update_api_spec(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.types.ApiSpec: @@ -2084,7 +2146,7 @@ async def delete_api_spec( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Removes a specified spec, all revisions, and all child resources (e.g., artifacts). @@ -2125,8 +2187,10 @@ async def sample_delete_api_spec(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2179,7 +2243,7 @@ async def tag_api_spec_revision( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.ApiSpec: r"""Adds a tag to a specified revision of a spec. @@ -2217,8 +2281,10 @@ async def sample_tag_api_spec_revision(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.types.ApiSpec: @@ -2278,7 +2344,7 @@ async def list_api_spec_revisions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListApiSpecRevisionsAsyncPager: r"""Lists all revisions of a spec. Revisions are returned in descending order of revision @@ -2318,8 +2384,10 @@ async def sample_list_api_spec_revisions(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.services.registry.pagers.ListApiSpecRevisionsAsyncPager: @@ -2379,7 +2447,7 @@ async def rollback_api_spec( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.ApiSpec: r"""Sets the current revision to a specified prior revision. Note that this creates a new revision with a @@ -2418,8 +2486,10 @@ async def sample_rollback_api_spec(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.types.ApiSpec: @@ -2480,7 +2550,7 @@ async def delete_api_spec_revision( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.ApiSpec: r"""Deletes a revision of a spec. @@ -2527,8 +2597,10 @@ async def sample_delete_api_spec_revision(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.types.ApiSpec: @@ -2603,7 +2675,7 @@ async def list_api_deployments( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListApiDeploymentsAsyncPager: r"""Returns matching deployments. @@ -2648,8 +2720,10 @@ async def sample_list_api_deployments(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.services.registry.pagers.ListApiDeploymentsAsyncPager: @@ -2724,7 +2798,7 @@ async def get_api_deployment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.ApiDeployment: r"""Returns a specified deployment. @@ -2767,8 +2841,10 @@ async def sample_get_api_deployment(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.types.ApiDeployment: @@ -2840,7 +2916,7 @@ async def create_api_deployment( api_deployment_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.ApiDeployment: r"""Creates a specified deployment. @@ -2903,8 +2979,10 @@ async def sample_create_api_deployment(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.types.ApiDeployment: @@ -2979,7 +3057,7 @@ async def update_api_deployment( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.ApiDeployment: r"""Used to modify a specified deployment. @@ -3035,8 +3113,10 @@ async def sample_update_api_deployment(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.types.ApiDeployment: @@ -3110,7 +3190,7 @@ async def delete_api_deployment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Removes a specified deployment, all revisions, and all child resources (e.g., artifacts). @@ -3152,8 +3232,10 @@ async def sample_delete_api_deployment(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -3206,7 +3288,7 @@ async def tag_api_deployment_revision( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.ApiDeployment: r"""Adds a tag to a specified revision of a deployment. @@ -3245,8 +3327,10 @@ async def sample_tag_api_deployment_revision(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.types.ApiDeployment: @@ -3301,7 +3385,7 @@ async def list_api_deployment_revisions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListApiDeploymentRevisionsAsyncPager: r"""Lists all revisions of a deployment. Revisions are returned in descending order of revision @@ -3341,8 +3425,10 @@ async def sample_list_api_deployment_revisions(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.services.registry.pagers.ListApiDeploymentRevisionsAsyncPager: @@ -3404,7 +3490,7 @@ async def rollback_api_deployment( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.ApiDeployment: r"""Sets the current revision to a specified prior revision. Note that this creates a new revision with a @@ -3444,8 +3530,10 @@ async def sample_rollback_api_deployment(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.types.ApiDeployment: @@ -3501,7 +3589,7 @@ async def delete_api_deployment_revision( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.ApiDeployment: r"""Deletes a revision of a deployment. @@ -3548,8 +3636,10 @@ async def sample_delete_api_deployment_revision(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.types.ApiDeployment: @@ -3617,7 +3707,7 @@ async def list_artifacts( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListArtifactsAsyncPager: r"""Returns matching artifacts. @@ -3661,8 +3751,10 @@ async def sample_list_artifacts(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.services.registry.pagers.ListArtifactsAsyncPager: @@ -3737,7 +3829,7 @@ async def get_artifact( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.Artifact: r"""Returns a specified artifact. @@ -3780,8 +3872,10 @@ async def sample_get_artifact(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.types.Artifact: @@ -3853,7 +3947,7 @@ async def get_artifact_contents( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> httpbody_pb2.HttpBody: r"""Returns the contents of a specified artifact. If artifacts are stored with GZip compression, the default behavior is to return @@ -3900,8 +3994,10 @@ async def sample_get_artifact_contents(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api.httpbody_pb2.HttpBody: @@ -4008,7 +4104,7 @@ async def create_artifact( artifact_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]]] = (), ) -> registry_models.Artifact: r"""Creates a specified artifact. @@ -4070,8 +4166,10 @@ async def sample_create_artifact(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.types.Artifact: @@ -4145,7 +4243,7 @@ async def replace_artifact( artifact: Optional[registry_models.Artifact] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.Artifact: r"""Used to replace a specified artifact. @@ -4189,8 +4287,10 @@ async def sample_replace_artifact(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.types.Artifact: @@ -4262,7 +4362,7 @@ async def delete_artifact( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 specified artifact. @@ -4302,8 +4402,10 @@ async def sample_delete_artifact(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -4354,7 +4456,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. @@ -4365,8 +4467,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. @@ -4407,7 +4511,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. @@ -4418,8 +4522,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. @@ -4460,7 +4566,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. @@ -4476,8 +4582,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 """ @@ -4514,7 +4622,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. @@ -4529,8 +4637,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 """ @@ -4567,7 +4677,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. @@ -4580,8 +4690,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. @@ -4686,7 +4798,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. @@ -4700,8 +4812,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. @@ -4806,7 +4920,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. @@ -4821,8 +4935,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. @@ -4866,7 +4982,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. @@ -4877,8 +4993,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. @@ -4919,7 +5037,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. @@ -4930,8 +5048,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-apigee-registry/google/cloud/apigee_registry_v1/services/registry/client.py b/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/registry/client.py index 43b0a11b2a0e..b9fdde2a8a2b 100644 --- a/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/registry/client.py +++ b/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/registry/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + from google.api import httpbody_pb2 # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.iam.v1 import iam_policy_pb2 # type: ignore @@ -683,6 +693,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( @@ -745,6 +759,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.apigeeregistry_v1.RegistryClient`.", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "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.apigeeregistry.v1.Registry", + "credentialsType": None, + }, + ) + def list_apis( self, request: Optional[Union[registry_service.ListApisRequest, dict]] = None, @@ -752,7 +789,7 @@ def list_apis( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListApisPager: r"""Returns matching APIs. @@ -796,8 +833,10 @@ def sample_list_apis(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.services.registry.pagers.ListApisPager: @@ -869,7 +908,7 @@ def get_api( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.Api: r"""Returns a specified API. @@ -912,8 +951,10 @@ def sample_get_api(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.types.Api: @@ -974,7 +1015,7 @@ def create_api( api_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]]] = (), ) -> registry_models.Api: r"""Creates a specified API. @@ -1035,8 +1076,10 @@ def sample_create_api(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.types.Api: @@ -1100,7 +1143,7 @@ def update_api( 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]]] = (), ) -> registry_models.Api: r"""Used to modify a specified API. @@ -1154,8 +1197,10 @@ def sample_update_api(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.types.Api: @@ -1216,7 +1261,7 @@ def delete_api( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 specified API and all of the resources that it owns. @@ -1257,8 +1302,10 @@ def sample_delete_api(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -1307,7 +1354,7 @@ def list_api_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.ListApiVersionsPager: r"""Returns matching versions. @@ -1351,8 +1398,10 @@ def sample_list_api_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.apigee_registry_v1.services.registry.pagers.ListApiVersionsPager: @@ -1424,7 +1473,7 @@ def get_api_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]]] = (), ) -> registry_models.ApiVersion: r"""Returns a specified version. @@ -1467,8 +1516,10 @@ def sample_get_api_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.apigee_registry_v1.types.ApiVersion: @@ -1529,7 +1580,7 @@ def create_api_version( api_version_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]]] = (), ) -> registry_models.ApiVersion: r"""Creates a specified version. @@ -1591,8 +1642,10 @@ def sample_create_api_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.apigee_registry_v1.types.ApiVersion: @@ -1656,7 +1709,7 @@ def update_api_version( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.ApiVersion: r"""Used to modify a specified version. @@ -1711,8 +1764,10 @@ def sample_update_api_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.apigee_registry_v1.types.ApiVersion: @@ -1775,7 +1830,7 @@ def delete_api_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Removes a specified version and all of the resources that it owns. @@ -1816,8 +1871,10 @@ def sample_delete_api_version(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1866,7 +1923,7 @@ def list_api_specs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListApiSpecsPager: r"""Returns matching specs. @@ -1911,8 +1968,10 @@ def sample_list_api_specs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.services.registry.pagers.ListApiSpecsPager: @@ -1984,7 +2043,7 @@ def get_api_spec( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.ApiSpec: r"""Returns a specified spec. @@ -2027,8 +2086,10 @@ def sample_get_api_spec(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.types.ApiSpec: @@ -2100,7 +2161,7 @@ def get_api_spec_contents( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> httpbody_pb2.HttpBody: r"""Returns the contents of a specified spec. If specs are stored with GZip compression, the default behavior is to return the @@ -2148,8 +2209,10 @@ def sample_get_api_spec_contents(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api.httpbody_pb2.HttpBody: @@ -2253,7 +2316,7 @@ def create_api_spec( api_spec_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]]] = (), ) -> registry_models.ApiSpec: r"""Creates a specified spec. @@ -2315,8 +2378,10 @@ def sample_create_api_spec(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.types.ApiSpec: @@ -2391,7 +2456,7 @@ def update_api_spec( 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]]] = (), ) -> registry_models.ApiSpec: r"""Used to modify a specified spec. @@ -2446,8 +2511,10 @@ def sample_update_api_spec(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.types.ApiSpec: @@ -2521,7 +2588,7 @@ def delete_api_spec( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Removes a specified spec, all revisions, and all child resources (e.g., artifacts). @@ -2562,8 +2629,10 @@ def sample_delete_api_spec(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2613,7 +2682,7 @@ def tag_api_spec_revision( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.ApiSpec: r"""Adds a tag to a specified revision of a spec. @@ -2651,8 +2720,10 @@ def sample_tag_api_spec_revision(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.types.ApiSpec: @@ -2710,7 +2781,7 @@ def list_api_spec_revisions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListApiSpecRevisionsPager: r"""Lists all revisions of a spec. Revisions are returned in descending order of revision @@ -2750,8 +2821,10 @@ def sample_list_api_spec_revisions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.services.registry.pagers.ListApiSpecRevisionsPager: @@ -2809,7 +2882,7 @@ def rollback_api_spec( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.ApiSpec: r"""Sets the current revision to a specified prior revision. Note that this creates a new revision with a @@ -2848,8 +2921,10 @@ def sample_rollback_api_spec(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.types.ApiSpec: @@ -2908,7 +2983,7 @@ def delete_api_spec_revision( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.ApiSpec: r"""Deletes a revision of a spec. @@ -2955,8 +3030,10 @@ def sample_delete_api_spec_revision(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.types.ApiSpec: @@ -3028,7 +3105,7 @@ def list_api_deployments( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListApiDeploymentsPager: r"""Returns matching deployments. @@ -3073,8 +3150,10 @@ def sample_list_api_deployments(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.services.registry.pagers.ListApiDeploymentsPager: @@ -3146,7 +3225,7 @@ def get_api_deployment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.ApiDeployment: r"""Returns a specified deployment. @@ -3189,8 +3268,10 @@ def sample_get_api_deployment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.types.ApiDeployment: @@ -3259,7 +3340,7 @@ def create_api_deployment( api_deployment_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.ApiDeployment: r"""Creates a specified deployment. @@ -3322,8 +3403,10 @@ def sample_create_api_deployment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.types.ApiDeployment: @@ -3395,7 +3478,7 @@ def update_api_deployment( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.ApiDeployment: r"""Used to modify a specified deployment. @@ -3451,8 +3534,10 @@ def sample_update_api_deployment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.types.ApiDeployment: @@ -3523,7 +3608,7 @@ def delete_api_deployment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Removes a specified deployment, all revisions, and all child resources (e.g., artifacts). @@ -3565,8 +3650,10 @@ def sample_delete_api_deployment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -3616,7 +3703,7 @@ def tag_api_deployment_revision( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.ApiDeployment: r"""Adds a tag to a specified revision of a deployment. @@ -3655,8 +3742,10 @@ def sample_tag_api_deployment_revision(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.types.ApiDeployment: @@ -3711,7 +3800,7 @@ def list_api_deployment_revisions( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListApiDeploymentRevisionsPager: r"""Lists all revisions of a deployment. Revisions are returned in descending order of revision @@ -3751,8 +3840,10 @@ def sample_list_api_deployment_revisions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.services.registry.pagers.ListApiDeploymentRevisionsPager: @@ -3814,7 +3905,7 @@ def rollback_api_deployment( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.ApiDeployment: r"""Sets the current revision to a specified prior revision. Note that this creates a new revision with a @@ -3854,8 +3945,10 @@ def sample_rollback_api_deployment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.types.ApiDeployment: @@ -3909,7 +4002,7 @@ def delete_api_deployment_revision( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.ApiDeployment: r"""Deletes a revision of a deployment. @@ -3956,8 +4049,10 @@ def sample_delete_api_deployment_revision(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.types.ApiDeployment: @@ -4024,7 +4119,7 @@ def list_artifacts( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListArtifactsPager: r"""Returns matching artifacts. @@ -4068,8 +4163,10 @@ def sample_list_artifacts(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.services.registry.pagers.ListArtifactsPager: @@ -4141,7 +4238,7 @@ def get_artifact( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.Artifact: r"""Returns a specified artifact. @@ -4184,8 +4281,10 @@ def sample_get_artifact(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.types.Artifact: @@ -4254,7 +4353,7 @@ def get_artifact_contents( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> httpbody_pb2.HttpBody: r"""Returns the contents of a specified artifact. If artifacts are stored with GZip compression, the default behavior is to return @@ -4301,8 +4400,10 @@ def sample_get_artifact_contents(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api.httpbody_pb2.HttpBody: @@ -4406,7 +4507,7 @@ def create_artifact( artifact_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]]] = (), ) -> registry_models.Artifact: r"""Creates a specified artifact. @@ -4468,8 +4569,10 @@ def sample_create_artifact(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.types.Artifact: @@ -4540,7 +4643,7 @@ def replace_artifact( artifact: Optional[registry_models.Artifact] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.Artifact: r"""Used to replace a specified artifact. @@ -4584,8 +4687,10 @@ def sample_replace_artifact(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apigee_registry_v1.types.Artifact: @@ -4654,7 +4759,7 @@ def delete_artifact( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 specified artifact. @@ -4694,8 +4799,10 @@ def sample_delete_artifact(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -4756,7 +4863,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. @@ -4767,8 +4874,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. @@ -4809,7 +4918,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. @@ -4820,8 +4929,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. @@ -4862,7 +4973,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. @@ -4878,8 +4989,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 """ @@ -4916,7 +5029,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. @@ -4931,8 +5044,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 """ @@ -4969,7 +5084,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. @@ -4982,8 +5097,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. @@ -5088,7 +5205,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. @@ -5102,8 +5219,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. @@ -5208,7 +5327,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. @@ -5223,8 +5342,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. @@ -5266,7 +5387,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. @@ -5277,8 +5398,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. @@ -5319,7 +5442,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. @@ -5330,8 +5453,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-apigee-registry/google/cloud/apigee_registry_v1/services/registry/pagers.py b/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/registry/pagers.py index 71836ce85470..41b410548560 100644 --- a/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/registry/pagers.py +++ b/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/registry/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 = registry_service.ListApisRequest(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 = registry_service.ListApisRequest(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 = registry_service.ListApiVersionsRequest(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 = registry_service.ListApiVersionsRequest(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 = registry_service.ListApiSpecsRequest(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 = registry_service.ListApiSpecsRequest(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 = registry_service.ListApiSpecRevisionsRequest(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 = registry_service.ListApiSpecRevisionsRequest(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 = registry_service.ListApiDeploymentsRequest(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 = registry_service.ListApiDeploymentsRequest(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 = registry_service.ListApiDeploymentRevisionsRequest(request) @@ -905,7 +927,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. @@ -919,8 +941,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 = registry_service.ListApiDeploymentRevisionsRequest(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 = registry_service.ListArtifactsRequest(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 = registry_service.ListArtifactsRequest(request) diff --git a/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/registry/transports/grpc.py b/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/registry/transports/grpc.py index d0f9996c8bb0..9f2932f2a752 100644 --- a/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/registry/transports/grpc.py +++ b/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/registry/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 @@ -26,12 +29,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.apigee_registry_v1.types import registry_models, registry_service from .base import DEFAULT_CLIENT_INFO, RegistryTransport +try: + from google.api_core import client_logging # 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.apigeeregistry.v1.Registry", + "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.apigeeregistry.v1.Registry", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class RegistryGrpcTransport(RegistryTransport): """gRPC backend transport for Registry. @@ -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 list_apis( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_apis" not in self._stubs: - self._stubs["list_apis"] = self.grpc_channel.unary_unary( + self._stubs["list_apis"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/ListApis", request_serializer=registry_service.ListApisRequest.serialize, response_deserializer=registry_service.ListApisResponse.deserialize, @@ -288,7 +374,7 @@ def get_api( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_api" not in self._stubs: - self._stubs["get_api"] = self.grpc_channel.unary_unary( + self._stubs["get_api"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/GetApi", request_serializer=registry_service.GetApiRequest.serialize, response_deserializer=registry_models.Api.deserialize, @@ -314,7 +400,7 @@ def create_api( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_api" not in self._stubs: - self._stubs["create_api"] = self.grpc_channel.unary_unary( + self._stubs["create_api"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/CreateApi", request_serializer=registry_service.CreateApiRequest.serialize, response_deserializer=registry_models.Api.deserialize, @@ -340,7 +426,7 @@ def update_api( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_api" not in self._stubs: - self._stubs["update_api"] = self.grpc_channel.unary_unary( + self._stubs["update_api"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/UpdateApi", request_serializer=registry_service.UpdateApiRequest.serialize, response_deserializer=registry_models.Api.deserialize, @@ -367,7 +453,7 @@ def delete_api( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_api" not in self._stubs: - self._stubs["delete_api"] = self.grpc_channel.unary_unary( + self._stubs["delete_api"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/DeleteApi", request_serializer=registry_service.DeleteApiRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -396,7 +482,7 @@ def list_api_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_api_versions" not in self._stubs: - self._stubs["list_api_versions"] = self.grpc_channel.unary_unary( + self._stubs["list_api_versions"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/ListApiVersions", request_serializer=registry_service.ListApiVersionsRequest.serialize, response_deserializer=registry_service.ListApiVersionsResponse.deserialize, @@ -422,7 +508,7 @@ def get_api_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_api_version" not in self._stubs: - self._stubs["get_api_version"] = self.grpc_channel.unary_unary( + self._stubs["get_api_version"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/GetApiVersion", request_serializer=registry_service.GetApiVersionRequest.serialize, response_deserializer=registry_models.ApiVersion.deserialize, @@ -450,7 +536,7 @@ def create_api_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_api_version" not in self._stubs: - self._stubs["create_api_version"] = self.grpc_channel.unary_unary( + self._stubs["create_api_version"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/CreateApiVersion", request_serializer=registry_service.CreateApiVersionRequest.serialize, response_deserializer=registry_models.ApiVersion.deserialize, @@ -478,7 +564,7 @@ def update_api_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_api_version" not in self._stubs: - self._stubs["update_api_version"] = self.grpc_channel.unary_unary( + self._stubs["update_api_version"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/UpdateApiVersion", request_serializer=registry_service.UpdateApiVersionRequest.serialize, response_deserializer=registry_models.ApiVersion.deserialize, @@ -505,7 +591,7 @@ def delete_api_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_api_version" not in self._stubs: - self._stubs["delete_api_version"] = self.grpc_channel.unary_unary( + self._stubs["delete_api_version"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/DeleteApiVersion", request_serializer=registry_service.DeleteApiVersionRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -533,7 +619,7 @@ def list_api_specs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_api_specs" not in self._stubs: - self._stubs["list_api_specs"] = self.grpc_channel.unary_unary( + self._stubs["list_api_specs"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/ListApiSpecs", request_serializer=registry_service.ListApiSpecsRequest.serialize, response_deserializer=registry_service.ListApiSpecsResponse.deserialize, @@ -559,7 +645,7 @@ def get_api_spec( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_api_spec" not in self._stubs: - self._stubs["get_api_spec"] = self.grpc_channel.unary_unary( + self._stubs["get_api_spec"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/GetApiSpec", request_serializer=registry_service.GetApiSpecRequest.serialize, response_deserializer=registry_models.ApiSpec.deserialize, @@ -588,7 +674,7 @@ def get_api_spec_contents( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_api_spec_contents" not in self._stubs: - self._stubs["get_api_spec_contents"] = self.grpc_channel.unary_unary( + self._stubs["get_api_spec_contents"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/GetApiSpecContents", request_serializer=registry_service.GetApiSpecContentsRequest.serialize, response_deserializer=httpbody_pb2.HttpBody.FromString, @@ -614,7 +700,7 @@ def create_api_spec( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_api_spec" not in self._stubs: - self._stubs["create_api_spec"] = self.grpc_channel.unary_unary( + self._stubs["create_api_spec"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/CreateApiSpec", request_serializer=registry_service.CreateApiSpecRequest.serialize, response_deserializer=registry_models.ApiSpec.deserialize, @@ -640,7 +726,7 @@ def update_api_spec( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_api_spec" not in self._stubs: - self._stubs["update_api_spec"] = self.grpc_channel.unary_unary( + self._stubs["update_api_spec"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/UpdateApiSpec", request_serializer=registry_service.UpdateApiSpecRequest.serialize, response_deserializer=registry_models.ApiSpec.deserialize, @@ -667,7 +753,7 @@ def delete_api_spec( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_api_spec" not in self._stubs: - self._stubs["delete_api_spec"] = self.grpc_channel.unary_unary( + self._stubs["delete_api_spec"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/DeleteApiSpec", request_serializer=registry_service.DeleteApiSpecRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -695,7 +781,7 @@ def tag_api_spec_revision( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "tag_api_spec_revision" not in self._stubs: - self._stubs["tag_api_spec_revision"] = self.grpc_channel.unary_unary( + self._stubs["tag_api_spec_revision"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/TagApiSpecRevision", request_serializer=registry_service.TagApiSpecRevisionRequest.serialize, response_deserializer=registry_models.ApiSpec.deserialize, @@ -726,7 +812,7 @@ def list_api_spec_revisions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_api_spec_revisions" not in self._stubs: - self._stubs["list_api_spec_revisions"] = self.grpc_channel.unary_unary( + self._stubs["list_api_spec_revisions"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/ListApiSpecRevisions", request_serializer=registry_service.ListApiSpecRevisionsRequest.serialize, response_deserializer=registry_service.ListApiSpecRevisionsResponse.deserialize, @@ -754,7 +840,7 @@ def rollback_api_spec( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "rollback_api_spec" not in self._stubs: - self._stubs["rollback_api_spec"] = self.grpc_channel.unary_unary( + self._stubs["rollback_api_spec"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/RollbackApiSpec", request_serializer=registry_service.RollbackApiSpecRequest.serialize, response_deserializer=registry_models.ApiSpec.deserialize, @@ -782,7 +868,7 @@ def delete_api_spec_revision( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_api_spec_revision" not in self._stubs: - self._stubs["delete_api_spec_revision"] = self.grpc_channel.unary_unary( + self._stubs["delete_api_spec_revision"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/DeleteApiSpecRevision", request_serializer=registry_service.DeleteApiSpecRevisionRequest.serialize, response_deserializer=registry_models.ApiSpec.deserialize, @@ -811,7 +897,7 @@ def list_api_deployments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_api_deployments" not in self._stubs: - self._stubs["list_api_deployments"] = self.grpc_channel.unary_unary( + self._stubs["list_api_deployments"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/ListApiDeployments", request_serializer=registry_service.ListApiDeploymentsRequest.serialize, response_deserializer=registry_service.ListApiDeploymentsResponse.deserialize, @@ -839,7 +925,7 @@ def get_api_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_api_deployment" not in self._stubs: - self._stubs["get_api_deployment"] = self.grpc_channel.unary_unary( + self._stubs["get_api_deployment"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/GetApiDeployment", request_serializer=registry_service.GetApiDeploymentRequest.serialize, response_deserializer=registry_models.ApiDeployment.deserialize, @@ -867,7 +953,7 @@ def create_api_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_api_deployment" not in self._stubs: - self._stubs["create_api_deployment"] = self.grpc_channel.unary_unary( + self._stubs["create_api_deployment"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/CreateApiDeployment", request_serializer=registry_service.CreateApiDeploymentRequest.serialize, response_deserializer=registry_models.ApiDeployment.deserialize, @@ -895,7 +981,7 @@ def update_api_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_api_deployment" not in self._stubs: - self._stubs["update_api_deployment"] = self.grpc_channel.unary_unary( + self._stubs["update_api_deployment"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/UpdateApiDeployment", request_serializer=registry_service.UpdateApiDeploymentRequest.serialize, response_deserializer=registry_models.ApiDeployment.deserialize, @@ -922,7 +1008,7 @@ def delete_api_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_api_deployment" not in self._stubs: - self._stubs["delete_api_deployment"] = self.grpc_channel.unary_unary( + self._stubs["delete_api_deployment"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/DeleteApiDeployment", request_serializer=registry_service.DeleteApiDeploymentRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -952,7 +1038,9 @@ def tag_api_deployment_revision( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "tag_api_deployment_revision" not in self._stubs: - self._stubs["tag_api_deployment_revision"] = self.grpc_channel.unary_unary( + self._stubs[ + "tag_api_deployment_revision" + ] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/TagApiDeploymentRevision", request_serializer=registry_service.TagApiDeploymentRevisionRequest.serialize, response_deserializer=registry_models.ApiDeployment.deserialize, @@ -985,7 +1073,7 @@ def list_api_deployment_revisions( if "list_api_deployment_revisions" not in self._stubs: self._stubs[ "list_api_deployment_revisions" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/ListApiDeploymentRevisions", request_serializer=registry_service.ListApiDeploymentRevisionsRequest.serialize, response_deserializer=registry_service.ListApiDeploymentRevisionsResponse.deserialize, @@ -1015,7 +1103,7 @@ def rollback_api_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "rollback_api_deployment" not in self._stubs: - self._stubs["rollback_api_deployment"] = self.grpc_channel.unary_unary( + self._stubs["rollback_api_deployment"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/RollbackApiDeployment", request_serializer=registry_service.RollbackApiDeploymentRequest.serialize, response_deserializer=registry_models.ApiDeployment.deserialize, @@ -1046,7 +1134,7 @@ def delete_api_deployment_revision( if "delete_api_deployment_revision" not in self._stubs: self._stubs[ "delete_api_deployment_revision" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/DeleteApiDeploymentRevision", request_serializer=registry_service.DeleteApiDeploymentRevisionRequest.serialize, response_deserializer=registry_models.ApiDeployment.deserialize, @@ -1074,7 +1162,7 @@ def list_artifacts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_artifacts" not in self._stubs: - self._stubs["list_artifacts"] = self.grpc_channel.unary_unary( + self._stubs["list_artifacts"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/ListArtifacts", request_serializer=registry_service.ListArtifactsRequest.serialize, response_deserializer=registry_service.ListArtifactsResponse.deserialize, @@ -1100,7 +1188,7 @@ def get_artifact( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_artifact" not in self._stubs: - self._stubs["get_artifact"] = self.grpc_channel.unary_unary( + self._stubs["get_artifact"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/GetArtifact", request_serializer=registry_service.GetArtifactRequest.serialize, response_deserializer=registry_models.Artifact.deserialize, @@ -1129,7 +1217,7 @@ def get_artifact_contents( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_artifact_contents" not in self._stubs: - self._stubs["get_artifact_contents"] = self.grpc_channel.unary_unary( + self._stubs["get_artifact_contents"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/GetArtifactContents", request_serializer=registry_service.GetArtifactContentsRequest.serialize, response_deserializer=httpbody_pb2.HttpBody.FromString, @@ -1155,7 +1243,7 @@ def create_artifact( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_artifact" not in self._stubs: - self._stubs["create_artifact"] = self.grpc_channel.unary_unary( + self._stubs["create_artifact"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/CreateArtifact", request_serializer=registry_service.CreateArtifactRequest.serialize, response_deserializer=registry_models.Artifact.deserialize, @@ -1181,7 +1269,7 @@ def replace_artifact( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "replace_artifact" not in self._stubs: - self._stubs["replace_artifact"] = self.grpc_channel.unary_unary( + self._stubs["replace_artifact"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/ReplaceArtifact", request_serializer=registry_service.ReplaceArtifactRequest.serialize, response_deserializer=registry_models.Artifact.deserialize, @@ -1207,7 +1295,7 @@ def delete_artifact( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_artifact" not in self._stubs: - self._stubs["delete_artifact"] = self.grpc_channel.unary_unary( + self._stubs["delete_artifact"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/DeleteArtifact", request_serializer=registry_service.DeleteArtifactRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1215,7 +1303,7 @@ def delete_artifact( return self._stubs["delete_artifact"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -1227,7 +1315,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, @@ -1244,7 +1332,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, @@ -1261,7 +1349,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, @@ -1280,7 +1368,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, @@ -1299,7 +1387,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, @@ -1316,7 +1404,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, @@ -1341,7 +1429,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, @@ -1367,7 +1455,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, @@ -1396,7 +1484,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-apigee-registry/google/cloud/apigee_registry_v1/services/registry/transports/grpc_asyncio.py b/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/registry/transports/grpc_asyncio.py index bf9ee790d6ac..f1650f5f0ce9 100644 --- a/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/registry/transports/grpc_asyncio.py +++ b/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/registry/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 @@ -28,14 +31,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.apigee_registry_v1.types import registry_models, registry_service from .base import DEFAULT_CLIENT_INFO, RegistryTransport from .grpc import RegistryGrpcTransport +try: + from google.api_core import client_logging # 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.apigeeregistry.v1.Registry", + "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.apigeeregistry.v1.Registry", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class RegistryGrpcAsyncIOTransport(RegistryTransport): """gRPC AsyncIO backend transport for Registry. @@ -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 @@ -270,7 +355,7 @@ def list_apis( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_apis" not in self._stubs: - self._stubs["list_apis"] = self.grpc_channel.unary_unary( + self._stubs["list_apis"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/ListApis", request_serializer=registry_service.ListApisRequest.serialize, response_deserializer=registry_service.ListApisResponse.deserialize, @@ -296,7 +381,7 @@ def get_api( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_api" not in self._stubs: - self._stubs["get_api"] = self.grpc_channel.unary_unary( + self._stubs["get_api"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/GetApi", request_serializer=registry_service.GetApiRequest.serialize, response_deserializer=registry_models.Api.deserialize, @@ -322,7 +407,7 @@ def create_api( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_api" not in self._stubs: - self._stubs["create_api"] = self.grpc_channel.unary_unary( + self._stubs["create_api"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/CreateApi", request_serializer=registry_service.CreateApiRequest.serialize, response_deserializer=registry_models.Api.deserialize, @@ -348,7 +433,7 @@ def update_api( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_api" not in self._stubs: - self._stubs["update_api"] = self.grpc_channel.unary_unary( + self._stubs["update_api"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/UpdateApi", request_serializer=registry_service.UpdateApiRequest.serialize, response_deserializer=registry_models.Api.deserialize, @@ -375,7 +460,7 @@ def delete_api( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_api" not in self._stubs: - self._stubs["delete_api"] = self.grpc_channel.unary_unary( + self._stubs["delete_api"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/DeleteApi", request_serializer=registry_service.DeleteApiRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -404,7 +489,7 @@ def list_api_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_api_versions" not in self._stubs: - self._stubs["list_api_versions"] = self.grpc_channel.unary_unary( + self._stubs["list_api_versions"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/ListApiVersions", request_serializer=registry_service.ListApiVersionsRequest.serialize, response_deserializer=registry_service.ListApiVersionsResponse.deserialize, @@ -432,7 +517,7 @@ def get_api_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_api_version" not in self._stubs: - self._stubs["get_api_version"] = self.grpc_channel.unary_unary( + self._stubs["get_api_version"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/GetApiVersion", request_serializer=registry_service.GetApiVersionRequest.serialize, response_deserializer=registry_models.ApiVersion.deserialize, @@ -461,7 +546,7 @@ def create_api_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_api_version" not in self._stubs: - self._stubs["create_api_version"] = self.grpc_channel.unary_unary( + self._stubs["create_api_version"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/CreateApiVersion", request_serializer=registry_service.CreateApiVersionRequest.serialize, response_deserializer=registry_models.ApiVersion.deserialize, @@ -490,7 +575,7 @@ def update_api_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_api_version" not in self._stubs: - self._stubs["update_api_version"] = self.grpc_channel.unary_unary( + self._stubs["update_api_version"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/UpdateApiVersion", request_serializer=registry_service.UpdateApiVersionRequest.serialize, response_deserializer=registry_models.ApiVersion.deserialize, @@ -519,7 +604,7 @@ def delete_api_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_api_version" not in self._stubs: - self._stubs["delete_api_version"] = self.grpc_channel.unary_unary( + self._stubs["delete_api_version"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/DeleteApiVersion", request_serializer=registry_service.DeleteApiVersionRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -548,7 +633,7 @@ def list_api_specs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_api_specs" not in self._stubs: - self._stubs["list_api_specs"] = self.grpc_channel.unary_unary( + self._stubs["list_api_specs"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/ListApiSpecs", request_serializer=registry_service.ListApiSpecsRequest.serialize, response_deserializer=registry_service.ListApiSpecsResponse.deserialize, @@ -576,7 +661,7 @@ def get_api_spec( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_api_spec" not in self._stubs: - self._stubs["get_api_spec"] = self.grpc_channel.unary_unary( + self._stubs["get_api_spec"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/GetApiSpec", request_serializer=registry_service.GetApiSpecRequest.serialize, response_deserializer=registry_models.ApiSpec.deserialize, @@ -607,7 +692,7 @@ def get_api_spec_contents( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_api_spec_contents" not in self._stubs: - self._stubs["get_api_spec_contents"] = self.grpc_channel.unary_unary( + self._stubs["get_api_spec_contents"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/GetApiSpecContents", request_serializer=registry_service.GetApiSpecContentsRequest.serialize, response_deserializer=httpbody_pb2.HttpBody.FromString, @@ -635,7 +720,7 @@ def create_api_spec( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_api_spec" not in self._stubs: - self._stubs["create_api_spec"] = self.grpc_channel.unary_unary( + self._stubs["create_api_spec"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/CreateApiSpec", request_serializer=registry_service.CreateApiSpecRequest.serialize, response_deserializer=registry_models.ApiSpec.deserialize, @@ -663,7 +748,7 @@ def update_api_spec( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_api_spec" not in self._stubs: - self._stubs["update_api_spec"] = self.grpc_channel.unary_unary( + self._stubs["update_api_spec"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/UpdateApiSpec", request_serializer=registry_service.UpdateApiSpecRequest.serialize, response_deserializer=registry_models.ApiSpec.deserialize, @@ -690,7 +775,7 @@ def delete_api_spec( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_api_spec" not in self._stubs: - self._stubs["delete_api_spec"] = self.grpc_channel.unary_unary( + self._stubs["delete_api_spec"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/DeleteApiSpec", request_serializer=registry_service.DeleteApiSpecRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -718,7 +803,7 @@ def tag_api_spec_revision( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "tag_api_spec_revision" not in self._stubs: - self._stubs["tag_api_spec_revision"] = self.grpc_channel.unary_unary( + self._stubs["tag_api_spec_revision"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/TagApiSpecRevision", request_serializer=registry_service.TagApiSpecRevisionRequest.serialize, response_deserializer=registry_models.ApiSpec.deserialize, @@ -749,7 +834,7 @@ def list_api_spec_revisions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_api_spec_revisions" not in self._stubs: - self._stubs["list_api_spec_revisions"] = self.grpc_channel.unary_unary( + self._stubs["list_api_spec_revisions"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/ListApiSpecRevisions", request_serializer=registry_service.ListApiSpecRevisionsRequest.serialize, response_deserializer=registry_service.ListApiSpecRevisionsResponse.deserialize, @@ -779,7 +864,7 @@ def rollback_api_spec( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "rollback_api_spec" not in self._stubs: - self._stubs["rollback_api_spec"] = self.grpc_channel.unary_unary( + self._stubs["rollback_api_spec"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/RollbackApiSpec", request_serializer=registry_service.RollbackApiSpecRequest.serialize, response_deserializer=registry_models.ApiSpec.deserialize, @@ -808,7 +893,7 @@ def delete_api_spec_revision( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_api_spec_revision" not in self._stubs: - self._stubs["delete_api_spec_revision"] = self.grpc_channel.unary_unary( + self._stubs["delete_api_spec_revision"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/DeleteApiSpecRevision", request_serializer=registry_service.DeleteApiSpecRevisionRequest.serialize, response_deserializer=registry_models.ApiSpec.deserialize, @@ -837,7 +922,7 @@ def list_api_deployments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_api_deployments" not in self._stubs: - self._stubs["list_api_deployments"] = self.grpc_channel.unary_unary( + self._stubs["list_api_deployments"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/ListApiDeployments", request_serializer=registry_service.ListApiDeploymentsRequest.serialize, response_deserializer=registry_service.ListApiDeploymentsResponse.deserialize, @@ -866,7 +951,7 @@ def get_api_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_api_deployment" not in self._stubs: - self._stubs["get_api_deployment"] = self.grpc_channel.unary_unary( + self._stubs["get_api_deployment"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/GetApiDeployment", request_serializer=registry_service.GetApiDeploymentRequest.serialize, response_deserializer=registry_models.ApiDeployment.deserialize, @@ -895,7 +980,7 @@ def create_api_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_api_deployment" not in self._stubs: - self._stubs["create_api_deployment"] = self.grpc_channel.unary_unary( + self._stubs["create_api_deployment"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/CreateApiDeployment", request_serializer=registry_service.CreateApiDeploymentRequest.serialize, response_deserializer=registry_models.ApiDeployment.deserialize, @@ -924,7 +1009,7 @@ def update_api_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_api_deployment" not in self._stubs: - self._stubs["update_api_deployment"] = self.grpc_channel.unary_unary( + self._stubs["update_api_deployment"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/UpdateApiDeployment", request_serializer=registry_service.UpdateApiDeploymentRequest.serialize, response_deserializer=registry_models.ApiDeployment.deserialize, @@ -953,7 +1038,7 @@ def delete_api_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_api_deployment" not in self._stubs: - self._stubs["delete_api_deployment"] = self.grpc_channel.unary_unary( + self._stubs["delete_api_deployment"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/DeleteApiDeployment", request_serializer=registry_service.DeleteApiDeploymentRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -983,7 +1068,9 @@ def tag_api_deployment_revision( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "tag_api_deployment_revision" not in self._stubs: - self._stubs["tag_api_deployment_revision"] = self.grpc_channel.unary_unary( + self._stubs[ + "tag_api_deployment_revision" + ] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/TagApiDeploymentRevision", request_serializer=registry_service.TagApiDeploymentRevisionRequest.serialize, response_deserializer=registry_models.ApiDeployment.deserialize, @@ -1016,7 +1103,7 @@ def list_api_deployment_revisions( if "list_api_deployment_revisions" not in self._stubs: self._stubs[ "list_api_deployment_revisions" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/ListApiDeploymentRevisions", request_serializer=registry_service.ListApiDeploymentRevisionsRequest.serialize, response_deserializer=registry_service.ListApiDeploymentRevisionsResponse.deserialize, @@ -1047,7 +1134,7 @@ def rollback_api_deployment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "rollback_api_deployment" not in self._stubs: - self._stubs["rollback_api_deployment"] = self.grpc_channel.unary_unary( + self._stubs["rollback_api_deployment"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/RollbackApiDeployment", request_serializer=registry_service.RollbackApiDeploymentRequest.serialize, response_deserializer=registry_models.ApiDeployment.deserialize, @@ -1078,7 +1165,7 @@ def delete_api_deployment_revision( if "delete_api_deployment_revision" not in self._stubs: self._stubs[ "delete_api_deployment_revision" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/DeleteApiDeploymentRevision", request_serializer=registry_service.DeleteApiDeploymentRevisionRequest.serialize, response_deserializer=registry_models.ApiDeployment.deserialize, @@ -1107,7 +1194,7 @@ def list_artifacts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_artifacts" not in self._stubs: - self._stubs["list_artifacts"] = self.grpc_channel.unary_unary( + self._stubs["list_artifacts"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/ListArtifacts", request_serializer=registry_service.ListArtifactsRequest.serialize, response_deserializer=registry_service.ListArtifactsResponse.deserialize, @@ -1135,7 +1222,7 @@ def get_artifact( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_artifact" not in self._stubs: - self._stubs["get_artifact"] = self.grpc_channel.unary_unary( + self._stubs["get_artifact"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/GetArtifact", request_serializer=registry_service.GetArtifactRequest.serialize, response_deserializer=registry_models.Artifact.deserialize, @@ -1166,7 +1253,7 @@ def get_artifact_contents( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_artifact_contents" not in self._stubs: - self._stubs["get_artifact_contents"] = self.grpc_channel.unary_unary( + self._stubs["get_artifact_contents"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/GetArtifactContents", request_serializer=registry_service.GetArtifactContentsRequest.serialize, response_deserializer=httpbody_pb2.HttpBody.FromString, @@ -1194,7 +1281,7 @@ def create_artifact( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_artifact" not in self._stubs: - self._stubs["create_artifact"] = self.grpc_channel.unary_unary( + self._stubs["create_artifact"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/CreateArtifact", request_serializer=registry_service.CreateArtifactRequest.serialize, response_deserializer=registry_models.Artifact.deserialize, @@ -1222,7 +1309,7 @@ def replace_artifact( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "replace_artifact" not in self._stubs: - self._stubs["replace_artifact"] = self.grpc_channel.unary_unary( + self._stubs["replace_artifact"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/ReplaceArtifact", request_serializer=registry_service.ReplaceArtifactRequest.serialize, response_deserializer=registry_models.Artifact.deserialize, @@ -1248,7 +1335,7 @@ def delete_artifact( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_artifact" not in self._stubs: - self._stubs["delete_artifact"] = self.grpc_channel.unary_unary( + self._stubs["delete_artifact"] = self._logged_channel.unary_unary( "/google.cloud.apigeeregistry.v1.Registry/DeleteArtifact", request_serializer=registry_service.DeleteArtifactRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1882,7 +1969,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: @@ -1898,7 +1985,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, @@ -1915,7 +2002,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, @@ -1932,7 +2019,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, @@ -1951,7 +2038,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, @@ -1970,7 +2057,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, @@ -1987,7 +2074,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, @@ -2012,7 +2099,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, @@ -2038,7 +2125,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, @@ -2067,7 +2154,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-apigee-registry/google/cloud/apigee_registry_v1/services/registry/transports/rest.py b/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/registry/transports/rest.py index 0e6808cd69fa..5a42b2c8b1a9 100644 --- a/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/registry/transports/rest.py +++ b/packages/google-cloud-apigee-registry/google/cloud/apigee_registry_v1/services/registry/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, @@ -335,8 +343,10 @@ def post_update_api_version(self, response): def pre_create_api( self, request: registry_service.CreateApiRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registry_service.CreateApiRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registry_service.CreateApiRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_api Override in a subclass to manipulate the request or metadata @@ -356,8 +366,11 @@ def post_create_api(self, response: registry_models.Api) -> registry_models.Api: def pre_create_api_deployment( self, request: registry_service.CreateApiDeploymentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registry_service.CreateApiDeploymentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registry_service.CreateApiDeploymentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_api_deployment Override in a subclass to manipulate the request or metadata @@ -379,8 +392,10 @@ def post_create_api_deployment( def pre_create_api_spec( self, request: registry_service.CreateApiSpecRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registry_service.CreateApiSpecRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registry_service.CreateApiSpecRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_api_spec Override in a subclass to manipulate the request or metadata @@ -402,8 +417,11 @@ def post_create_api_spec( def pre_create_api_version( self, request: registry_service.CreateApiVersionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registry_service.CreateApiVersionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registry_service.CreateApiVersionRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_api_version Override in a subclass to manipulate the request or metadata @@ -425,8 +443,10 @@ def post_create_api_version( def pre_create_artifact( self, request: registry_service.CreateArtifactRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registry_service.CreateArtifactRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registry_service.CreateArtifactRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_artifact Override in a subclass to manipulate the request or metadata @@ -448,8 +468,10 @@ def post_create_artifact( def pre_delete_api( self, request: registry_service.DeleteApiRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registry_service.DeleteApiRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registry_service.DeleteApiRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_api Override in a subclass to manipulate the request or metadata @@ -460,8 +482,11 @@ def pre_delete_api( def pre_delete_api_deployment( self, request: registry_service.DeleteApiDeploymentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registry_service.DeleteApiDeploymentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registry_service.DeleteApiDeploymentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_api_deployment Override in a subclass to manipulate the request or metadata @@ -472,9 +497,10 @@ def pre_delete_api_deployment( def pre_delete_api_deployment_revision( self, request: registry_service.DeleteApiDeploymentRevisionRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - registry_service.DeleteApiDeploymentRevisionRequest, Sequence[Tuple[str, str]] + registry_service.DeleteApiDeploymentRevisionRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_api_deployment_revision @@ -497,8 +523,10 @@ def post_delete_api_deployment_revision( def pre_delete_api_spec( self, request: registry_service.DeleteApiSpecRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registry_service.DeleteApiSpecRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registry_service.DeleteApiSpecRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_api_spec Override in a subclass to manipulate the request or metadata @@ -509,9 +537,10 @@ def pre_delete_api_spec( def pre_delete_api_spec_revision( self, request: registry_service.DeleteApiSpecRevisionRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - registry_service.DeleteApiSpecRevisionRequest, Sequence[Tuple[str, str]] + registry_service.DeleteApiSpecRevisionRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_api_spec_revision @@ -534,8 +563,11 @@ def post_delete_api_spec_revision( def pre_delete_api_version( self, request: registry_service.DeleteApiVersionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registry_service.DeleteApiVersionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registry_service.DeleteApiVersionRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_api_version Override in a subclass to manipulate the request or metadata @@ -546,8 +578,10 @@ def pre_delete_api_version( def pre_delete_artifact( self, request: registry_service.DeleteArtifactRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registry_service.DeleteArtifactRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registry_service.DeleteArtifactRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_artifact Override in a subclass to manipulate the request or metadata @@ -558,8 +592,8 @@ def pre_delete_artifact( def pre_get_api( self, request: registry_service.GetApiRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registry_service.GetApiRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[registry_service.GetApiRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_api Override in a subclass to manipulate the request or metadata @@ -579,8 +613,11 @@ def post_get_api(self, response: registry_models.Api) -> registry_models.Api: def pre_get_api_deployment( self, request: registry_service.GetApiDeploymentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registry_service.GetApiDeploymentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registry_service.GetApiDeploymentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_api_deployment Override in a subclass to manipulate the request or metadata @@ -602,8 +639,10 @@ def post_get_api_deployment( def pre_get_api_spec( self, request: registry_service.GetApiSpecRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registry_service.GetApiSpecRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registry_service.GetApiSpecRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_api_spec Override in a subclass to manipulate the request or metadata @@ -625,8 +664,11 @@ def post_get_api_spec( def pre_get_api_spec_contents( self, request: registry_service.GetApiSpecContentsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registry_service.GetApiSpecContentsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registry_service.GetApiSpecContentsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_api_spec_contents Override in a subclass to manipulate the request or metadata @@ -648,8 +690,10 @@ def post_get_api_spec_contents( def pre_get_api_version( self, request: registry_service.GetApiVersionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registry_service.GetApiVersionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registry_service.GetApiVersionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_api_version Override in a subclass to manipulate the request or metadata @@ -671,8 +715,10 @@ def post_get_api_version( def pre_get_artifact( self, request: registry_service.GetArtifactRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registry_service.GetArtifactRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registry_service.GetArtifactRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_artifact Override in a subclass to manipulate the request or metadata @@ -694,8 +740,11 @@ def post_get_artifact( def pre_get_artifact_contents( self, request: registry_service.GetArtifactContentsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registry_service.GetArtifactContentsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registry_service.GetArtifactContentsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_artifact_contents Override in a subclass to manipulate the request or metadata @@ -717,9 +766,10 @@ def post_get_artifact_contents( def pre_list_api_deployment_revisions( self, request: registry_service.ListApiDeploymentRevisionsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - registry_service.ListApiDeploymentRevisionsRequest, Sequence[Tuple[str, str]] + registry_service.ListApiDeploymentRevisionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_api_deployment_revisions @@ -742,8 +792,11 @@ def post_list_api_deployment_revisions( def pre_list_api_deployments( self, request: registry_service.ListApiDeploymentsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registry_service.ListApiDeploymentsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registry_service.ListApiDeploymentsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_api_deployments Override in a subclass to manipulate the request or metadata @@ -765,8 +818,10 @@ def post_list_api_deployments( def pre_list_apis( self, request: registry_service.ListApisRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registry_service.ListApisRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registry_service.ListApisRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_apis Override in a subclass to manipulate the request or metadata @@ -788,8 +843,11 @@ def post_list_apis( def pre_list_api_spec_revisions( self, request: registry_service.ListApiSpecRevisionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registry_service.ListApiSpecRevisionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registry_service.ListApiSpecRevisionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_api_spec_revisions Override in a subclass to manipulate the request or metadata @@ -811,8 +869,10 @@ def post_list_api_spec_revisions( def pre_list_api_specs( self, request: registry_service.ListApiSpecsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registry_service.ListApiSpecsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registry_service.ListApiSpecsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_api_specs Override in a subclass to manipulate the request or metadata @@ -834,8 +894,10 @@ def post_list_api_specs( def pre_list_api_versions( self, request: registry_service.ListApiVersionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registry_service.ListApiVersionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registry_service.ListApiVersionsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_api_versions Override in a subclass to manipulate the request or metadata @@ -857,8 +919,10 @@ def post_list_api_versions( def pre_list_artifacts( self, request: registry_service.ListArtifactsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registry_service.ListArtifactsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registry_service.ListArtifactsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_artifacts Override in a subclass to manipulate the request or metadata @@ -880,8 +944,10 @@ def post_list_artifacts( def pre_replace_artifact( self, request: registry_service.ReplaceArtifactRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registry_service.ReplaceArtifactRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registry_service.ReplaceArtifactRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for replace_artifact Override in a subclass to manipulate the request or metadata @@ -903,9 +969,10 @@ def post_replace_artifact( def pre_rollback_api_deployment( self, request: registry_service.RollbackApiDeploymentRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - registry_service.RollbackApiDeploymentRequest, Sequence[Tuple[str, str]] + registry_service.RollbackApiDeploymentRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for rollback_api_deployment @@ -928,8 +995,10 @@ def post_rollback_api_deployment( def pre_rollback_api_spec( self, request: registry_service.RollbackApiSpecRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registry_service.RollbackApiSpecRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registry_service.RollbackApiSpecRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for rollback_api_spec Override in a subclass to manipulate the request or metadata @@ -951,9 +1020,10 @@ def post_rollback_api_spec( def pre_tag_api_deployment_revision( self, request: registry_service.TagApiDeploymentRevisionRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - registry_service.TagApiDeploymentRevisionRequest, Sequence[Tuple[str, str]] + registry_service.TagApiDeploymentRevisionRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for tag_api_deployment_revision @@ -976,8 +1046,11 @@ def post_tag_api_deployment_revision( def pre_tag_api_spec_revision( self, request: registry_service.TagApiSpecRevisionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registry_service.TagApiSpecRevisionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registry_service.TagApiSpecRevisionRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for tag_api_spec_revision Override in a subclass to manipulate the request or metadata @@ -999,8 +1072,10 @@ def post_tag_api_spec_revision( def pre_update_api( self, request: registry_service.UpdateApiRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registry_service.UpdateApiRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registry_service.UpdateApiRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_api Override in a subclass to manipulate the request or metadata @@ -1020,8 +1095,11 @@ def post_update_api(self, response: registry_models.Api) -> registry_models.Api: def pre_update_api_deployment( self, request: registry_service.UpdateApiDeploymentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registry_service.UpdateApiDeploymentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registry_service.UpdateApiDeploymentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_api_deployment Override in a subclass to manipulate the request or metadata @@ -1043,8 +1121,10 @@ def post_update_api_deployment( def pre_update_api_spec( self, request: registry_service.UpdateApiSpecRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registry_service.UpdateApiSpecRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registry_service.UpdateApiSpecRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_api_spec Override in a subclass to manipulate the request or metadata @@ -1066,8 +1146,11 @@ def post_update_api_spec( def pre_update_api_version( self, request: registry_service.UpdateApiVersionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[registry_service.UpdateApiVersionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + registry_service.UpdateApiVersionRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_api_version Override in a subclass to manipulate the request or metadata @@ -1089,8 +1172,10 @@ def post_update_api_version( 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 @@ -1112,8 +1197,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 @@ -1135,8 +1222,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 @@ -1156,8 +1245,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 @@ -1177,8 +1268,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 @@ -1200,8 +1294,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 @@ -1221,8 +1317,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 @@ -1242,8 +1340,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 @@ -1265,8 +1365,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 @@ -1406,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]]] = (), ) -> registry_models.Api: r"""Call the create api method over HTTP. @@ -1416,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: ~.registry_models.Api: @@ -1428,6 +1532,7 @@ def __call__( """ http_options = _BaseRegistryRestTransport._BaseCreateApi._get_http_options() + request, metadata = self._interceptor.pre_create_api(request, metadata) transcoded_request = ( _BaseRegistryRestTransport._BaseCreateApi._get_transcoded_request( @@ -1446,6 +1551,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.CreateApi", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "CreateApi", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._CreateApi._get_response( self._host, @@ -1467,7 +1599,29 @@ def __call__( pb_resp = registry_models.Api.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_api(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = registry_models.Api.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigeeregistry_v1.RegistryClient.create_api", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "CreateApi", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateApiDeployment( @@ -1505,7 +1659,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.ApiDeployment: r"""Call the create api deployment method over HTTP. @@ -1516,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: ~.registry_models.ApiDeployment: @@ -1536,6 +1692,7 @@ def __call__( http_options = ( _BaseRegistryRestTransport._BaseCreateApiDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_create_api_deployment( request, metadata ) @@ -1552,6 +1709,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.CreateApiDeployment", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "CreateApiDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._CreateApiDeployment._get_response( self._host, @@ -1573,7 +1757,29 @@ def __call__( pb_resp = registry_models.ApiDeployment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_api_deployment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = registry_models.ApiDeployment.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigeeregistry_v1.RegistryClient.create_api_deployment", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "CreateApiDeployment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateApiSpec( @@ -1611,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]]] = (), ) -> registry_models.ApiSpec: r"""Call the create api spec method over HTTP. @@ -1621,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: ~.registry_models.ApiSpec: @@ -1646,6 +1854,7 @@ def __call__( http_options = ( _BaseRegistryRestTransport._BaseCreateApiSpec._get_http_options() ) + request, metadata = self._interceptor.pre_create_api_spec(request, metadata) transcoded_request = ( _BaseRegistryRestTransport._BaseCreateApiSpec._get_transcoded_request( @@ -1664,6 +1873,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.CreateApiSpec", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "CreateApiSpec", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._CreateApiSpec._get_response( self._host, @@ -1685,7 +1921,29 @@ def __call__( pb_resp = registry_models.ApiSpec.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_api_spec(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = registry_models.ApiSpec.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigeeregistry_v1.RegistryClient.create_api_spec", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "CreateApiSpec", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateApiVersion( @@ -1723,7 +1981,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.ApiVersion: r"""Call the create api version method over HTTP. @@ -1733,8 +1991,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.registry_models.ApiVersion: @@ -1747,6 +2007,7 @@ def __call__( http_options = ( _BaseRegistryRestTransport._BaseCreateApiVersion._get_http_options() ) + request, metadata = self._interceptor.pre_create_api_version( request, metadata ) @@ -1767,6 +2028,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.CreateApiVersion", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "CreateApiVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._CreateApiVersion._get_response( self._host, @@ -1788,7 +2076,29 @@ def __call__( pb_resp = registry_models.ApiVersion.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_api_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = registry_models.ApiVersion.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigeeregistry_v1.RegistryClient.create_api_version", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "CreateApiVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateArtifact( @@ -1826,7 +2136,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.Artifact: r"""Call the create artifact method over HTTP. @@ -1836,8 +2146,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.registry_models.Artifact: @@ -1858,6 +2170,7 @@ def __call__( http_options = ( _BaseRegistryRestTransport._BaseCreateArtifact._get_http_options() ) + request, metadata = self._interceptor.pre_create_artifact(request, metadata) transcoded_request = ( _BaseRegistryRestTransport._BaseCreateArtifact._get_transcoded_request( @@ -1878,6 +2191,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.CreateArtifact", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "CreateArtifact", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._CreateArtifact._get_response( self._host, @@ -1899,7 +2239,29 @@ def __call__( pb_resp = registry_models.Artifact.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_artifact(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = registry_models.Artifact.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigeeregistry_v1.RegistryClient.create_artifact", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "CreateArtifact", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteApi(_BaseRegistryRestTransport._BaseDeleteApi, RegistryRestStub): @@ -1934,7 +2296,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete api method over HTTP. @@ -1944,11 +2306,14 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = _BaseRegistryRestTransport._BaseDeleteApi._get_http_options() + request, metadata = self._interceptor.pre_delete_api(request, metadata) transcoded_request = ( _BaseRegistryRestTransport._BaseDeleteApi._get_transcoded_request( @@ -1963,6 +2328,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.DeleteApi", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "DeleteApi", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._DeleteApi._get_response( self._host, @@ -2012,7 +2404,7 @@ 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 api deployment method over HTTP. @@ -2023,13 +2415,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 = ( _BaseRegistryRestTransport._BaseDeleteApiDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_delete_api_deployment( request, metadata ) @@ -2042,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 = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.DeleteApiDeployment", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "DeleteApiDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._DeleteApiDeployment._get_response( self._host, @@ -2091,7 +2513,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.ApiDeployment: r"""Call the delete api deployment revision method over HTTP. @@ -2103,8 +2525,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.registry_models.ApiDeployment: @@ -2123,6 +2547,7 @@ def __call__( http_options = ( _BaseRegistryRestTransport._BaseDeleteApiDeploymentRevision._get_http_options() ) + request, metadata = self._interceptor.pre_delete_api_deployment_revision( request, metadata ) @@ -2135,6 +2560,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.DeleteApiDeploymentRevision", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "DeleteApiDeploymentRevision", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._DeleteApiDeploymentRevision._get_response( self._host, @@ -2155,7 +2607,29 @@ def __call__( pb_resp = registry_models.ApiDeployment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_api_deployment_revision(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = registry_models.ApiDeployment.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigeeregistry_v1.RegistryClient.delete_api_deployment_revision", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "DeleteApiDeploymentRevision", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteApiSpec( @@ -2192,7 +2666,7 @@ 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 api spec method over HTTP. @@ -2202,13 +2676,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 = ( _BaseRegistryRestTransport._BaseDeleteApiSpec._get_http_options() ) + request, metadata = self._interceptor.pre_delete_api_spec(request, metadata) transcoded_request = ( _BaseRegistryRestTransport._BaseDeleteApiSpec._get_transcoded_request( @@ -2223,6 +2700,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.DeleteApiSpec", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "DeleteApiSpec", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._DeleteApiSpec._get_response( self._host, @@ -2272,7 +2776,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.ApiSpec: r"""Call the delete api spec revision method over HTTP. @@ -2283,8 +2787,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.registry_models.ApiSpec: @@ -2308,6 +2814,7 @@ def __call__( http_options = ( _BaseRegistryRestTransport._BaseDeleteApiSpecRevision._get_http_options() ) + request, metadata = self._interceptor.pre_delete_api_spec_revision( request, metadata ) @@ -2320,6 +2827,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.DeleteApiSpecRevision", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "DeleteApiSpecRevision", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._DeleteApiSpecRevision._get_response( self._host, @@ -2340,7 +2874,29 @@ def __call__( pb_resp = registry_models.ApiSpec.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_api_spec_revision(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = registry_models.ApiSpec.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigeeregistry_v1.RegistryClient.delete_api_spec_revision", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "DeleteApiSpecRevision", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteApiVersion( @@ -2377,7 +2933,7 @@ 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 api version method over HTTP. @@ -2387,13 +2943,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 = ( _BaseRegistryRestTransport._BaseDeleteApiVersion._get_http_options() ) + request, metadata = self._interceptor.pre_delete_api_version( request, metadata ) @@ -2408,6 +2967,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.DeleteApiVersion", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "DeleteApiVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._DeleteApiVersion._get_response( self._host, @@ -2457,7 +3043,7 @@ 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 artifact method over HTTP. @@ -2467,13 +3053,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 = ( _BaseRegistryRestTransport._BaseDeleteArtifact._get_http_options() ) + request, metadata = self._interceptor.pre_delete_artifact(request, metadata) transcoded_request = ( _BaseRegistryRestTransport._BaseDeleteArtifact._get_transcoded_request( @@ -2488,6 +3077,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.DeleteArtifact", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "DeleteArtifact", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._DeleteArtifact._get_response( self._host, @@ -2535,7 +3151,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.Api: r"""Call the get api method over HTTP. @@ -2545,8 +3161,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.registry_models.Api: @@ -2557,6 +3175,7 @@ def __call__( """ http_options = _BaseRegistryRestTransport._BaseGetApi._get_http_options() + request, metadata = self._interceptor.pre_get_api(request, metadata) transcoded_request = ( _BaseRegistryRestTransport._BaseGetApi._get_transcoded_request( @@ -2571,6 +3190,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.GetApi", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "GetApi", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._GetApi._get_response( self._host, @@ -2591,7 +3237,29 @@ def __call__( pb_resp = registry_models.Api.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_api(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = registry_models.Api.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigeeregistry_v1.RegistryClient.get_api", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "GetApi", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetApiDeployment( @@ -2628,7 +3296,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.ApiDeployment: r"""Call the get api deployment method over HTTP. @@ -2638,8 +3306,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.registry_models.ApiDeployment: @@ -2658,6 +3328,7 @@ def __call__( http_options = ( _BaseRegistryRestTransport._BaseGetApiDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_get_api_deployment( request, metadata ) @@ -2672,6 +3343,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.GetApiDeployment", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "GetApiDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._GetApiDeployment._get_response( self._host, @@ -2692,7 +3390,29 @@ def __call__( pb_resp = registry_models.ApiDeployment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_api_deployment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = registry_models.ApiDeployment.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigeeregistry_v1.RegistryClient.get_api_deployment", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "GetApiDeployment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetApiSpec(_BaseRegistryRestTransport._BaseGetApiSpec, RegistryRestStub): @@ -2727,7 +3447,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.ApiSpec: r"""Call the get api spec method over HTTP. @@ -2737,8 +3457,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.registry_models.ApiSpec: @@ -2762,6 +3484,7 @@ def __call__( http_options = ( _BaseRegistryRestTransport._BaseGetApiSpec._get_http_options() ) + request, metadata = self._interceptor.pre_get_api_spec(request, metadata) transcoded_request = ( _BaseRegistryRestTransport._BaseGetApiSpec._get_transcoded_request( @@ -2776,6 +3499,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.GetApiSpec", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "GetApiSpec", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._GetApiSpec._get_response( self._host, @@ -2796,7 +3546,29 @@ def __call__( pb_resp = registry_models.ApiSpec.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_api_spec(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = registry_models.ApiSpec.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigeeregistry_v1.RegistryClient.get_api_spec", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "GetApiSpec", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetApiSpecContents( @@ -2833,7 +3605,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> httpbody_pb2.HttpBody: r"""Call the get api spec contents method over HTTP. @@ -2844,8 +3616,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.httpbody_pb2.HttpBody: @@ -2904,6 +3678,7 @@ def __call__( http_options = ( _BaseRegistryRestTransport._BaseGetApiSpecContents._get_http_options() ) + request, metadata = self._interceptor.pre_get_api_spec_contents( request, metadata ) @@ -2916,6 +3691,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.GetApiSpecContents", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "GetApiSpecContents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._GetApiSpecContents._get_response( self._host, @@ -2936,7 +3738,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_api_spec_contents(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigeeregistry_v1.RegistryClient.get_api_spec_contents", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "GetApiSpecContents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetApiVersion( @@ -2973,7 +3797,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.ApiVersion: r"""Call the get api version method over HTTP. @@ -2983,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: ~.registry_models.ApiVersion: @@ -2997,6 +3823,7 @@ def __call__( http_options = ( _BaseRegistryRestTransport._BaseGetApiVersion._get_http_options() ) + request, metadata = self._interceptor.pre_get_api_version(request, metadata) transcoded_request = ( _BaseRegistryRestTransport._BaseGetApiVersion._get_transcoded_request( @@ -3011,6 +3838,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.GetApiVersion", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "GetApiVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._GetApiVersion._get_response( self._host, @@ -3031,7 +3885,29 @@ def __call__( pb_resp = registry_models.ApiVersion.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_api_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = registry_models.ApiVersion.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigeeregistry_v1.RegistryClient.get_api_version", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "GetApiVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetArtifact(_BaseRegistryRestTransport._BaseGetArtifact, RegistryRestStub): @@ -3066,7 +3942,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.Artifact: r"""Call the get artifact method over HTTP. @@ -3076,8 +3952,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.registry_models.Artifact: @@ -3098,6 +3976,7 @@ def __call__( http_options = ( _BaseRegistryRestTransport._BaseGetArtifact._get_http_options() ) + request, metadata = self._interceptor.pre_get_artifact(request, metadata) transcoded_request = ( _BaseRegistryRestTransport._BaseGetArtifact._get_transcoded_request( @@ -3112,6 +3991,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.GetArtifact", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "GetArtifact", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._GetArtifact._get_response( self._host, @@ -3132,7 +4038,29 @@ def __call__( pb_resp = registry_models.Artifact.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_artifact(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = registry_models.Artifact.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigeeregistry_v1.RegistryClient.get_artifact", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "GetArtifact", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetArtifactContents( @@ -3169,7 +4097,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> httpbody_pb2.HttpBody: r"""Call the get artifact contents method over HTTP. @@ -3180,8 +4108,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.httpbody_pb2.HttpBody: @@ -3240,6 +4170,7 @@ def __call__( http_options = ( _BaseRegistryRestTransport._BaseGetArtifactContents._get_http_options() ) + request, metadata = self._interceptor.pre_get_artifact_contents( request, metadata ) @@ -3252,6 +4183,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.GetArtifactContents", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "GetArtifactContents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._GetArtifactContents._get_response( self._host, @@ -3272,7 +4230,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_artifact_contents(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigeeregistry_v1.RegistryClient.get_artifact_contents", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "GetArtifactContents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListApiDeploymentRevisions( @@ -3309,7 +4289,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_service.ListApiDeploymentRevisionsResponse: r"""Call the list api deployment revisions method over HTTP. @@ -3321,8 +4301,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.registry_service.ListApiDeploymentRevisionsResponse: @@ -3334,6 +4316,7 @@ def __call__( http_options = ( _BaseRegistryRestTransport._BaseListApiDeploymentRevisions._get_http_options() ) + request, metadata = self._interceptor.pre_list_api_deployment_revisions( request, metadata ) @@ -3346,6 +4329,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.ListApiDeploymentRevisions", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "ListApiDeploymentRevisions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._ListApiDeploymentRevisions._get_response( self._host, @@ -3366,7 +4376,33 @@ def __call__( pb_resp = registry_service.ListApiDeploymentRevisionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_api_deployment_revisions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + registry_service.ListApiDeploymentRevisionsResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigeeregistry_v1.RegistryClient.list_api_deployment_revisions", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "ListApiDeploymentRevisions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListApiDeployments( @@ -3403,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]]] = (), ) -> registry_service.ListApiDeploymentsResponse: r"""Call the list api deployments method over HTTP. @@ -3414,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: ~.registry_service.ListApiDeploymentsResponse: @@ -3427,6 +4465,7 @@ def __call__( http_options = ( _BaseRegistryRestTransport._BaseListApiDeployments._get_http_options() ) + request, metadata = self._interceptor.pre_list_api_deployments( request, metadata ) @@ -3439,6 +4478,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.ListApiDeployments", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "ListApiDeployments", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._ListApiDeployments._get_response( self._host, @@ -3459,7 +4525,31 @@ def __call__( pb_resp = registry_service.ListApiDeploymentsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_api_deployments(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + registry_service.ListApiDeploymentsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigeeregistry_v1.RegistryClient.list_api_deployments", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "ListApiDeployments", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListApis(_BaseRegistryRestTransport._BaseListApis, RegistryRestStub): @@ -3494,7 +4584,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_service.ListApisResponse: r"""Call the list apis method over HTTP. @@ -3504,8 +4594,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.registry_service.ListApisResponse: @@ -3513,6 +4605,7 @@ def __call__( """ http_options = _BaseRegistryRestTransport._BaseListApis._get_http_options() + request, metadata = self._interceptor.pre_list_apis(request, metadata) transcoded_request = ( _BaseRegistryRestTransport._BaseListApis._get_transcoded_request( @@ -3527,6 +4620,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.ListApis", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "ListApis", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._ListApis._get_response( self._host, @@ -3547,7 +4667,31 @@ def __call__( pb_resp = registry_service.ListApisResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_apis(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = registry_service.ListApisResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigeeregistry_v1.RegistryClient.list_apis", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "ListApis", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListApiSpecRevisions( @@ -3584,7 +4728,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_service.ListApiSpecRevisionsResponse: r"""Call the list api spec revisions method over HTTP. @@ -3595,8 +4739,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.registry_service.ListApiSpecRevisionsResponse: @@ -3608,6 +4754,7 @@ def __call__( http_options = ( _BaseRegistryRestTransport._BaseListApiSpecRevisions._get_http_options() ) + request, metadata = self._interceptor.pre_list_api_spec_revisions( request, metadata ) @@ -3620,6 +4767,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.ListApiSpecRevisions", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "ListApiSpecRevisions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._ListApiSpecRevisions._get_response( self._host, @@ -3640,7 +4814,31 @@ def __call__( pb_resp = registry_service.ListApiSpecRevisionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_api_spec_revisions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + registry_service.ListApiSpecRevisionsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigeeregistry_v1.RegistryClient.list_api_spec_revisions", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "ListApiSpecRevisions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListApiSpecs(_BaseRegistryRestTransport._BaseListApiSpecs, RegistryRestStub): @@ -3675,7 +4873,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_service.ListApiSpecsResponse: r"""Call the list api specs method over HTTP. @@ -3685,8 +4883,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.registry_service.ListApiSpecsResponse: @@ -3696,6 +4896,7 @@ def __call__( http_options = ( _BaseRegistryRestTransport._BaseListApiSpecs._get_http_options() ) + request, metadata = self._interceptor.pre_list_api_specs(request, metadata) transcoded_request = ( _BaseRegistryRestTransport._BaseListApiSpecs._get_transcoded_request( @@ -3710,6 +4911,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.ListApiSpecs", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "ListApiSpecs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._ListApiSpecs._get_response( self._host, @@ -3730,7 +4958,31 @@ def __call__( pb_resp = registry_service.ListApiSpecsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_api_specs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = registry_service.ListApiSpecsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigeeregistry_v1.RegistryClient.list_api_specs", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "ListApiSpecs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListApiVersions( @@ -3767,7 +5019,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_service.ListApiVersionsResponse: r"""Call the list api versions method over HTTP. @@ -3777,8 +5029,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.registry_service.ListApiVersionsResponse: @@ -3788,6 +5042,7 @@ def __call__( http_options = ( _BaseRegistryRestTransport._BaseListApiVersions._get_http_options() ) + request, metadata = self._interceptor.pre_list_api_versions( request, metadata ) @@ -3804,6 +5059,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.ListApiVersions", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "ListApiVersions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._ListApiVersions._get_response( self._host, @@ -3824,7 +5106,31 @@ def __call__( pb_resp = registry_service.ListApiVersionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_api_versions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = registry_service.ListApiVersionsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigeeregistry_v1.RegistryClient.list_api_versions", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "ListApiVersions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListArtifacts( @@ -3861,7 +5167,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_service.ListArtifactsResponse: r"""Call the list artifacts method over HTTP. @@ -3871,8 +5177,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.registry_service.ListArtifactsResponse: @@ -3882,6 +5190,7 @@ def __call__( http_options = ( _BaseRegistryRestTransport._BaseListArtifacts._get_http_options() ) + request, metadata = self._interceptor.pre_list_artifacts(request, metadata) transcoded_request = ( _BaseRegistryRestTransport._BaseListArtifacts._get_transcoded_request( @@ -3896,6 +5205,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.ListArtifacts", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "ListArtifacts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._ListArtifacts._get_response( self._host, @@ -3916,7 +5252,31 @@ def __call__( pb_resp = registry_service.ListArtifactsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_artifacts(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = registry_service.ListArtifactsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigeeregistry_v1.RegistryClient.list_artifacts", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "ListArtifacts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ReplaceArtifact( @@ -3954,7 +5314,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.Artifact: r"""Call the replace artifact method over HTTP. @@ -3964,8 +5324,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.registry_models.Artifact: @@ -3986,6 +5348,7 @@ def __call__( http_options = ( _BaseRegistryRestTransport._BaseReplaceArtifact._get_http_options() ) + request, metadata = self._interceptor.pre_replace_artifact( request, metadata ) @@ -4008,6 +5371,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.ReplaceArtifact", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "ReplaceArtifact", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._ReplaceArtifact._get_response( self._host, @@ -4029,7 +5419,29 @@ def __call__( pb_resp = registry_models.Artifact.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_replace_artifact(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = registry_models.Artifact.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigeeregistry_v1.RegistryClient.replace_artifact", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "ReplaceArtifact", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RollbackApiDeployment( @@ -4067,7 +5479,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.ApiDeployment: r"""Call the rollback api deployment method over HTTP. @@ -4078,8 +5490,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.registry_models.ApiDeployment: @@ -4098,6 +5512,7 @@ def __call__( http_options = ( _BaseRegistryRestTransport._BaseRollbackApiDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_rollback_api_deployment( request, metadata ) @@ -4114,6 +5529,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.RollbackApiDeployment", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "RollbackApiDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._RollbackApiDeployment._get_response( self._host, @@ -4135,7 +5577,29 @@ def __call__( pb_resp = registry_models.ApiDeployment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_rollback_api_deployment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = registry_models.ApiDeployment.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigeeregistry_v1.RegistryClient.rollback_api_deployment", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "RollbackApiDeployment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RollbackApiSpec( @@ -4173,7 +5637,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.ApiSpec: r"""Call the rollback api spec method over HTTP. @@ -4183,8 +5647,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.registry_models.ApiSpec: @@ -4208,6 +5674,7 @@ def __call__( http_options = ( _BaseRegistryRestTransport._BaseRollbackApiSpec._get_http_options() ) + request, metadata = self._interceptor.pre_rollback_api_spec( request, metadata ) @@ -4230,6 +5697,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.RollbackApiSpec", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "RollbackApiSpec", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._RollbackApiSpec._get_response( self._host, @@ -4251,7 +5745,29 @@ def __call__( pb_resp = registry_models.ApiSpec.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_rollback_api_spec(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = registry_models.ApiSpec.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigeeregistry_v1.RegistryClient.rollback_api_spec", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "RollbackApiSpec", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TagApiDeploymentRevision( @@ -4289,7 +5805,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.ApiDeployment: r"""Call the tag api deployment revision method over HTTP. @@ -4301,8 +5817,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.registry_models.ApiDeployment: @@ -4321,6 +5839,7 @@ def __call__( http_options = ( _BaseRegistryRestTransport._BaseTagApiDeploymentRevision._get_http_options() ) + request, metadata = self._interceptor.pre_tag_api_deployment_revision( request, metadata ) @@ -4337,6 +5856,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.TagApiDeploymentRevision", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "TagApiDeploymentRevision", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._TagApiDeploymentRevision._get_response( self._host, @@ -4358,7 +5904,29 @@ def __call__( pb_resp = registry_models.ApiDeployment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_tag_api_deployment_revision(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = registry_models.ApiDeployment.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigeeregistry_v1.RegistryClient.tag_api_deployment_revision", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "TagApiDeploymentRevision", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TagApiSpecRevision( @@ -4396,7 +5964,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.ApiSpec: r"""Call the tag api spec revision method over HTTP. @@ -4407,8 +5975,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.registry_models.ApiSpec: @@ -4432,6 +6002,7 @@ def __call__( http_options = ( _BaseRegistryRestTransport._BaseTagApiSpecRevision._get_http_options() ) + request, metadata = self._interceptor.pre_tag_api_spec_revision( request, metadata ) @@ -4448,6 +6019,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.TagApiSpecRevision", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "TagApiSpecRevision", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._TagApiSpecRevision._get_response( self._host, @@ -4469,7 +6067,29 @@ def __call__( pb_resp = registry_models.ApiSpec.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_tag_api_spec_revision(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = registry_models.ApiSpec.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigeeregistry_v1.RegistryClient.tag_api_spec_revision", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "TagApiSpecRevision", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateApi(_BaseRegistryRestTransport._BaseUpdateApi, RegistryRestStub): @@ -4505,7 +6125,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.Api: r"""Call the update api method over HTTP. @@ -4515,8 +6135,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.registry_models.Api: @@ -4527,6 +6149,7 @@ def __call__( """ http_options = _BaseRegistryRestTransport._BaseUpdateApi._get_http_options() + request, metadata = self._interceptor.pre_update_api(request, metadata) transcoded_request = ( _BaseRegistryRestTransport._BaseUpdateApi._get_transcoded_request( @@ -4545,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.apigeeregistry_v1.RegistryClient.UpdateApi", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "UpdateApi", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._UpdateApi._get_response( self._host, @@ -4566,7 +6216,29 @@ def __call__( pb_resp = registry_models.Api.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_api(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = registry_models.Api.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigeeregistry_v1.RegistryClient.update_api", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "UpdateApi", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateApiDeployment( @@ -4604,7 +6276,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.ApiDeployment: r"""Call the update api deployment method over HTTP. @@ -4615,8 +6287,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.registry_models.ApiDeployment: @@ -4635,6 +6309,7 @@ def __call__( http_options = ( _BaseRegistryRestTransport._BaseUpdateApiDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_update_api_deployment( request, metadata ) @@ -4651,6 +6326,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.UpdateApiDeployment", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "UpdateApiDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._UpdateApiDeployment._get_response( self._host, @@ -4672,7 +6374,29 @@ def __call__( pb_resp = registry_models.ApiDeployment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_api_deployment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = registry_models.ApiDeployment.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigeeregistry_v1.RegistryClient.update_api_deployment", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "UpdateApiDeployment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateApiSpec( @@ -4710,7 +6434,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.ApiSpec: r"""Call the update api spec method over HTTP. @@ -4720,8 +6444,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.registry_models.ApiSpec: @@ -4745,6 +6471,7 @@ def __call__( http_options = ( _BaseRegistryRestTransport._BaseUpdateApiSpec._get_http_options() ) + request, metadata = self._interceptor.pre_update_api_spec(request, metadata) transcoded_request = ( _BaseRegistryRestTransport._BaseUpdateApiSpec._get_transcoded_request( @@ -4763,6 +6490,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.UpdateApiSpec", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "UpdateApiSpec", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._UpdateApiSpec._get_response( self._host, @@ -4784,7 +6538,29 @@ def __call__( pb_resp = registry_models.ApiSpec.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_api_spec(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = registry_models.ApiSpec.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigeeregistry_v1.RegistryClient.update_api_spec", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "UpdateApiSpec", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateApiVersion( @@ -4822,7 +6598,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> registry_models.ApiVersion: r"""Call the update api version method over HTTP. @@ -4832,8 +6608,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.registry_models.ApiVersion: @@ -4846,6 +6624,7 @@ def __call__( http_options = ( _BaseRegistryRestTransport._BaseUpdateApiVersion._get_http_options() ) + request, metadata = self._interceptor.pre_update_api_version( request, metadata ) @@ -4866,6 +6645,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.UpdateApiVersion", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "UpdateApiVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._UpdateApiVersion._get_response( self._host, @@ -4887,7 +6693,29 @@ def __call__( pb_resp = registry_models.ApiVersion.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_api_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = registry_models.ApiVersion.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apigeeregistry_v1.RegistryClient.update_api_version", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "UpdateApiVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -5246,7 +7074,7 @@ 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. @@ -5256,8 +7084,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -5266,6 +7096,7 @@ def __call__( http_options = ( _BaseRegistryRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseRegistryRestTransport._BaseGetLocation._get_transcoded_request( @@ -5280,6 +7111,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.GetLocation", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._GetLocation._get_response( self._host, @@ -5299,6 +7157,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.apigeeregistry_v1.RegistryAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -5339,7 +7218,7 @@ 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. @@ -5349,8 +7228,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -5359,6 +7240,7 @@ def __call__( http_options = ( _BaseRegistryRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = ( _BaseRegistryRestTransport._BaseListLocations._get_transcoded_request( @@ -5373,6 +7255,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.ListLocations", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._ListLocations._get_response( self._host, @@ -5392,6 +7301,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.apigeeregistry_v1.RegistryAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -5430,7 +7360,7 @@ 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. @@ -5440,8 +7370,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -5450,6 +7382,7 @@ def __call__( http_options = ( _BaseRegistryRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = ( _BaseRegistryRestTransport._BaseGetIamPolicy._get_transcoded_request( @@ -5464,6 +7397,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._GetIamPolicy._get_response( self._host, @@ -5483,6 +7443,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.apigeeregistry_v1.RegistryAsyncClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "GetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -5522,7 +7503,7 @@ 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. @@ -5532,8 +7513,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -5542,6 +7525,7 @@ def __call__( http_options = ( _BaseRegistryRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = ( _BaseRegistryRestTransport._BaseSetIamPolicy._get_transcoded_request( @@ -5560,6 +7544,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._SetIamPolicy._get_response( self._host, @@ -5580,6 +7591,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.apigeeregistry_v1.RegistryAsyncClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "SetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -5621,7 +7653,7 @@ 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. @@ -5631,8 +7663,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -5641,6 +7675,7 @@ def __call__( http_options = ( _BaseRegistryRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -5657,6 +7692,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._TestIamPermissions._get_response( self._host, @@ -5677,6 +7739,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.apigeeregistry_v1.RegistryAsyncClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "TestIamPermissions", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -5718,7 +7801,7 @@ 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. @@ -5728,13 +7811,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 = ( _BaseRegistryRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -5757,6 +7843,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.CancelOperation", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._CancelOperation._get_response( self._host, @@ -5813,7 +7926,7 @@ 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. @@ -5823,13 +7936,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 = ( _BaseRegistryRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -5846,6 +7962,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._DeleteOperation._get_response( self._host, @@ -5899,7 +8042,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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. @@ -5909,8 +8052,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -5919,6 +8064,7 @@ def __call__( http_options = ( _BaseRegistryRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseRegistryRestTransport._BaseGetOperation._get_transcoded_request( @@ -5933,6 +8079,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.GetOperation", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._GetOperation._get_response( self._host, @@ -5952,6 +8125,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.apigeeregistry_v1.RegistryAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -5992,7 +8186,7 @@ def __call__( *, 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. @@ -6002,8 +8196,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must 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. @@ -6012,6 +8208,7 @@ def __call__( http_options = ( _BaseRegistryRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = ( _BaseRegistryRestTransport._BaseListOperations._get_transcoded_request( @@ -6026,6 +8223,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apigeeregistry_v1.RegistryClient.ListOperations", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RegistryRestTransport._ListOperations._get_response( self._host, @@ -6045,6 +8269,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.apigeeregistry_v1.RegistryAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.apigeeregistry.v1.Registry", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-apigee-registry/samples/generated_samples/snippet_metadata_google.cloud.apigeeregistry.v1.json b/packages/google-cloud-apigee-registry/samples/generated_samples/snippet_metadata_google.cloud.apigeeregistry.v1.json index 70bba77cb438..b2c5df756020 100644 --- a/packages/google-cloud-apigee-registry/samples/generated_samples/snippet_metadata_google.cloud.apigeeregistry.v1.json +++ b/packages/google-cloud-apigee-registry/samples/generated_samples/snippet_metadata_google.cloud.apigeeregistry.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-apigee-registry", - "version": "0.6.13" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -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.apigee_registry_v1.types.Instance", @@ -465,7 +465,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.Instance", @@ -554,7 +554,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.ApiDeployment", @@ -642,7 +642,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.ApiDeployment", @@ -731,7 +731,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.ApiSpec", @@ -819,7 +819,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.ApiSpec", @@ -908,7 +908,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.ApiVersion", @@ -996,7 +996,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.ApiVersion", @@ -1085,7 +1085,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.Api", @@ -1173,7 +1173,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.Api", @@ -1262,7 +1262,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.Artifact", @@ -1350,7 +1350,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.Artifact", @@ -1431,7 +1431,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.ApiDeployment", @@ -1511,7 +1511,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.ApiDeployment", @@ -1592,7 +1592,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_api_deployment" @@ -1669,7 +1669,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_api_deployment" @@ -1747,7 +1747,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.ApiSpec", @@ -1827,7 +1827,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.ApiSpec", @@ -1908,7 +1908,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_api_spec" @@ -1985,7 +1985,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_api_spec" @@ -2063,7 +2063,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_api_version" @@ -2140,7 +2140,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_api_version" @@ -2218,7 +2218,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_api" @@ -2295,7 +2295,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_api" @@ -2373,7 +2373,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_artifact" @@ -2450,7 +2450,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_artifact" @@ -2528,7 +2528,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.ApiDeployment", @@ -2608,7 +2608,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.ApiDeployment", @@ -2689,7 +2689,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api.httpbody_pb2.HttpBody", @@ -2769,7 +2769,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api.httpbody_pb2.HttpBody", @@ -2850,7 +2850,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.ApiSpec", @@ -2930,7 +2930,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.ApiSpec", @@ -3011,7 +3011,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.ApiVersion", @@ -3091,7 +3091,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.ApiVersion", @@ -3172,7 +3172,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.Api", @@ -3252,7 +3252,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.Api", @@ -3333,7 +3333,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api.httpbody_pb2.HttpBody", @@ -3413,7 +3413,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api.httpbody_pb2.HttpBody", @@ -3494,7 +3494,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.Artifact", @@ -3574,7 +3574,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.Artifact", @@ -3651,7 +3651,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.services.registry.pagers.ListApiDeploymentRevisionsAsyncPager", @@ -3727,7 +3727,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.services.registry.pagers.ListApiDeploymentRevisionsPager", @@ -3808,7 +3808,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.services.registry.pagers.ListApiDeploymentsAsyncPager", @@ -3888,7 +3888,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.services.registry.pagers.ListApiDeploymentsPager", @@ -3965,7 +3965,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.services.registry.pagers.ListApiSpecRevisionsAsyncPager", @@ -4041,7 +4041,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.services.registry.pagers.ListApiSpecRevisionsPager", @@ -4122,7 +4122,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.services.registry.pagers.ListApiSpecsAsyncPager", @@ -4202,7 +4202,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.services.registry.pagers.ListApiSpecsPager", @@ -4283,7 +4283,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.services.registry.pagers.ListApiVersionsAsyncPager", @@ -4363,7 +4363,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.services.registry.pagers.ListApiVersionsPager", @@ -4444,7 +4444,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.services.registry.pagers.ListApisAsyncPager", @@ -4524,7 +4524,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.services.registry.pagers.ListApisPager", @@ -4605,7 +4605,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.services.registry.pagers.ListArtifactsAsyncPager", @@ -4685,7 +4685,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.services.registry.pagers.ListArtifactsPager", @@ -4766,7 +4766,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.Artifact", @@ -4846,7 +4846,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.Artifact", @@ -4923,7 +4923,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.ApiDeployment", @@ -4999,7 +4999,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.ApiDeployment", @@ -5076,7 +5076,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.ApiSpec", @@ -5152,7 +5152,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.ApiSpec", @@ -5229,7 +5229,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.ApiDeployment", @@ -5305,7 +5305,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.ApiDeployment", @@ -5382,7 +5382,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.ApiSpec", @@ -5458,7 +5458,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.ApiSpec", @@ -5543,7 +5543,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.ApiDeployment", @@ -5627,7 +5627,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.ApiDeployment", @@ -5712,7 +5712,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.ApiSpec", @@ -5796,7 +5796,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.ApiSpec", @@ -5881,7 +5881,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.ApiVersion", @@ -5965,7 +5965,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.ApiVersion", @@ -6050,7 +6050,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.Api", @@ -6134,7 +6134,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apigee_registry_v1.types.Api", diff --git a/packages/google-cloud-apigee-registry/tests/unit/gapic/apigee_registry_v1/test_provisioning.py b/packages/google-cloud-apigee-registry/tests/unit/gapic/apigee_registry_v1/test_provisioning.py index 962e61a891b1..084db6f89135 100644 --- a/packages/google-cloud-apigee-registry/tests/unit/gapic/apigee_registry_v1/test_provisioning.py +++ b/packages/google-cloud-apigee-registry/tests/unit/gapic/apigee_registry_v1/test_provisioning.py @@ -2175,6 +2175,7 @@ def test_create_instance_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_instance(request) @@ -2235,6 +2236,7 @@ def test_create_instance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_instance(**mock_args) @@ -2368,6 +2370,7 @@ def test_delete_instance_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_instance(request) @@ -2413,6 +2416,7 @@ def test_delete_instance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_instance(**mock_args) @@ -2543,6 +2547,7 @@ def test_get_instance_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_instance(request) @@ -2590,6 +2595,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) @@ -2908,6 +2914,7 @@ def test_create_instance_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_instance(request) @@ -3016,6 +3023,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_instance(request) # Establish that the response is the type that we expect. @@ -3057,6 +3065,7 @@ def test_create_instance_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -3101,6 +3110,7 @@ def test_delete_instance_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_instance(request) @@ -3131,6 +3141,7 @@ def test_delete_instance_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_instance(request) # Establish that the response is the type that we expect. @@ -3172,6 +3183,7 @@ def test_delete_instance_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -3216,6 +3228,7 @@ def test_get_instance_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_instance(request) @@ -3253,6 +3266,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. @@ -3295,6 +3309,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 = provisioning_service.Instance.to_json( provisioning_service.Instance() ) @@ -3341,6 +3356,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) @@ -3371,6 +3387,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) @@ -3399,6 +3416,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) @@ -3429,6 +3447,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) @@ -3459,6 +3478,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) @@ -3489,6 +3509,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) @@ -3519,6 +3540,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) @@ -3549,6 +3571,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) @@ -3579,6 +3602,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) @@ -3609,6 +3633,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) @@ -3639,6 +3664,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) @@ -3669,6 +3695,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) @@ -3699,6 +3726,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) @@ -3729,6 +3757,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) @@ -3759,6 +3788,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) @@ -3789,6 +3819,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) @@ -3819,6 +3850,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) @@ -3849,6 +3881,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-apigee-registry/tests/unit/gapic/apigee_registry_v1/test_registry.py b/packages/google-cloud-apigee-registry/tests/unit/gapic/apigee_registry_v1/test_registry.py index d5e5078e6acc..c41ab4b6268a 100644 --- a/packages/google-cloud-apigee-registry/tests/unit/gapic/apigee_registry_v1/test_registry.py +++ b/packages/google-cloud-apigee-registry/tests/unit/gapic/apigee_registry_v1/test_registry.py @@ -14290,6 +14290,7 @@ def test_list_apis_rest_required_fields(request_type=registry_service.ListApisRe response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_apis(request) @@ -14344,6 +14345,7 @@ def test_list_apis_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_apis(**mock_args) @@ -14533,6 +14535,7 @@ def test_get_api_rest_required_fields(request_type=registry_service.GetApiReques response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_api(request) @@ -14578,6 +14581,7 @@ def test_get_api_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_api(**mock_args) @@ -14718,6 +14722,7 @@ def test_create_api_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_api(request) @@ -14780,6 +14785,7 @@ def test_create_api_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_api(**mock_args) @@ -14915,6 +14921,7 @@ def test_update_api_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_api(request) @@ -14971,6 +14978,7 @@ def test_update_api_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_api(**mock_args) @@ -15101,6 +15109,7 @@ def test_delete_api_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_api(request) @@ -15144,6 +15153,7 @@ def test_delete_api_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_api(**mock_args) @@ -15284,6 +15294,7 @@ def test_list_api_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_api_versions(request) @@ -15338,6 +15349,7 @@ def test_list_api_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_api_versions(**mock_args) @@ -15532,6 +15544,7 @@ def test_get_api_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_api_version(request) @@ -15579,6 +15592,7 @@ def test_get_api_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_api_version(**mock_args) @@ -15724,6 +15738,7 @@ def test_create_api_version_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_api_version(request) @@ -15786,6 +15801,7 @@ def test_create_api_version_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_api_version(**mock_args) @@ -15926,6 +15942,7 @@ def test_update_api_version_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_api_version(request) @@ -15984,6 +16001,7 @@ def test_update_api_version_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_api_version(**mock_args) @@ -16119,6 +16137,7 @@ def test_delete_api_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.delete_api_version(request) @@ -16164,6 +16183,7 @@ def test_delete_api_version_rest_flattened(): json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_api_version(**mock_args) @@ -16303,6 +16323,7 @@ def test_list_api_specs_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_api_specs(request) @@ -16359,6 +16380,7 @@ def test_list_api_specs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_api_specs(**mock_args) @@ -16555,6 +16577,7 @@ def test_get_api_spec_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_api_spec(request) @@ -16602,6 +16625,7 @@ def test_get_api_spec_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_api_spec(**mock_args) @@ -16736,6 +16760,7 @@ def test_get_api_spec_contents_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_api_spec_contents(request) @@ -16781,6 +16806,7 @@ def test_get_api_spec_contents_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_api_spec_contents(**mock_args) @@ -16922,6 +16948,7 @@ def test_create_api_spec_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_api_spec(request) @@ -16986,6 +17013,7 @@ def test_create_api_spec_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_api_spec(**mock_args) @@ -17122,6 +17150,7 @@ def test_update_api_spec_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_api_spec(request) @@ -17180,6 +17209,7 @@ def test_update_api_spec_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_api_spec(**mock_args) @@ -17311,6 +17341,7 @@ def test_delete_api_spec_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_api_spec(request) @@ -17356,6 +17387,7 @@ def test_delete_api_spec_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_api_spec(**mock_args) @@ -17497,6 +17529,7 @@ def test_tag_api_spec_revision_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.tag_api_spec_revision(request) @@ -17638,6 +17671,7 @@ def test_list_api_spec_revisions_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_api_spec_revisions(request) @@ -17837,6 +17871,7 @@ def test_rollback_api_spec_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.rollback_api_spec(request) @@ -17969,6 +18004,7 @@ def test_delete_api_spec_revision_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_api_spec_revision(request) @@ -18016,6 +18052,7 @@ def test_delete_api_spec_revision_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_api_spec_revision(**mock_args) @@ -18159,6 +18196,7 @@ def test_list_api_deployments_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_api_deployments(request) @@ -18213,6 +18251,7 @@ def test_list_api_deployments_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_api_deployments(**mock_args) @@ -18411,6 +18450,7 @@ def test_get_api_deployment_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_api_deployment(request) @@ -18458,6 +18498,7 @@ def test_get_api_deployment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_api_deployment(**mock_args) @@ -18604,6 +18645,7 @@ def test_create_api_deployment_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_api_deployment(request) @@ -18666,6 +18708,7 @@ def test_create_api_deployment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_api_deployment(**mock_args) @@ -18807,6 +18850,7 @@ def test_update_api_deployment_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_api_deployment(request) @@ -18865,6 +18909,7 @@ def test_update_api_deployment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_api_deployment(**mock_args) @@ -19001,6 +19046,7 @@ def test_delete_api_deployment_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_api_deployment(request) @@ -19046,6 +19092,7 @@ def test_delete_api_deployment_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_api_deployment(**mock_args) @@ -19187,6 +19234,7 @@ def test_tag_api_deployment_revision_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.tag_api_deployment_revision(request) @@ -19328,6 +19376,7 @@ def test_list_api_deployment_revisions_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_api_deployment_revisions(request) @@ -19533,6 +19582,7 @@ def test_rollback_api_deployment_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.rollback_api_deployment(request) @@ -19665,6 +19715,7 @@ def test_delete_api_deployment_revision_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_api_deployment_revision(request) @@ -19714,6 +19765,7 @@ def test_delete_api_deployment_revision_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_api_deployment_revision(**mock_args) @@ -19853,6 +19905,7 @@ def test_list_artifacts_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_artifacts(request) @@ -19907,6 +19960,7 @@ def test_list_artifacts_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_artifacts(**mock_args) @@ -20100,6 +20154,7 @@ def test_get_artifact_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_artifact(request) @@ -20147,6 +20202,7 @@ def test_get_artifact_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_artifact(**mock_args) @@ -20280,6 +20336,7 @@ def test_get_artifact_contents_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_artifact_contents(request) @@ -20325,6 +20382,7 @@ def test_get_artifact_contents_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_artifact_contents(**mock_args) @@ -20466,6 +20524,7 @@ def test_create_artifact_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_artifact(request) @@ -20528,6 +20587,7 @@ def test_create_artifact_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_artifact(**mock_args) @@ -20658,6 +20718,7 @@ def test_replace_artifact_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.replace_artifact(request) @@ -20705,6 +20766,7 @@ def test_replace_artifact_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.replace_artifact(**mock_args) @@ -20833,6 +20895,7 @@ def test_delete_artifact_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_artifact(request) @@ -20878,6 +20941,7 @@ def test_delete_artifact_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_artifact(**mock_args) @@ -22922,6 +22986,7 @@ def test_list_apis_rest_bad_request(request_type=registry_service.ListApisReques response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_apis(request) @@ -22957,6 +23022,7 @@ def test_list_apis_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_apis(request) # Establish that the response is the type that we expect. @@ -22995,6 +23061,7 @@ def test_list_apis_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = registry_service.ListApisResponse.to_json( registry_service.ListApisResponse() ) @@ -23039,6 +23106,7 @@ def test_get_api_rest_bad_request(request_type=registry_service.GetApiRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_api(request) @@ -23079,6 +23147,7 @@ def test_get_api_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_api(request) # Establish that the response is the type that we expect. @@ -23120,6 +23189,7 @@ def test_get_api_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = registry_models.Api.to_json(registry_models.Api()) req.return_value.content = return_value @@ -23162,6 +23232,7 @@ def test_create_api_rest_bad_request(request_type=registry_service.CreateApiRequ response_value.status_code = 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_api(request) @@ -23281,6 +23352,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_api(request) # Establish that the response is the type that we expect. @@ -23324,6 +23396,7 @@ def test_create_api_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = registry_models.Api.to_json(registry_models.Api()) req.return_value.content = return_value @@ -23366,6 +23439,7 @@ def test_update_api_rest_bad_request(request_type=registry_service.UpdateApiRequ response_value.status_code = 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_api(request) @@ -23485,6 +23559,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_api(request) # Establish that the response is the type that we expect. @@ -23528,6 +23603,7 @@ def test_update_api_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = registry_models.Api.to_json(registry_models.Api()) req.return_value.content = return_value @@ -23570,6 +23646,7 @@ def test_delete_api_rest_bad_request(request_type=registry_service.DeleteApiRequ response_value.status_code = 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_api(request) @@ -23600,6 +23677,7 @@ def test_delete_api_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_api(request) # Establish that the response is the type that we expect. @@ -23634,6 +23712,7 @@ def test_delete_api_rest_interceptors(null_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 = registry_service.DeleteApiRequest() metadata = [ @@ -23674,6 +23753,7 @@ def test_list_api_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_api_versions(request) @@ -23709,6 +23789,7 @@ def test_list_api_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_api_versions(request) # Establish that the response is the type that we expect. @@ -23747,6 +23828,7 @@ def test_list_api_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 = registry_service.ListApiVersionsResponse.to_json( registry_service.ListApiVersionsResponse() ) @@ -23795,6 +23877,7 @@ def test_get_api_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_api_version(request) @@ -23835,6 +23918,7 @@ def test_get_api_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_api_version(request) # Establish that the response is the type that we expect. @@ -23876,6 +23960,7 @@ def test_get_api_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 = registry_models.ApiVersion.to_json(registry_models.ApiVersion()) req.return_value.content = return_value @@ -23920,6 +24005,7 @@ def test_create_api_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.create_api_version(request) @@ -24035,6 +24121,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_api_version(request) # Establish that the response is the type that we expect. @@ -24076,6 +24163,7 @@ def test_create_api_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 = registry_models.ApiVersion.to_json(registry_models.ApiVersion()) req.return_value.content = return_value @@ -24124,6 +24212,7 @@ def test_update_api_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.update_api_version(request) @@ -24243,6 +24332,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_api_version(request) # Establish that the response is the type that we expect. @@ -24284,6 +24374,7 @@ def test_update_api_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 = registry_models.ApiVersion.to_json(registry_models.ApiVersion()) req.return_value.content = return_value @@ -24330,6 +24421,7 @@ def test_delete_api_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.delete_api_version(request) @@ -24362,6 +24454,7 @@ def test_delete_api_version_rest_call_success(request_type): json_return_value = "" response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_api_version(request) # Establish that the response is the type that we expect. @@ -24396,6 +24489,7 @@ def test_delete_api_version_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = registry_service.DeleteApiVersionRequest() metadata = [ @@ -24438,6 +24532,7 @@ def test_list_api_specs_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_api_specs(request) @@ -24475,6 +24570,7 @@ def test_list_api_specs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_api_specs(request) # Establish that the response is the type that we expect. @@ -24513,6 +24609,7 @@ def test_list_api_specs_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = registry_service.ListApiSpecsResponse.to_json( registry_service.ListApiSpecsResponse() ) @@ -24559,6 +24656,7 @@ def test_get_api_spec_rest_bad_request(request_type=registry_service.GetApiSpecR response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_api_spec(request) @@ -24604,6 +24702,7 @@ def test_get_api_spec_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_api_spec(request) # Establish that the response is the type that we expect. @@ -24650,6 +24749,7 @@ def test_get_api_spec_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = registry_models.ApiSpec.to_json(registry_models.ApiSpec()) req.return_value.content = return_value @@ -24696,6 +24796,7 @@ def test_get_api_spec_contents_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_api_spec_contents(request) @@ -24731,6 +24832,7 @@ def test_get_api_spec_contents_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_api_spec_contents(request) # Establish that the response is the type that we expect. @@ -24770,6 +24872,7 @@ def test_get_api_spec_contents_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(httpbody_pb2.HttpBody()) req.return_value.content = return_value @@ -24816,6 +24919,7 @@ def test_create_api_spec_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_api_spec(request) @@ -24944,6 +25048,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_api_spec(request) # Establish that the response is the type that we expect. @@ -24990,6 +25095,7 @@ def test_create_api_spec_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = registry_models.ApiSpec.to_json(registry_models.ApiSpec()) req.return_value.content = return_value @@ -25038,6 +25144,7 @@ def test_update_api_spec_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_api_spec(request) @@ -25168,6 +25275,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_api_spec(request) # Establish that the response is the type that we expect. @@ -25214,6 +25322,7 @@ def test_update_api_spec_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = registry_models.ApiSpec.to_json(registry_models.ApiSpec()) req.return_value.content = return_value @@ -25260,6 +25369,7 @@ def test_delete_api_spec_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_api_spec(request) @@ -25292,6 +25402,7 @@ def test_delete_api_spec_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_api_spec(request) # Establish that the response is the type that we expect. @@ -25326,6 +25437,7 @@ def test_delete_api_spec_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = registry_service.DeleteApiSpecRequest() metadata = [ @@ -25368,6 +25480,7 @@ def test_tag_api_spec_revision_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.tag_api_spec_revision(request) @@ -25413,6 +25526,7 @@ def test_tag_api_spec_revision_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.tag_api_spec_revision(request) # Establish that the response is the type that we expect. @@ -25459,6 +25573,7 @@ def test_tag_api_spec_revision_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = registry_models.ApiSpec.to_json(registry_models.ApiSpec()) req.return_value.content = return_value @@ -25505,6 +25620,7 @@ def test_list_api_spec_revisions_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_api_spec_revisions(request) @@ -25542,6 +25658,7 @@ def test_list_api_spec_revisions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_api_spec_revisions(request) # Establish that the response is the type that we expect. @@ -25580,6 +25697,7 @@ def test_list_api_spec_revisions_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = registry_service.ListApiSpecRevisionsResponse.to_json( registry_service.ListApiSpecRevisionsResponse() ) @@ -25628,6 +25746,7 @@ def test_rollback_api_spec_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.rollback_api_spec(request) @@ -25673,6 +25792,7 @@ def test_rollback_api_spec_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.rollback_api_spec(request) # Establish that the response is the type that we expect. @@ -25719,6 +25839,7 @@ def test_rollback_api_spec_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = registry_models.ApiSpec.to_json(registry_models.ApiSpec()) req.return_value.content = return_value @@ -25765,6 +25886,7 @@ def test_delete_api_spec_revision_rest_bad_request( response_value.status_code = 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_api_spec_revision(request) @@ -25810,6 +25932,7 @@ def test_delete_api_spec_revision_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_api_spec_revision(request) # Establish that the response is the type that we expect. @@ -25856,6 +25979,7 @@ def test_delete_api_spec_revision_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = registry_models.ApiSpec.to_json(registry_models.ApiSpec()) req.return_value.content = return_value @@ -25900,6 +26024,7 @@ def test_list_api_deployments_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_api_deployments(request) @@ -25935,6 +26060,7 @@ def test_list_api_deployments_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_api_deployments(request) # Establish that the response is the type that we expect. @@ -25973,6 +26099,7 @@ def test_list_api_deployments_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = registry_service.ListApiDeploymentsResponse.to_json( registry_service.ListApiDeploymentsResponse() ) @@ -26021,6 +26148,7 @@ def test_get_api_deployment_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_api_deployment(request) @@ -26066,6 +26194,7 @@ def test_get_api_deployment_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_api_deployment(request) # Establish that the response is the type that we expect. @@ -26112,6 +26241,7 @@ def test_get_api_deployment_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = registry_models.ApiDeployment.to_json( registry_models.ApiDeployment() ) @@ -26158,6 +26288,7 @@ def test_create_api_deployment_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_api_deployment(request) @@ -26286,6 +26417,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_api_deployment(request) # Establish that the response is the type that we expect. @@ -26332,6 +26464,7 @@ def test_create_api_deployment_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = registry_models.ApiDeployment.to_json( registry_models.ApiDeployment() ) @@ -26382,6 +26515,7 @@ def test_update_api_deployment_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_api_deployment(request) @@ -26514,6 +26648,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_api_deployment(request) # Establish that the response is the type that we expect. @@ -26560,6 +26695,7 @@ def test_update_api_deployment_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = registry_models.ApiDeployment.to_json( registry_models.ApiDeployment() ) @@ -26608,6 +26744,7 @@ def test_delete_api_deployment_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_api_deployment(request) @@ -26640,6 +26777,7 @@ def test_delete_api_deployment_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_api_deployment(request) # Establish that the response is the type that we expect. @@ -26674,6 +26812,7 @@ def test_delete_api_deployment_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = registry_service.DeleteApiDeploymentRequest() metadata = [ @@ -26716,6 +26855,7 @@ def test_tag_api_deployment_revision_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.tag_api_deployment_revision(request) @@ -26761,6 +26901,7 @@ def test_tag_api_deployment_revision_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.tag_api_deployment_revision(request) # Establish that the response is the type that we expect. @@ -26807,6 +26948,7 @@ def test_tag_api_deployment_revision_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = registry_models.ApiDeployment.to_json( registry_models.ApiDeployment() ) @@ -26855,6 +26997,7 @@ def test_list_api_deployment_revisions_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_api_deployment_revisions(request) @@ -26894,6 +27037,7 @@ def test_list_api_deployment_revisions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_api_deployment_revisions(request) # Establish that the response is the type that we expect. @@ -26932,6 +27076,7 @@ def test_list_api_deployment_revisions_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = registry_service.ListApiDeploymentRevisionsResponse.to_json( registry_service.ListApiDeploymentRevisionsResponse() ) @@ -26980,6 +27125,7 @@ def test_rollback_api_deployment_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.rollback_api_deployment(request) @@ -27025,6 +27171,7 @@ def test_rollback_api_deployment_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.rollback_api_deployment(request) # Establish that the response is the type that we expect. @@ -27071,6 +27218,7 @@ def test_rollback_api_deployment_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = registry_models.ApiDeployment.to_json( registry_models.ApiDeployment() ) @@ -27119,6 +27267,7 @@ def test_delete_api_deployment_revision_rest_bad_request( response_value.status_code = 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_api_deployment_revision(request) @@ -27164,6 +27313,7 @@ def test_delete_api_deployment_revision_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_api_deployment_revision(request) # Establish that the response is the type that we expect. @@ -27210,6 +27360,7 @@ def test_delete_api_deployment_revision_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = registry_models.ApiDeployment.to_json( registry_models.ApiDeployment() ) @@ -27256,6 +27407,7 @@ def test_list_artifacts_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_artifacts(request) @@ -27291,6 +27443,7 @@ def test_list_artifacts_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_artifacts(request) # Establish that the response is the type that we expect. @@ -27329,6 +27482,7 @@ def test_list_artifacts_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = registry_service.ListArtifactsResponse.to_json( registry_service.ListArtifactsResponse() ) @@ -27375,6 +27529,7 @@ def test_get_artifact_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_artifact(request) @@ -27414,6 +27569,7 @@ def test_get_artifact_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_artifact(request) # Establish that the response is the type that we expect. @@ -27456,6 +27612,7 @@ def test_get_artifact_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = registry_models.Artifact.to_json(registry_models.Artifact()) req.return_value.content = return_value @@ -27500,6 +27657,7 @@ def test_get_artifact_contents_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_artifact_contents(request) @@ -27533,6 +27691,7 @@ def test_get_artifact_contents_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_artifact_contents(request) # Establish that the response is the type that we expect. @@ -27572,6 +27731,7 @@ def test_get_artifact_contents_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(httpbody_pb2.HttpBody()) req.return_value.content = return_value @@ -27616,6 +27776,7 @@ def test_create_artifact_rest_bad_request( response_value.status_code = 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_artifact(request) @@ -27731,6 +27892,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_artifact(request) # Establish that the response is the type that we expect. @@ -27773,6 +27935,7 @@ def test_create_artifact_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = registry_models.Artifact.to_json(registry_models.Artifact()) req.return_value.content = return_value @@ -27819,6 +27982,7 @@ def test_replace_artifact_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.replace_artifact(request) @@ -27936,6 +28100,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.replace_artifact(request) # Establish that the response is the type that we expect. @@ -27978,6 +28143,7 @@ def test_replace_artifact_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = registry_models.Artifact.to_json(registry_models.Artifact()) req.return_value.content = return_value @@ -28022,6 +28188,7 @@ def test_delete_artifact_rest_bad_request( response_value.status_code = 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_artifact(request) @@ -28052,6 +28219,7 @@ def test_delete_artifact_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_artifact(request) # Establish that the response is the type that we expect. @@ -28086,6 +28254,7 @@ def test_delete_artifact_rest_interceptors(null_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 = registry_service.DeleteArtifactRequest() metadata = [ @@ -28126,6 +28295,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) @@ -28156,6 +28326,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) @@ -28184,6 +28355,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) @@ -28214,6 +28386,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) @@ -28244,6 +28417,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) @@ -28274,6 +28448,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) @@ -28304,6 +28479,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) @@ -28334,6 +28510,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) @@ -28364,6 +28541,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) @@ -28394,6 +28572,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) @@ -28424,6 +28603,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) @@ -28454,6 +28634,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) @@ -28484,6 +28665,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) @@ -28514,6 +28696,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) @@ -28544,6 +28727,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) @@ -28574,6 +28758,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) @@ -28604,6 +28789,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) @@ -28634,6 +28820,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-apihub/google/cloud/apihub/gapic_version.py b/packages/google-cloud-apihub/google/cloud/apihub/gapic_version.py index d1a1a883babd..558c8aab67c5 100644 --- a/packages/google-cloud-apihub/google/cloud/apihub/gapic_version.py +++ b/packages/google-cloud-apihub/google/cloud/apihub/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.2.2" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-apihub/google/cloud/apihub_v1/gapic_version.py b/packages/google-cloud-apihub/google/cloud/apihub_v1/gapic_version.py index d1a1a883babd..558c8aab67c5 100644 --- a/packages/google-cloud-apihub/google/cloud/apihub_v1/gapic_version.py +++ b/packages/google-cloud-apihub/google/cloud/apihub_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.2" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-apihub/google/cloud/apihub_v1/services/api_hub/client.py b/packages/google-cloud-apihub/google/cloud/apihub_v1/services/api_hub/client.py index dc5bfa82b1f8..9796f05470ca 100644 --- a/packages/google-cloud-apihub/google/cloud/apihub_v1/services/api_hub/client.py +++ b/packages/google-cloud-apihub/google/cloud/apihub_v1/services/api_hub/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -747,6 +757,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( @@ -809,6 +823,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.apihub_v1.ApiHubClient`.", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "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.apihub.v1.ApiHub", + "credentialsType": None, + }, + ) + def create_api( self, request: Optional[Union[apihub_service.CreateApiRequest, dict]] = None, @@ -818,7 +855,7 @@ def create_api( api_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]]] = (), ) -> common_fields.Api: r"""Create an API resource in the API hub. Once an API resource is created, versions can be added @@ -889,8 +926,10 @@ def sample_create_api(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.types.Api: @@ -950,7 +989,7 @@ def get_api( name: Optional[str] = None, retry: OptionalRetry = 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_fields.Api: r"""Get API resource details including the API versions contained in it. @@ -996,8 +1035,10 @@ def sample_get_api(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.types.Api: @@ -1053,7 +1094,7 @@ def list_apis( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListApisPager: r"""List API resources in the API hub. @@ -1099,8 +1140,10 @@ def sample_list_apis(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.services.api_hub.pagers.ListApisPager: @@ -1173,7 +1216,7 @@ def update_api( 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]]] = (), ) -> common_fields.Api: r"""Update an API resource in the API hub. The following fields in the [API][] can be updated: @@ -1248,8 +1291,10 @@ def sample_update_api(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.types.Api: @@ -1307,7 +1352,7 @@ def delete_api( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Delete an API resource in the API hub. API can only be deleted if all underlying versions are deleted. @@ -1350,8 +1395,10 @@ def sample_delete_api(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -1402,7 +1449,7 @@ def create_version( version_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]]] = (), ) -> common_fields.Version: r"""Create an API version for an API resource in the API hub. @@ -1473,8 +1520,10 @@ def sample_create_version(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.types.Version: @@ -1537,7 +1586,7 @@ def get_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common_fields.Version: r"""Get details about the API version of an API resource. This will include information about the specs and @@ -1586,8 +1635,10 @@ def sample_get_version(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.types.Version: @@ -1646,7 +1697,7 @@ def list_versions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListVersionsPager: r"""List API versions of an API resource in the API hub. @@ -1693,8 +1744,10 @@ def sample_list_versions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.services.api_hub.pagers.ListVersionsPager: @@ -1767,7 +1820,7 @@ def update_version( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common_fields.Version: r"""Update API version. The following fields in the [version][google.cloud.apihub.v1.Version] can be updated @@ -1840,8 +1893,10 @@ def sample_update_version(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.types.Version: @@ -1904,7 +1959,7 @@ def delete_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Delete an API version. Version can only be deleted if all underlying specs, operations, definitions and linked @@ -1948,8 +2003,10 @@ def sample_delete_version(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2000,7 +2057,7 @@ def create_spec( spec_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]]] = (), ) -> common_fields.Spec: r"""Add a spec to an API version in the API hub. Multiple specs can be added to an API version. Note, while adding a spec, at least @@ -2094,8 +2151,10 @@ def sample_create_spec(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.types.Spec: @@ -2160,7 +2219,7 @@ def get_spec( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common_fields.Spec: r"""Get details about the information parsed from a spec. Note that this method does not return the raw spec contents. Use @@ -2207,8 +2266,10 @@ def sample_get_spec(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.types.Spec: @@ -2269,7 +2330,7 @@ def get_spec_contents( name: Optional[str] = None, retry: OptionalRetry = 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_fields.SpecContents: r"""Get spec contents. @@ -2315,8 +2376,10 @@ def sample_get_spec_contents(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.types.SpecContents: @@ -2372,7 +2435,7 @@ def list_specs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSpecsPager: r"""List specs corresponding to a particular API resource. @@ -2418,8 +2481,10 @@ def sample_list_specs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.services.api_hub.pagers.ListSpecsPager: @@ -2492,7 +2557,7 @@ def update_spec( 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]]] = (), ) -> common_fields.Spec: r"""Update spec. The following fields in the [spec][google.cloud.apihub.v1.Spec] can be updated: @@ -2574,8 +2639,10 @@ def sample_update_spec(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.types.Spec: @@ -2640,7 +2707,7 @@ def delete_spec( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Delete a spec. Deleting a spec will also delete the associated @@ -2684,8 +2751,10 @@ def sample_delete_spec(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2734,7 +2803,7 @@ def get_api_operation( name: Optional[str] = None, retry: OptionalRetry = 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_fields.ApiOperation: r"""Get details about a particular operation in API version. @@ -2780,8 +2849,10 @@ def sample_get_api_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: google.cloud.apihub_v1.types.ApiOperation: @@ -2846,7 +2917,7 @@ def list_api_operations( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListApiOperationsPager: r"""List operations in an API version. @@ -2893,8 +2964,10 @@ def sample_list_api_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: google.cloud.apihub_v1.services.api_hub.pagers.ListApiOperationsPager: @@ -2966,7 +3039,7 @@ def get_definition( name: Optional[str] = None, retry: OptionalRetry = 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_fields.Definition: r"""Get details about a definition in an API version. @@ -3012,8 +3085,10 @@ def sample_get_definition(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.types.Definition: @@ -3079,7 +3154,7 @@ def create_deployment( deployment_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common_fields.Deployment: r"""Create a deployment resource in the API hub. Once a deployment resource is created, it can be @@ -3158,8 +3233,10 @@ def sample_create_deployment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.types.Deployment: @@ -3226,7 +3303,7 @@ def get_deployment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common_fields.Deployment: r"""Get details about a deployment and the API versions linked to it. @@ -3273,8 +3350,10 @@ def sample_get_deployment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.types.Deployment: @@ -3337,7 +3416,7 @@ def list_deployments( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDeploymentsPager: r"""List deployment resources in the API hub. @@ -3384,8 +3463,10 @@ def sample_list_deployments(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.services.api_hub.pagers.ListDeploymentsPager: @@ -3458,7 +3539,7 @@ def update_deployment( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common_fields.Deployment: r"""Update a deployment resource in the API hub. The following fields in the [deployment @@ -3536,8 +3617,10 @@ def sample_update_deployment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.types.Deployment: @@ -3604,7 +3687,7 @@ def delete_deployment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Delete a deployment resource in the API hub. @@ -3647,8 +3730,10 @@ def sample_delete_deployment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -3699,7 +3784,7 @@ def create_attribute( attribute_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]]] = (), ) -> common_fields.Attribute: r"""Create a user defined attribute. @@ -3779,8 +3864,10 @@ def sample_create_attribute(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.types.Attribute: @@ -3847,7 +3934,7 @@ def get_attribute( name: Optional[str] = None, retry: OptionalRetry = 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_fields.Attribute: r"""Get details about the attribute. @@ -3892,8 +3979,10 @@ def sample_get_attribute(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.types.Attribute: @@ -3957,7 +4046,7 @@ def update_attribute( 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]]] = (), ) -> common_fields.Attribute: r"""Update the attribute. The following fields in the [Attribute resource][google.cloud.apihub.v1.Attribute] can be updated: @@ -4042,8 +4131,10 @@ def sample_update_attribute(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.types.Attribute: @@ -4110,7 +4201,7 @@ def delete_attribute( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Delete an attribute. @@ -4156,8 +4247,10 @@ def sample_delete_attribute(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -4206,7 +4299,7 @@ def list_attributes( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAttributesPager: r"""List all attributes. @@ -4252,8 +4345,10 @@ def sample_list_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.apihub_v1.services.api_hub.pagers.ListAttributesPager: @@ -4326,7 +4421,7 @@ def search_resources( query: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchResourcesPager: r"""Search across API-Hub resources. @@ -4386,8 +4481,10 @@ def sample_search_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.apihub_v1.services.api_hub.pagers.SearchResourcesPager: @@ -4464,7 +4561,7 @@ def create_external_api( external_api_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]]] = (), ) -> common_fields.ExternalApi: r"""Create an External API resource in the API hub. @@ -4537,8 +4634,10 @@ def sample_create_external_api(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.types.ExternalApi: @@ -4602,7 +4701,7 @@ def get_external_api( name: Optional[str] = None, retry: OptionalRetry = 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_fields.ExternalApi: r"""Get details about an External API resource in the API hub. @@ -4649,8 +4748,10 @@ def sample_get_external_api(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.types.ExternalApi: @@ -4711,7 +4812,7 @@ def update_external_api( 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]]] = (), ) -> common_fields.ExternalApi: r"""Update an External API resource in the API hub. The following fields can be updated: @@ -4780,8 +4881,10 @@ def sample_update_external_api(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.types.ExternalApi: @@ -4845,7 +4948,7 @@ def delete_external_api( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Delete an External API resource in the API hub. @@ -4888,8 +4991,10 @@ def sample_delete_external_api(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -4938,7 +5043,7 @@ def list_external_apis( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListExternalApisPager: r"""List External API resources in the API hub. @@ -4985,8 +5090,10 @@ def sample_list_external_apis(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.services.api_hub.pagers.ListExternalApisPager: @@ -5070,7 +5177,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. @@ -5081,8 +5188,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. @@ -5123,7 +5232,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. @@ -5134,8 +5243,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. @@ -5176,7 +5287,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. @@ -5192,8 +5303,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 """ @@ -5230,7 +5343,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. @@ -5245,8 +5358,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 """ @@ -5283,7 +5398,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. @@ -5294,8 +5409,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. @@ -5336,7 +5453,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. @@ -5347,8 +5464,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-apihub/google/cloud/apihub_v1/services/api_hub/pagers.py b/packages/google-cloud-apihub/google/cloud/apihub_v1/services/api_hub/pagers.py index 510192a2f321..ced47bdaa2b8 100644 --- a/packages/google-cloud-apihub/google/cloud/apihub_v1/services/api_hub/pagers.py +++ b/packages/google-cloud-apihub/google/cloud/apihub_v1/services/api_hub/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 = apihub_service.ListApisRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -155,8 +157,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = apihub_service.ListVersionsRequest(request) @@ -215,7 +219,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -229,8 +233,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = apihub_service.ListSpecsRequest(request) @@ -289,7 +295,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -303,8 +309,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = apihub_service.ListApiOperationsRequest(request) @@ -363,7 +371,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -377,8 +385,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = apihub_service.ListDeploymentsRequest(request) @@ -437,7 +447,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -451,8 +461,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = apihub_service.ListAttributesRequest(request) @@ -511,7 +523,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -525,8 +537,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = apihub_service.SearchResourcesRequest(request) @@ -585,7 +599,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -599,8 +613,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = apihub_service.ListExternalApisRequest(request) diff --git a/packages/google-cloud-apihub/google/cloud/apihub_v1/services/api_hub/transports/rest.py b/packages/google-cloud-apihub/google/cloud/apihub_v1/services/api_hub/transports/rest.py index b494570eeac3..f1623721d63a 100644 --- a/packages/google-cloud-apihub/google/cloud/apihub_v1/services/api_hub/transports/rest.py +++ b/packages/google-cloud-apihub/google/cloud/apihub_v1/services/api_hub/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, @@ -328,8 +336,10 @@ def post_update_version(self, response): def pre_create_api( self, request: apihub_service.CreateApiRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.CreateApiRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apihub_service.CreateApiRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_api Override in a subclass to manipulate the request or metadata @@ -349,8 +359,10 @@ def post_create_api(self, response: common_fields.Api) -> common_fields.Api: def pre_create_attribute( self, request: apihub_service.CreateAttributeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.CreateAttributeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apihub_service.CreateAttributeRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_attribute Override in a subclass to manipulate the request or metadata @@ -372,8 +384,10 @@ def post_create_attribute( def pre_create_deployment( self, request: apihub_service.CreateDeploymentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.CreateDeploymentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apihub_service.CreateDeploymentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_deployment Override in a subclass to manipulate the request or metadata @@ -395,8 +409,10 @@ def post_create_deployment( def pre_create_external_api( self, request: apihub_service.CreateExternalApiRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.CreateExternalApiRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apihub_service.CreateExternalApiRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_external_api Override in a subclass to manipulate the request or metadata @@ -418,8 +434,10 @@ def post_create_external_api( def pre_create_spec( self, request: apihub_service.CreateSpecRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.CreateSpecRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apihub_service.CreateSpecRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_spec Override in a subclass to manipulate the request or metadata @@ -439,8 +457,10 @@ def post_create_spec(self, response: common_fields.Spec) -> common_fields.Spec: def pre_create_version( self, request: apihub_service.CreateVersionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.CreateVersionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apihub_service.CreateVersionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_version Override in a subclass to manipulate the request or metadata @@ -462,8 +482,10 @@ def post_create_version( def pre_delete_api( self, request: apihub_service.DeleteApiRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.DeleteApiRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apihub_service.DeleteApiRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_api Override in a subclass to manipulate the request or metadata @@ -474,8 +496,10 @@ def pre_delete_api( def pre_delete_attribute( self, request: apihub_service.DeleteAttributeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.DeleteAttributeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apihub_service.DeleteAttributeRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_attribute Override in a subclass to manipulate the request or metadata @@ -486,8 +510,10 @@ def pre_delete_attribute( def pre_delete_deployment( self, request: apihub_service.DeleteDeploymentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.DeleteDeploymentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apihub_service.DeleteDeploymentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_deployment Override in a subclass to manipulate the request or metadata @@ -498,8 +524,10 @@ def pre_delete_deployment( def pre_delete_external_api( self, request: apihub_service.DeleteExternalApiRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.DeleteExternalApiRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apihub_service.DeleteExternalApiRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_external_api Override in a subclass to manipulate the request or metadata @@ -510,8 +538,10 @@ def pre_delete_external_api( def pre_delete_spec( self, request: apihub_service.DeleteSpecRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.DeleteSpecRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apihub_service.DeleteSpecRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_spec Override in a subclass to manipulate the request or metadata @@ -522,8 +552,10 @@ def pre_delete_spec( def pre_delete_version( self, request: apihub_service.DeleteVersionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.DeleteVersionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apihub_service.DeleteVersionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_version Override in a subclass to manipulate the request or metadata @@ -532,8 +564,10 @@ def pre_delete_version( return request, metadata def pre_get_api( - self, request: apihub_service.GetApiRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[apihub_service.GetApiRequest, Sequence[Tuple[str, str]]]: + self, + request: apihub_service.GetApiRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[apihub_service.GetApiRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_api Override in a subclass to manipulate the request or metadata @@ -553,8 +587,10 @@ def post_get_api(self, response: common_fields.Api) -> common_fields.Api: def pre_get_api_operation( self, request: apihub_service.GetApiOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.GetApiOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apihub_service.GetApiOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_api_operation Override in a subclass to manipulate the request or metadata @@ -576,8 +612,10 @@ def post_get_api_operation( def pre_get_attribute( self, request: apihub_service.GetAttributeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.GetAttributeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apihub_service.GetAttributeRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_attribute Override in a subclass to manipulate the request or metadata @@ -599,8 +637,10 @@ def post_get_attribute( def pre_get_definition( self, request: apihub_service.GetDefinitionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.GetDefinitionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apihub_service.GetDefinitionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_definition Override in a subclass to manipulate the request or metadata @@ -622,8 +662,10 @@ def post_get_definition( def pre_get_deployment( self, request: apihub_service.GetDeploymentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.GetDeploymentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apihub_service.GetDeploymentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_deployment Override in a subclass to manipulate the request or metadata @@ -645,8 +687,10 @@ def post_get_deployment( def pre_get_external_api( self, request: apihub_service.GetExternalApiRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.GetExternalApiRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apihub_service.GetExternalApiRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_external_api Override in a subclass to manipulate the request or metadata @@ -668,8 +712,8 @@ def post_get_external_api( def pre_get_spec( self, request: apihub_service.GetSpecRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.GetSpecRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[apihub_service.GetSpecRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_spec Override in a subclass to manipulate the request or metadata @@ -689,8 +733,10 @@ def post_get_spec(self, response: common_fields.Spec) -> common_fields.Spec: def pre_get_spec_contents( self, request: apihub_service.GetSpecContentsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.GetSpecContentsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apihub_service.GetSpecContentsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_spec_contents Override in a subclass to manipulate the request or metadata @@ -712,8 +758,10 @@ def post_get_spec_contents( def pre_get_version( self, request: apihub_service.GetVersionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.GetVersionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apihub_service.GetVersionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_version Override in a subclass to manipulate the request or metadata @@ -735,8 +783,10 @@ def post_get_version( def pre_list_api_operations( self, request: apihub_service.ListApiOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.ListApiOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apihub_service.ListApiOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_api_operations Override in a subclass to manipulate the request or metadata @@ -758,8 +808,8 @@ def post_list_api_operations( def pre_list_apis( self, request: apihub_service.ListApisRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.ListApisRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[apihub_service.ListApisRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_apis Override in a subclass to manipulate the request or metadata @@ -781,8 +831,10 @@ def post_list_apis( def pre_list_attributes( self, request: apihub_service.ListAttributesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.ListAttributesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apihub_service.ListAttributesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_attributes Override in a subclass to manipulate the request or metadata @@ -804,8 +856,10 @@ def post_list_attributes( def pre_list_deployments( self, request: apihub_service.ListDeploymentsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.ListDeploymentsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apihub_service.ListDeploymentsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_deployments Override in a subclass to manipulate the request or metadata @@ -827,8 +881,10 @@ def post_list_deployments( def pre_list_external_apis( self, request: apihub_service.ListExternalApisRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.ListExternalApisRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apihub_service.ListExternalApisRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_external_apis Override in a subclass to manipulate the request or metadata @@ -850,8 +906,10 @@ def post_list_external_apis( def pre_list_specs( self, request: apihub_service.ListSpecsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.ListSpecsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apihub_service.ListSpecsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_specs Override in a subclass to manipulate the request or metadata @@ -873,8 +931,10 @@ def post_list_specs( def pre_list_versions( self, request: apihub_service.ListVersionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.ListVersionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apihub_service.ListVersionsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_versions Override in a subclass to manipulate the request or metadata @@ -896,8 +956,10 @@ def post_list_versions( def pre_search_resources( self, request: apihub_service.SearchResourcesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.SearchResourcesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apihub_service.SearchResourcesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for search_resources Override in a subclass to manipulate the request or metadata @@ -919,8 +981,10 @@ def post_search_resources( def pre_update_api( self, request: apihub_service.UpdateApiRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.UpdateApiRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apihub_service.UpdateApiRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_api Override in a subclass to manipulate the request or metadata @@ -940,8 +1004,10 @@ def post_update_api(self, response: common_fields.Api) -> common_fields.Api: def pre_update_attribute( self, request: apihub_service.UpdateAttributeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.UpdateAttributeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apihub_service.UpdateAttributeRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_attribute Override in a subclass to manipulate the request or metadata @@ -963,8 +1029,10 @@ def post_update_attribute( def pre_update_deployment( self, request: apihub_service.UpdateDeploymentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.UpdateDeploymentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apihub_service.UpdateDeploymentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_deployment Override in a subclass to manipulate the request or metadata @@ -986,8 +1054,10 @@ def post_update_deployment( def pre_update_external_api( self, request: apihub_service.UpdateExternalApiRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.UpdateExternalApiRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apihub_service.UpdateExternalApiRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_external_api Override in a subclass to manipulate the request or metadata @@ -1009,8 +1079,10 @@ def post_update_external_api( def pre_update_spec( self, request: apihub_service.UpdateSpecRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.UpdateSpecRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apihub_service.UpdateSpecRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_spec Override in a subclass to manipulate the request or metadata @@ -1030,8 +1102,10 @@ def post_update_spec(self, response: common_fields.Spec) -> common_fields.Spec: def pre_update_version( self, request: apihub_service.UpdateVersionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.UpdateVersionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apihub_service.UpdateVersionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_version Override in a subclass to manipulate the request or metadata @@ -1053,8 +1127,10 @@ def post_update_version( 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 @@ -1076,8 +1152,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 @@ -1099,8 +1177,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 @@ -1120,8 +1200,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 @@ -1141,8 +1223,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 @@ -1164,8 +1248,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 @@ -1304,7 +1390,7 @@ 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_fields.Api: r"""Call the create api method over HTTP. @@ -1315,8 +1401,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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_fields.Api: @@ -1324,6 +1412,7 @@ def __call__( """ http_options = _BaseApiHubRestTransport._BaseCreateApi._get_http_options() + request, metadata = self._interceptor.pre_create_api(request, metadata) transcoded_request = ( _BaseApiHubRestTransport._BaseCreateApi._get_transcoded_request( @@ -1342,6 +1431,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.CreateApi", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "CreateApi", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._CreateApi._get_response( self._host, @@ -1363,7 +1479,29 @@ def __call__( pb_resp = common_fields.Api.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_api(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = common_fields.Api.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ApiHubClient.create_api", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "CreateApi", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateAttribute( @@ -1401,7 +1539,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common_fields.Attribute: r"""Call the create attribute method over HTTP. @@ -1413,8 +1551,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.common_fields.Attribute: @@ -1431,6 +1571,7 @@ def __call__( http_options = ( _BaseApiHubRestTransport._BaseCreateAttribute._get_http_options() ) + request, metadata = self._interceptor.pre_create_attribute( request, metadata ) @@ -1451,6 +1592,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.CreateAttribute", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "CreateAttribute", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._CreateAttribute._get_response( self._host, @@ -1472,7 +1640,29 @@ def __call__( pb_resp = common_fields.Attribute.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_attribute(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = common_fields.Attribute.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ApiHubClient.create_attribute", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "CreateAttribute", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateDeployment( @@ -1510,7 +1700,7 @@ 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_fields.Deployment: r"""Call the create deployment method over HTTP. @@ -1522,8 +1712,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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_fields.Deployment: @@ -1540,6 +1732,7 @@ def __call__( http_options = ( _BaseApiHubRestTransport._BaseCreateDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_create_deployment( request, metadata ) @@ -1562,6 +1755,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.CreateDeployment", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "CreateDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._CreateDeployment._get_response( self._host, @@ -1583,7 +1803,29 @@ def __call__( pb_resp = common_fields.Deployment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_deployment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = common_fields.Deployment.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ApiHubClient.create_deployment", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "CreateDeployment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateExternalApi( @@ -1621,7 +1863,7 @@ 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_fields.ExternalApi: r"""Call the create external api method over HTTP. @@ -1633,8 +1875,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.common_fields.ExternalApi: @@ -1648,6 +1892,7 @@ def __call__( http_options = ( _BaseApiHubRestTransport._BaseCreateExternalApi._get_http_options() ) + request, metadata = self._interceptor.pre_create_external_api( request, metadata ) @@ -1670,6 +1915,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.CreateExternalApi", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "CreateExternalApi", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._CreateExternalApi._get_response( self._host, @@ -1691,7 +1963,29 @@ def __call__( pb_resp = common_fields.ExternalApi.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_external_api(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = common_fields.ExternalApi.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ApiHubClient.create_external_api", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "CreateExternalApi", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSpec(_BaseApiHubRestTransport._BaseCreateSpec, ApiHubRestStub): @@ -1727,7 +2021,7 @@ 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_fields.Spec: r"""Call the create spec method over HTTP. @@ -1739,8 +2033,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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_fields.Spec: @@ -1753,6 +2049,7 @@ def __call__( """ http_options = _BaseApiHubRestTransport._BaseCreateSpec._get_http_options() + request, metadata = self._interceptor.pre_create_spec(request, metadata) transcoded_request = ( _BaseApiHubRestTransport._BaseCreateSpec._get_transcoded_request( @@ -1771,6 +2068,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.CreateSpec", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "CreateSpec", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._CreateSpec._get_response( self._host, @@ -1792,7 +2116,29 @@ def __call__( pb_resp = common_fields.Spec.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_spec(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = common_fields.Spec.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ApiHubClient.create_spec", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "CreateSpec", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateVersion(_BaseApiHubRestTransport._BaseCreateVersion, ApiHubRestStub): @@ -1828,7 +2174,7 @@ 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_fields.Version: r"""Call the create version method over HTTP. @@ -1840,8 +2186,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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_fields.Version: @@ -1854,6 +2202,7 @@ def __call__( http_options = ( _BaseApiHubRestTransport._BaseCreateVersion._get_http_options() ) + request, metadata = self._interceptor.pre_create_version(request, metadata) transcoded_request = ( _BaseApiHubRestTransport._BaseCreateVersion._get_transcoded_request( @@ -1872,6 +2221,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.CreateVersion", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "CreateVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._CreateVersion._get_response( self._host, @@ -1893,7 +2269,29 @@ def __call__( pb_resp = common_fields.Version.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = common_fields.Version.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ApiHubClient.create_version", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "CreateVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteApi(_BaseApiHubRestTransport._BaseDeleteApi, ApiHubRestStub): @@ -1928,7 +2326,7 @@ 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 api method over HTTP. @@ -1939,11 +2337,14 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = _BaseApiHubRestTransport._BaseDeleteApi._get_http_options() + request, metadata = self._interceptor.pre_delete_api(request, metadata) transcoded_request = ( _BaseApiHubRestTransport._BaseDeleteApi._get_transcoded_request( @@ -1958,6 +2359,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.DeleteApi", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "DeleteApi", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._DeleteApi._get_response( self._host, @@ -2007,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]]] = (), ): r"""Call the delete attribute method over HTTP. @@ -2019,13 +2447,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 = ( _BaseApiHubRestTransport._BaseDeleteAttribute._get_http_options() ) + request, metadata = self._interceptor.pre_delete_attribute( request, metadata ) @@ -2042,6 +2473,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.DeleteAttribute", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "DeleteAttribute", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._DeleteAttribute._get_response( self._host, @@ -2091,7 +2549,7 @@ 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 deployment method over HTTP. @@ -2103,13 +2561,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 = ( _BaseApiHubRestTransport._BaseDeleteDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_delete_deployment( request, metadata ) @@ -2126,6 +2587,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.DeleteDeployment", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "DeleteDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._DeleteDeployment._get_response( self._host, @@ -2175,7 +2663,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete external api method over HTTP. @@ -2187,13 +2675,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 = ( _BaseApiHubRestTransport._BaseDeleteExternalApi._get_http_options() ) + request, metadata = self._interceptor.pre_delete_external_api( request, metadata ) @@ -2210,6 +2701,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.DeleteExternalApi", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "DeleteExternalApi", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._DeleteExternalApi._get_response( self._host, @@ -2257,7 +2775,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete spec method over HTTP. @@ -2269,11 +2787,14 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = _BaseApiHubRestTransport._BaseDeleteSpec._get_http_options() + request, metadata = self._interceptor.pre_delete_spec(request, metadata) transcoded_request = ( _BaseApiHubRestTransport._BaseDeleteSpec._get_transcoded_request( @@ -2288,6 +2809,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.DeleteSpec", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "DeleteSpec", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._DeleteSpec._get_response( self._host, @@ -2335,7 +2883,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete version method over HTTP. @@ -2347,13 +2895,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 = ( _BaseApiHubRestTransport._BaseDeleteVersion._get_http_options() ) + request, metadata = self._interceptor.pre_delete_version(request, metadata) transcoded_request = ( _BaseApiHubRestTransport._BaseDeleteVersion._get_transcoded_request( @@ -2368,6 +2919,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.DeleteVersion", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "DeleteVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._DeleteVersion._get_response( self._host, @@ -2415,7 +2993,7 @@ 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_fields.Api: r"""Call the get api method over HTTP. @@ -2426,8 +3004,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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_fields.Api: @@ -2435,6 +3015,7 @@ def __call__( """ http_options = _BaseApiHubRestTransport._BaseGetApi._get_http_options() + request, metadata = self._interceptor.pre_get_api(request, metadata) transcoded_request = ( _BaseApiHubRestTransport._BaseGetApi._get_transcoded_request( @@ -2447,6 +3028,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.GetApi", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "GetApi", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._GetApi._get_response( self._host, @@ -2467,7 +3075,29 @@ def __call__( pb_resp = common_fields.Api.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_api(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = common_fields.Api.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ApiHubClient.get_api", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "GetApi", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetApiOperation( @@ -2504,7 +3134,7 @@ 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_fields.ApiOperation: r"""Call the get api operation method over HTTP. @@ -2516,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: ~.common_fields.ApiOperation: @@ -2536,6 +3168,7 @@ def __call__( http_options = ( _BaseApiHubRestTransport._BaseGetApiOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_api_operation( request, metadata ) @@ -2552,6 +3185,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.GetApiOperation", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "GetApiOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._GetApiOperation._get_response( self._host, @@ -2572,7 +3232,29 @@ def __call__( pb_resp = common_fields.ApiOperation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_api_operation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = common_fields.ApiOperation.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ApiHubClient.get_api_operation", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "GetApiOperation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAttribute(_BaseApiHubRestTransport._BaseGetAttribute, ApiHubRestStub): @@ -2607,7 +3289,7 @@ 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_fields.Attribute: r"""Call the get attribute method over HTTP. @@ -2619,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: ~.common_fields.Attribute: @@ -2637,6 +3321,7 @@ def __call__( http_options = ( _BaseApiHubRestTransport._BaseGetAttribute._get_http_options() ) + request, metadata = self._interceptor.pre_get_attribute(request, metadata) transcoded_request = ( _BaseApiHubRestTransport._BaseGetAttribute._get_transcoded_request( @@ -2651,6 +3336,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.GetAttribute", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "GetAttribute", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._GetAttribute._get_response( self._host, @@ -2671,7 +3383,29 @@ def __call__( pb_resp = common_fields.Attribute.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_attribute(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = common_fields.Attribute.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ApiHubClient.get_attribute", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "GetAttribute", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDefinition(_BaseApiHubRestTransport._BaseGetDefinition, ApiHubRestStub): @@ -2706,7 +3440,7 @@ 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_fields.Definition: r"""Call the get definition method over HTTP. @@ -2718,8 +3452,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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_fields.Definition: @@ -2737,6 +3473,7 @@ def __call__( http_options = ( _BaseApiHubRestTransport._BaseGetDefinition._get_http_options() ) + request, metadata = self._interceptor.pre_get_definition(request, metadata) transcoded_request = ( _BaseApiHubRestTransport._BaseGetDefinition._get_transcoded_request( @@ -2751,6 +3488,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.GetDefinition", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "GetDefinition", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._GetDefinition._get_response( self._host, @@ -2771,7 +3535,29 @@ def __call__( pb_resp = common_fields.Definition.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_definition(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = common_fields.Definition.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ApiHubClient.get_definition", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "GetDefinition", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDeployment(_BaseApiHubRestTransport._BaseGetDeployment, ApiHubRestStub): @@ -2806,7 +3592,7 @@ 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_fields.Deployment: r"""Call the get deployment method over HTTP. @@ -2818,8 +3604,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.common_fields.Deployment: @@ -2836,6 +3624,7 @@ def __call__( http_options = ( _BaseApiHubRestTransport._BaseGetDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_get_deployment(request, metadata) transcoded_request = ( _BaseApiHubRestTransport._BaseGetDeployment._get_transcoded_request( @@ -2850,6 +3639,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.GetDeployment", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "GetDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._GetDeployment._get_response( self._host, @@ -2870,7 +3686,29 @@ def __call__( pb_resp = common_fields.Deployment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_deployment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = common_fields.Deployment.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ApiHubClient.get_deployment", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "GetDeployment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetExternalApi(_BaseApiHubRestTransport._BaseGetExternalApi, ApiHubRestStub): @@ -2905,7 +3743,7 @@ 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_fields.ExternalApi: r"""Call the get external api method over HTTP. @@ -2917,8 +3755,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.common_fields.ExternalApi: @@ -2932,6 +3772,7 @@ def __call__( http_options = ( _BaseApiHubRestTransport._BaseGetExternalApi._get_http_options() ) + request, metadata = self._interceptor.pre_get_external_api( request, metadata ) @@ -2948,6 +3789,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.GetExternalApi", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "GetExternalApi", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._GetExternalApi._get_response( self._host, @@ -2968,7 +3836,29 @@ def __call__( pb_resp = common_fields.ExternalApi.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_external_api(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = common_fields.ExternalApi.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ApiHubClient.get_external_api", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "GetExternalApi", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSpec(_BaseApiHubRestTransport._BaseGetSpec, ApiHubRestStub): @@ -3003,7 +3893,7 @@ 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_fields.Spec: r"""Call the get spec method over HTTP. @@ -3014,8 +3904,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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_fields.Spec: @@ -3028,6 +3920,7 @@ def __call__( """ http_options = _BaseApiHubRestTransport._BaseGetSpec._get_http_options() + request, metadata = self._interceptor.pre_get_spec(request, metadata) transcoded_request = ( _BaseApiHubRestTransport._BaseGetSpec._get_transcoded_request( @@ -3040,6 +3933,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.GetSpec", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "GetSpec", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._GetSpec._get_response( self._host, @@ -3060,7 +3980,29 @@ def __call__( pb_resp = common_fields.Spec.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_spec(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = common_fields.Spec.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ApiHubClient.get_spec", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "GetSpec", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSpecContents( @@ -3097,7 +4039,7 @@ 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_fields.SpecContents: r"""Call the get spec contents method over HTTP. @@ -3109,8 +4051,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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_fields.SpecContents: @@ -3120,6 +4064,7 @@ def __call__( http_options = ( _BaseApiHubRestTransport._BaseGetSpecContents._get_http_options() ) + request, metadata = self._interceptor.pre_get_spec_contents( request, metadata ) @@ -3136,6 +4081,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.GetSpecContents", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "GetSpecContents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._GetSpecContents._get_response( self._host, @@ -3156,7 +4128,29 @@ def __call__( pb_resp = common_fields.SpecContents.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_spec_contents(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = common_fields.SpecContents.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ApiHubClient.get_spec_contents", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "GetSpecContents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetVersion(_BaseApiHubRestTransport._BaseGetVersion, ApiHubRestStub): @@ -3191,7 +4185,7 @@ 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_fields.Version: r"""Call the get version method over HTTP. @@ -3203,8 +4197,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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_fields.Version: @@ -3215,6 +4211,7 @@ def __call__( """ http_options = _BaseApiHubRestTransport._BaseGetVersion._get_http_options() + request, metadata = self._interceptor.pre_get_version(request, metadata) transcoded_request = ( _BaseApiHubRestTransport._BaseGetVersion._get_transcoded_request( @@ -3229,6 +4226,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.GetVersion", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "GetVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._GetVersion._get_response( self._host, @@ -3249,7 +4273,29 @@ def __call__( pb_resp = common_fields.Version.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = common_fields.Version.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ApiHubClient.get_version", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "GetVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListApiOperations( @@ -3286,7 +4332,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apihub_service.ListApiOperationsResponse: r"""Call the list api operations method over HTTP. @@ -3298,8 +4344,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.apihub_service.ListApiOperationsResponse: @@ -3312,6 +4360,7 @@ def __call__( http_options = ( _BaseApiHubRestTransport._BaseListApiOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_api_operations( request, metadata ) @@ -3328,6 +4377,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.ListApiOperations", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "ListApiOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._ListApiOperations._get_response( self._host, @@ -3348,7 +4424,31 @@ def __call__( pb_resp = apihub_service.ListApiOperationsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_api_operations(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = apihub_service.ListApiOperationsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ApiHubClient.list_api_operations", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "ListApiOperations", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListApis(_BaseApiHubRestTransport._BaseListApis, ApiHubRestStub): @@ -3383,7 +4483,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apihub_service.ListApisResponse: r"""Call the list apis method over HTTP. @@ -3394,8 +4494,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.apihub_service.ListApisResponse: @@ -3405,6 +4507,7 @@ def __call__( """ http_options = _BaseApiHubRestTransport._BaseListApis._get_http_options() + request, metadata = self._interceptor.pre_list_apis(request, metadata) transcoded_request = ( _BaseApiHubRestTransport._BaseListApis._get_transcoded_request( @@ -3419,6 +4522,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.ListApis", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "ListApis", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._ListApis._get_response( self._host, @@ -3439,7 +4569,29 @@ def __call__( pb_resp = apihub_service.ListApisResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_apis(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = apihub_service.ListApisResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ApiHubClient.list_apis", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "ListApis", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAttributes(_BaseApiHubRestTransport._BaseListAttributes, ApiHubRestStub): @@ -3474,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]]] = (), ) -> apihub_service.ListAttributesResponse: r"""Call the list attributes method over HTTP. @@ -3486,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: ~.apihub_service.ListAttributesResponse: @@ -3500,6 +4654,7 @@ def __call__( http_options = ( _BaseApiHubRestTransport._BaseListAttributes._get_http_options() ) + request, metadata = self._interceptor.pre_list_attributes(request, metadata) transcoded_request = ( _BaseApiHubRestTransport._BaseListAttributes._get_transcoded_request( @@ -3514,6 +4669,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.ListAttributes", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "ListAttributes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._ListAttributes._get_response( self._host, @@ -3534,7 +4716,31 @@ def __call__( pb_resp = apihub_service.ListAttributesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_attributes(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = apihub_service.ListAttributesResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ApiHubClient.list_attributes", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "ListAttributes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDeployments( @@ -3571,7 +4777,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apihub_service.ListDeploymentsResponse: r"""Call the list deployments method over HTTP. @@ -3583,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: ~.apihub_service.ListDeploymentsResponse: @@ -3597,6 +4805,7 @@ def __call__( http_options = ( _BaseApiHubRestTransport._BaseListDeployments._get_http_options() ) + request, metadata = self._interceptor.pre_list_deployments( request, metadata ) @@ -3613,6 +4822,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.ListDeployments", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "ListDeployments", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._ListDeployments._get_response( self._host, @@ -3633,7 +4869,31 @@ def __call__( pb_resp = apihub_service.ListDeploymentsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_deployments(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = apihub_service.ListDeploymentsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ApiHubClient.list_deployments", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "ListDeployments", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListExternalApis( @@ -3670,7 +4930,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apihub_service.ListExternalApisResponse: r"""Call the list external apis method over HTTP. @@ -3682,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: ~.apihub_service.ListExternalApisResponse: @@ -3696,6 +4958,7 @@ def __call__( http_options = ( _BaseApiHubRestTransport._BaseListExternalApis._get_http_options() ) + request, metadata = self._interceptor.pre_list_external_apis( request, metadata ) @@ -3712,6 +4975,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.ListExternalApis", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "ListExternalApis", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._ListExternalApis._get_response( self._host, @@ -3732,7 +5022,31 @@ def __call__( pb_resp = apihub_service.ListExternalApisResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_external_apis(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = apihub_service.ListExternalApisResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ApiHubClient.list_external_apis", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "ListExternalApis", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSpecs(_BaseApiHubRestTransport._BaseListSpecs, ApiHubRestStub): @@ -3767,7 +5081,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apihub_service.ListSpecsResponse: r"""Call the list specs method over HTTP. @@ -3777,8 +5091,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.apihub_service.ListSpecsResponse: @@ -3788,6 +5104,7 @@ def __call__( """ http_options = _BaseApiHubRestTransport._BaseListSpecs._get_http_options() + request, metadata = self._interceptor.pre_list_specs(request, metadata) transcoded_request = ( _BaseApiHubRestTransport._BaseListSpecs._get_transcoded_request( @@ -3802,6 +5119,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.ListSpecs", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "ListSpecs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._ListSpecs._get_response( self._host, @@ -3822,7 +5166,31 @@ def __call__( pb_resp = apihub_service.ListSpecsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_specs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = apihub_service.ListSpecsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ApiHubClient.list_specs", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "ListSpecs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListVersions(_BaseApiHubRestTransport._BaseListVersions, ApiHubRestStub): @@ -3857,7 +5225,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apihub_service.ListVersionsResponse: r"""Call the list versions method over HTTP. @@ -3869,8 +5237,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.apihub_service.ListVersionsResponse: @@ -3883,6 +5253,7 @@ def __call__( http_options = ( _BaseApiHubRestTransport._BaseListVersions._get_http_options() ) + request, metadata = self._interceptor.pre_list_versions(request, metadata) transcoded_request = ( _BaseApiHubRestTransport._BaseListVersions._get_transcoded_request( @@ -3897,6 +5268,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.ListVersions", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "ListVersions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._ListVersions._get_response( self._host, @@ -3917,7 +5315,31 @@ def __call__( pb_resp = apihub_service.ListVersionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_versions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = apihub_service.ListVersionsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ApiHubClient.list_versions", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "ListVersions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchResources( @@ -3955,7 +5377,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apihub_service.SearchResourcesResponse: r"""Call the search resources method over HTTP. @@ -3967,8 +5389,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.apihub_service.SearchResourcesResponse: @@ -3981,6 +5405,7 @@ def __call__( http_options = ( _BaseApiHubRestTransport._BaseSearchResources._get_http_options() ) + request, metadata = self._interceptor.pre_search_resources( request, metadata ) @@ -4001,6 +5426,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.SearchResources", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "SearchResources", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._SearchResources._get_response( self._host, @@ -4022,7 +5474,31 @@ def __call__( pb_resp = apihub_service.SearchResourcesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_resources(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = apihub_service.SearchResourcesResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ApiHubClient.search_resources", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "SearchResources", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateApi(_BaseApiHubRestTransport._BaseUpdateApi, ApiHubRestStub): @@ -4058,7 +5534,7 @@ 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_fields.Api: r"""Call the update api method over HTTP. @@ -4069,8 +5545,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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_fields.Api: @@ -4078,6 +5556,7 @@ def __call__( """ http_options = _BaseApiHubRestTransport._BaseUpdateApi._get_http_options() + request, metadata = self._interceptor.pre_update_api(request, metadata) transcoded_request = ( _BaseApiHubRestTransport._BaseUpdateApi._get_transcoded_request( @@ -4096,6 +5575,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.UpdateApi", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "UpdateApi", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._UpdateApi._get_response( self._host, @@ -4117,7 +5623,29 @@ def __call__( pb_resp = common_fields.Api.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_api(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = common_fields.Api.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ApiHubClient.update_api", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "UpdateApi", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateAttribute( @@ -4155,7 +5683,7 @@ 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_fields.Attribute: r"""Call the update attribute method over HTTP. @@ -4167,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: ~.common_fields.Attribute: @@ -4185,6 +5715,7 @@ def __call__( http_options = ( _BaseApiHubRestTransport._BaseUpdateAttribute._get_http_options() ) + request, metadata = self._interceptor.pre_update_attribute( request, metadata ) @@ -4205,6 +5736,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.UpdateAttribute", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "UpdateAttribute", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._UpdateAttribute._get_response( self._host, @@ -4226,7 +5784,29 @@ def __call__( pb_resp = common_fields.Attribute.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_attribute(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = common_fields.Attribute.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ApiHubClient.update_attribute", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "UpdateAttribute", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateDeployment( @@ -4264,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]]] = (), ) -> common_fields.Deployment: r"""Call the update deployment method over HTTP. @@ -4276,8 +5856,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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_fields.Deployment: @@ -4294,6 +5876,7 @@ def __call__( http_options = ( _BaseApiHubRestTransport._BaseUpdateDeployment._get_http_options() ) + request, metadata = self._interceptor.pre_update_deployment( request, metadata ) @@ -4316,6 +5899,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.UpdateDeployment", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "UpdateDeployment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._UpdateDeployment._get_response( self._host, @@ -4337,7 +5947,29 @@ def __call__( pb_resp = common_fields.Deployment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_deployment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = common_fields.Deployment.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ApiHubClient.update_deployment", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "UpdateDeployment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateExternalApi( @@ -4375,7 +6007,7 @@ 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_fields.ExternalApi: r"""Call the update external api method over HTTP. @@ -4387,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: ~.common_fields.ExternalApi: @@ -4402,6 +6036,7 @@ def __call__( http_options = ( _BaseApiHubRestTransport._BaseUpdateExternalApi._get_http_options() ) + request, metadata = self._interceptor.pre_update_external_api( request, metadata ) @@ -4424,6 +6059,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.UpdateExternalApi", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "UpdateExternalApi", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._UpdateExternalApi._get_response( self._host, @@ -4445,7 +6107,29 @@ def __call__( pb_resp = common_fields.ExternalApi.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_external_api(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = common_fields.ExternalApi.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ApiHubClient.update_external_api", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "UpdateExternalApi", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSpec(_BaseApiHubRestTransport._BaseUpdateSpec, ApiHubRestStub): @@ -4481,7 +6165,7 @@ 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_fields.Spec: r"""Call the update spec method over HTTP. @@ -4493,8 +6177,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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_fields.Spec: @@ -4507,6 +6193,7 @@ def __call__( """ http_options = _BaseApiHubRestTransport._BaseUpdateSpec._get_http_options() + request, metadata = self._interceptor.pre_update_spec(request, metadata) transcoded_request = ( _BaseApiHubRestTransport._BaseUpdateSpec._get_transcoded_request( @@ -4525,6 +6212,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.UpdateSpec", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "UpdateSpec", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._UpdateSpec._get_response( self._host, @@ -4546,7 +6260,29 @@ def __call__( pb_resp = common_fields.Spec.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_spec(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = common_fields.Spec.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ApiHubClient.update_spec", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "UpdateSpec", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateVersion(_BaseApiHubRestTransport._BaseUpdateVersion, ApiHubRestStub): @@ -4582,7 +6318,7 @@ 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_fields.Version: r"""Call the update version method over HTTP. @@ -4594,8 +6330,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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_fields.Version: @@ -4608,6 +6346,7 @@ def __call__( http_options = ( _BaseApiHubRestTransport._BaseUpdateVersion._get_http_options() ) + request, metadata = self._interceptor.pre_update_version(request, metadata) transcoded_request = ( _BaseApiHubRestTransport._BaseUpdateVersion._get_transcoded_request( @@ -4626,6 +6365,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.UpdateVersion", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "UpdateVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._UpdateVersion._get_response( self._host, @@ -4647,7 +6413,29 @@ def __call__( pb_resp = common_fields.Version.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = common_fields.Version.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ApiHubClient.update_version", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "UpdateVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -4976,7 +6764,7 @@ 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. @@ -4986,14 +6774,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 = _BaseApiHubRestTransport._BaseGetLocation._get_http_options() + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseApiHubRestTransport._BaseGetLocation._get_transcoded_request( @@ -5008,6 +6799,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.GetLocation", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._GetLocation._get_response( self._host, @@ -5027,6 +6845,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.apihub_v1.ApiHubAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -5065,7 +6904,7 @@ 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. @@ -5075,8 +6914,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -5085,6 +6926,7 @@ def __call__( http_options = ( _BaseApiHubRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = ( _BaseApiHubRestTransport._BaseListLocations._get_transcoded_request( @@ -5099,6 +6941,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.ListLocations", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._ListLocations._get_response( self._host, @@ -5118,6 +6987,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.apihub_v1.ApiHubAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -5159,7 +7049,7 @@ 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. @@ -5169,13 +7059,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 = ( _BaseApiHubRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -5196,6 +7089,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.CancelOperation", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._CancelOperation._get_response( self._host, @@ -5252,7 +7172,7 @@ 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. @@ -5262,13 +7182,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 = ( _BaseApiHubRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -5285,6 +7208,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._DeleteOperation._get_response( self._host, @@ -5338,7 +7288,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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. @@ -5348,8 +7298,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -5358,6 +7310,7 @@ def __call__( http_options = ( _BaseApiHubRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseApiHubRestTransport._BaseGetOperation._get_transcoded_request( @@ -5372,6 +7325,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.GetOperation", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._GetOperation._get_response( self._host, @@ -5391,6 +7371,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.apihub_v1.ApiHubAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -5429,7 +7430,7 @@ def __call__( *, 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. @@ -5439,8 +7440,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must 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. @@ -5449,6 +7452,7 @@ def __call__( http_options = ( _BaseApiHubRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = ( _BaseApiHubRestTransport._BaseListOperations._get_transcoded_request( @@ -5463,6 +7467,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubClient.ListOperations", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubRestTransport._ListOperations._get_response( self._host, @@ -5482,6 +7513,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.apihub_v1.ApiHubAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHub", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-apihub/google/cloud/apihub_v1/services/api_hub_dependencies/client.py b/packages/google-cloud-apihub/google/cloud/apihub_v1/services/api_hub_dependencies/client.py index 64a45030eb07..ed70b2364c1d 100644 --- a/packages/google-cloud-apihub/google/cloud/apihub_v1/services/api_hub_dependencies/client.py +++ b/packages/google-cloud-apihub/google/cloud/apihub_v1/services/api_hub_dependencies/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -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( @@ -675,6 +689,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.apihub_v1.ApiHubDependenciesClient`.", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHubDependencies", + "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.apihub.v1.ApiHubDependencies", + "credentialsType": None, + }, + ) + def create_dependency( self, request: Optional[Union[apihub_service.CreateDependencyRequest, dict]] = None, @@ -684,7 +721,7 @@ def create_dependency( dependency_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]]] = (), ) -> common_fields.Dependency: r"""Create a dependency between two entities in the API hub. @@ -759,8 +796,10 @@ def sample_create_dependency(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.types.Dependency: @@ -827,7 +866,7 @@ def get_dependency( name: Optional[str] = None, retry: OptionalRetry = 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_fields.Dependency: r"""Get details about a dependency resource in the API hub. @@ -873,8 +912,10 @@ def sample_get_dependency(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.types.Dependency: @@ -938,7 +979,7 @@ def update_dependency( 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]]] = (), ) -> common_fields.Dependency: r"""Update a dependency based on the [update_mask][google.cloud.apihub.v1.UpdateDependencyRequest.update_mask] @@ -1004,8 +1045,10 @@ def sample_update_dependency(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.types.Dependency: @@ -1072,7 +1115,7 @@ def delete_dependency( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Delete the dependency resource. @@ -1115,8 +1158,10 @@ def sample_delete_dependency(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -1165,7 +1210,7 @@ def list_dependencies( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDependenciesPager: r"""List dependencies based on the provided filter and pagination parameters. @@ -1213,8 +1258,10 @@ def sample_list_dependencies(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.services.api_hub_dependencies.pagers.ListDependenciesPager: @@ -1299,7 +1346,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. @@ -1310,8 +1357,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. @@ -1352,7 +1401,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. @@ -1363,8 +1412,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. @@ -1405,7 +1456,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. @@ -1421,8 +1472,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 """ @@ -1459,7 +1512,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. @@ -1474,8 +1527,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 """ @@ -1512,7 +1567,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. @@ -1523,8 +1578,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. @@ -1565,7 +1622,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. @@ -1576,8 +1633,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-apihub/google/cloud/apihub_v1/services/api_hub_dependencies/pagers.py b/packages/google-cloud-apihub/google/cloud/apihub_v1/services/api_hub_dependencies/pagers.py index 6f0fa634f84d..3521cfeb19e6 100644 --- a/packages/google-cloud-apihub/google/cloud/apihub_v1/services/api_hub_dependencies/pagers.py +++ b/packages/google-cloud-apihub/google/cloud/apihub_v1/services/api_hub_dependencies/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 = apihub_service.ListDependenciesRequest(request) diff --git a/packages/google-cloud-apihub/google/cloud/apihub_v1/services/api_hub_dependencies/transports/rest.py b/packages/google-cloud-apihub/google/cloud/apihub_v1/services/api_hub_dependencies/transports/rest.py index 34b96e739576..d283dbab1a25 100644 --- a/packages/google-cloud-apihub/google/cloud/apihub_v1/services/api_hub_dependencies/transports/rest.py +++ b/packages/google-cloud-apihub/google/cloud/apihub_v1/services/api_hub_dependencies/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, @@ -108,8 +116,10 @@ def post_update_dependency(self, response): def pre_create_dependency( self, request: apihub_service.CreateDependencyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.CreateDependencyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apihub_service.CreateDependencyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_dependency Override in a subclass to manipulate the request or metadata @@ -131,8 +141,10 @@ def post_create_dependency( def pre_delete_dependency( self, request: apihub_service.DeleteDependencyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.DeleteDependencyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apihub_service.DeleteDependencyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_dependency Override in a subclass to manipulate the request or metadata @@ -143,8 +155,10 @@ def pre_delete_dependency( def pre_get_dependency( self, request: apihub_service.GetDependencyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.GetDependencyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apihub_service.GetDependencyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_dependency Override in a subclass to manipulate the request or metadata @@ -166,8 +180,10 @@ def post_get_dependency( def pre_list_dependencies( self, request: apihub_service.ListDependenciesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.ListDependenciesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apihub_service.ListDependenciesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_dependencies Override in a subclass to manipulate the request or metadata @@ -189,8 +205,10 @@ def post_list_dependencies( def pre_update_dependency( self, request: apihub_service.UpdateDependencyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apihub_service.UpdateDependencyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apihub_service.UpdateDependencyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_dependency Override in a subclass to manipulate the request or metadata @@ -212,8 +230,10 @@ def post_update_dependency( 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 @@ -235,8 +255,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 @@ -258,8 +280,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 @@ -279,8 +303,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 @@ -300,8 +326,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 @@ -323,8 +351,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 @@ -467,7 +497,7 @@ 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_fields.Dependency: r"""Call the create dependency method over HTTP. @@ -479,8 +509,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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_fields.Dependency: @@ -496,6 +528,7 @@ def __call__( http_options = ( _BaseApiHubDependenciesRestTransport._BaseCreateDependency._get_http_options() ) + request, metadata = self._interceptor.pre_create_dependency( request, metadata ) @@ -512,6 +545,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubDependenciesClient.CreateDependency", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHubDependencies", + "rpcName": "CreateDependency", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubDependenciesRestTransport._CreateDependency._get_response( self._host, @@ -533,7 +593,29 @@ def __call__( pb_resp = common_fields.Dependency.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_dependency(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = common_fields.Dependency.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ApiHubDependenciesClient.create_dependency", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHubDependencies", + "rpcName": "CreateDependency", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteDependency( @@ -571,7 +653,7 @@ 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 dependency method over HTTP. @@ -583,13 +665,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 = ( _BaseApiHubDependenciesRestTransport._BaseDeleteDependency._get_http_options() ) + request, metadata = self._interceptor.pre_delete_dependency( request, metadata ) @@ -602,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.apihub_v1.ApiHubDependenciesClient.DeleteDependency", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHubDependencies", + "rpcName": "DeleteDependency", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubDependenciesRestTransport._DeleteDependency._get_response( self._host, @@ -652,7 +764,7 @@ 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_fields.Dependency: r"""Call the get dependency method over HTTP. @@ -663,8 +775,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.common_fields.Dependency: @@ -680,6 +794,7 @@ def __call__( http_options = ( _BaseApiHubDependenciesRestTransport._BaseGetDependency._get_http_options() ) + request, metadata = self._interceptor.pre_get_dependency(request, metadata) transcoded_request = _BaseApiHubDependenciesRestTransport._BaseGetDependency._get_transcoded_request( http_options, request @@ -690,6 +805,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubDependenciesClient.GetDependency", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHubDependencies", + "rpcName": "GetDependency", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubDependenciesRestTransport._GetDependency._get_response( self._host, @@ -710,7 +852,29 @@ def __call__( pb_resp = common_fields.Dependency.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_dependency(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = common_fields.Dependency.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ApiHubDependenciesClient.get_dependency", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHubDependencies", + "rpcName": "GetDependency", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDependencies( @@ -748,7 +912,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apihub_service.ListDependenciesResponse: r"""Call the list dependencies method over HTTP. @@ -760,8 +924,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.apihub_service.ListDependenciesResponse: @@ -774,6 +940,7 @@ def __call__( http_options = ( _BaseApiHubDependenciesRestTransport._BaseListDependencies._get_http_options() ) + request, metadata = self._interceptor.pre_list_dependencies( request, metadata ) @@ -786,6 +953,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubDependenciesClient.ListDependencies", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHubDependencies", + "rpcName": "ListDependencies", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubDependenciesRestTransport._ListDependencies._get_response( self._host, @@ -806,7 +1000,31 @@ def __call__( pb_resp = apihub_service.ListDependenciesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_dependencies(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = apihub_service.ListDependenciesResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ApiHubDependenciesClient.list_dependencies", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHubDependencies", + "rpcName": "ListDependencies", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateDependency( @@ -845,7 +1063,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> common_fields.Dependency: r"""Call the update dependency method over HTTP. @@ -857,8 +1075,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.common_fields.Dependency: @@ -874,6 +1094,7 @@ def __call__( http_options = ( _BaseApiHubDependenciesRestTransport._BaseUpdateDependency._get_http_options() ) + request, metadata = self._interceptor.pre_update_dependency( request, metadata ) @@ -890,6 +1111,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubDependenciesClient.UpdateDependency", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHubDependencies", + "rpcName": "UpdateDependency", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubDependenciesRestTransport._UpdateDependency._get_response( self._host, @@ -911,7 +1159,29 @@ def __call__( pb_resp = common_fields.Dependency.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_dependency(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = common_fields.Dependency.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ApiHubDependenciesClient.update_dependency", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHubDependencies", + "rpcName": "UpdateDependency", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -996,7 +1266,7 @@ 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. @@ -1006,8 +1276,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -1016,6 +1288,7 @@ def __call__( http_options = ( _BaseApiHubDependenciesRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseApiHubDependenciesRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -1026,6 +1299,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubDependenciesClient.GetLocation", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHubDependencies", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubDependenciesRestTransport._GetLocation._get_response( self._host, @@ -1045,6 +1345,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.apihub_v1.ApiHubDependenciesAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHubDependencies", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1086,7 +1407,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -1096,8 +1417,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -1106,6 +1429,7 @@ def __call__( http_options = ( _BaseApiHubDependenciesRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseApiHubDependenciesRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -1116,6 +1440,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubDependenciesClient.ListLocations", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHubDependencies", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubDependenciesRestTransport._ListLocations._get_response( self._host, @@ -1135,6 +1486,27 @@ def __call__( resp = locations_pb2.ListLocationsResponse() resp = json_format.Parse(content, resp) resp = self._interceptor.post_list_locations(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ApiHubDependenciesAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHubDependencies", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1177,7 +1549,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1187,13 +1559,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 = ( _BaseApiHubDependenciesRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1210,6 +1585,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubDependenciesClient.CancelOperation", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHubDependencies", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubDependenciesRestTransport._CancelOperation._get_response( self._host, @@ -1267,7 +1669,7 @@ 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. @@ -1277,13 +1679,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 = ( _BaseApiHubDependenciesRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -1296,6 +1701,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubDependenciesClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHubDependencies", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubDependenciesRestTransport._DeleteOperation._get_response( self._host, @@ -1352,7 +1784,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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. @@ -1362,8 +1794,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -1372,6 +1806,7 @@ def __call__( http_options = ( _BaseApiHubDependenciesRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseApiHubDependenciesRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1382,6 +1817,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubDependenciesClient.GetOperation", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHubDependencies", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubDependenciesRestTransport._GetOperation._get_response( self._host, @@ -1401,6 +1863,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.apihub_v1.ApiHubDependenciesAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHubDependencies", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1442,7 +1925,7 @@ def __call__( *, 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. @@ -1452,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.ListOperationsResponse: Response from ListOperations method. @@ -1462,6 +1947,7 @@ def __call__( http_options = ( _BaseApiHubDependenciesRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseApiHubDependenciesRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1472,6 +1958,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubDependenciesClient.ListOperations", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHubDependencies", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubDependenciesRestTransport._ListOperations._get_response( self._host, @@ -1491,6 +2004,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.apihub_v1.ApiHubDependenciesAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHubDependencies", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-apihub/google/cloud/apihub_v1/services/api_hub_plugin/client.py b/packages/google-cloud-apihub/google/cloud/apihub_v1/services/api_hub_plugin/client.py index f4cebeb8cb2f..4d6b0b55a5af 100644 --- a/packages/google-cloud-apihub/google/cloud/apihub_v1/services/api_hub_plugin/client.py +++ b/packages/google-cloud-apihub/google/cloud/apihub_v1/services/api_hub_plugin/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore @@ -596,6 +606,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -658,6 +672,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.apihub_v1.ApiHubPluginClient`.", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHubPlugin", + "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.apihub.v1.ApiHubPlugin", + "credentialsType": None, + }, + ) + def get_plugin( self, request: Optional[Union[plugin_service.GetPluginRequest, dict]] = None, @@ -665,7 +702,7 @@ def get_plugin( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> plugin_service.Plugin: r"""Get details about an API Hub plugin. @@ -710,8 +747,10 @@ def sample_get_plugin(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.types.Plugin: @@ -767,7 +806,7 @@ def enable_plugin( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> plugin_service.Plugin: r"""Enables a plugin. The ``state`` of the plugin after enabling is ``ENABLED`` @@ -813,8 +852,10 @@ def sample_enable_plugin(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.types.Plugin: @@ -870,7 +911,7 @@ def disable_plugin( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> plugin_service.Plugin: r"""Disables a plugin. The ``state`` of the plugin after disabling is ``DISABLED`` @@ -916,8 +957,10 @@ def sample_disable_plugin(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.types.Plugin: @@ -985,7 +1028,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. @@ -996,8 +1039,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. @@ -1038,7 +1083,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. @@ -1049,8 +1094,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. @@ -1091,7 +1138,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. @@ -1107,8 +1154,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 """ @@ -1145,7 +1194,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. @@ -1160,8 +1209,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 """ @@ -1198,7 +1249,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. @@ -1209,8 +1260,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. @@ -1251,7 +1304,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. @@ -1262,8 +1315,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-apihub/google/cloud/apihub_v1/services/api_hub_plugin/transports/rest.py b/packages/google-cloud-apihub/google/cloud/apihub_v1/services/api_hub_plugin/transports/rest.py index 7ca28737f7de..3e6fcd8fed38 100644 --- a/packages/google-cloud-apihub/google/cloud/apihub_v1/services/api_hub_plugin/transports/rest.py +++ b/packages/google-cloud-apihub/google/cloud/apihub_v1/services/api_hub_plugin/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, @@ -95,8 +103,10 @@ def post_get_plugin(self, response): def pre_disable_plugin( self, request: plugin_service.DisablePluginRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[plugin_service.DisablePluginRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + plugin_service.DisablePluginRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for disable_plugin Override in a subclass to manipulate the request or metadata @@ -118,8 +128,10 @@ def post_disable_plugin( def pre_enable_plugin( self, request: plugin_service.EnablePluginRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[plugin_service.EnablePluginRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + plugin_service.EnablePluginRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for enable_plugin Override in a subclass to manipulate the request or metadata @@ -141,8 +153,10 @@ def post_enable_plugin( def pre_get_plugin( self, request: plugin_service.GetPluginRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[plugin_service.GetPluginRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + plugin_service.GetPluginRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_plugin Override in a subclass to manipulate the request or metadata @@ -162,8 +176,10 @@ def post_get_plugin(self, response: plugin_service.Plugin) -> plugin_service.Plu 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 @@ -185,8 +201,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 @@ -208,8 +226,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 @@ -229,8 +249,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 @@ -250,8 +272,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 @@ -273,8 +297,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 @@ -415,7 +441,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> plugin_service.Plugin: r"""Call the disable plugin method over HTTP. @@ -427,8 +453,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.plugin_service.Plugin: @@ -438,6 +466,7 @@ def __call__( http_options = ( _BaseApiHubPluginRestTransport._BaseDisablePlugin._get_http_options() ) + request, metadata = self._interceptor.pre_disable_plugin(request, metadata) transcoded_request = _BaseApiHubPluginRestTransport._BaseDisablePlugin._get_transcoded_request( http_options, request @@ -452,6 +481,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubPluginClient.DisablePlugin", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHubPlugin", + "rpcName": "DisablePlugin", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubPluginRestTransport._DisablePlugin._get_response( self._host, @@ -473,7 +529,29 @@ def __call__( pb_resp = plugin_service.Plugin.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_disable_plugin(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = plugin_service.Plugin.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ApiHubPluginClient.disable_plugin", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHubPlugin", + "rpcName": "DisablePlugin", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _EnablePlugin( @@ -511,7 +589,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> plugin_service.Plugin: r"""Call the enable plugin method over HTTP. @@ -523,8 +601,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.plugin_service.Plugin: @@ -534,6 +614,7 @@ def __call__( http_options = ( _BaseApiHubPluginRestTransport._BaseEnablePlugin._get_http_options() ) + request, metadata = self._interceptor.pre_enable_plugin(request, metadata) transcoded_request = _BaseApiHubPluginRestTransport._BaseEnablePlugin._get_transcoded_request( http_options, request @@ -552,6 +633,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubPluginClient.EnablePlugin", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHubPlugin", + "rpcName": "EnablePlugin", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubPluginRestTransport._EnablePlugin._get_response( self._host, @@ -573,7 +681,29 @@ def __call__( pb_resp = plugin_service.Plugin.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_enable_plugin(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = plugin_service.Plugin.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ApiHubPluginClient.enable_plugin", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHubPlugin", + "rpcName": "EnablePlugin", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetPlugin( @@ -610,7 +740,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> plugin_service.Plugin: r"""Call the get plugin method over HTTP. @@ -622,8 +752,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.plugin_service.Plugin: @@ -633,6 +765,7 @@ def __call__( http_options = ( _BaseApiHubPluginRestTransport._BaseGetPlugin._get_http_options() ) + request, metadata = self._interceptor.pre_get_plugin(request, metadata) transcoded_request = ( _BaseApiHubPluginRestTransport._BaseGetPlugin._get_transcoded_request( @@ -647,6 +780,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubPluginClient.GetPlugin", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHubPlugin", + "rpcName": "GetPlugin", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubPluginRestTransport._GetPlugin._get_response( self._host, @@ -667,7 +827,29 @@ def __call__( pb_resp = plugin_service.Plugin.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_plugin(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = plugin_service.Plugin.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ApiHubPluginClient.get_plugin", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHubPlugin", + "rpcName": "GetPlugin", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -732,7 +914,7 @@ 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. @@ -742,8 +924,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -752,6 +936,7 @@ def __call__( http_options = ( _BaseApiHubPluginRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseApiHubPluginRestTransport._BaseGetLocation._get_transcoded_request( @@ -766,6 +951,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubPluginClient.GetLocation", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHubPlugin", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubPluginRestTransport._GetLocation._get_response( self._host, @@ -785,6 +997,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.apihub_v1.ApiHubPluginAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHubPlugin", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -825,7 +1058,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -835,8 +1068,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -845,6 +1080,7 @@ def __call__( http_options = ( _BaseApiHubPluginRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseApiHubPluginRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -855,6 +1091,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubPluginClient.ListLocations", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHubPlugin", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubPluginRestTransport._ListLocations._get_response( self._host, @@ -874,6 +1137,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.apihub_v1.ApiHubPluginAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHubPlugin", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -915,7 +1199,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -925,13 +1209,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 = ( _BaseApiHubPluginRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -948,6 +1235,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubPluginClient.CancelOperation", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHubPlugin", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubPluginRestTransport._CancelOperation._get_response( self._host, @@ -1004,7 +1318,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -1014,13 +1328,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 = ( _BaseApiHubPluginRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -1033,6 +1350,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubPluginClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHubPlugin", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubPluginRestTransport._DeleteOperation._get_response( self._host, @@ -1088,7 +1432,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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. @@ -1098,8 +1442,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: operations_pb2.Operation: Response from GetOperation method. @@ -1108,6 +1454,7 @@ def __call__( http_options = ( _BaseApiHubPluginRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseApiHubPluginRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1120,6 +1467,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubPluginClient.GetOperation", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHubPlugin", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubPluginRestTransport._GetOperation._get_response( self._host, @@ -1139,6 +1513,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.apihub_v1.ApiHubPluginAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHubPlugin", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1179,7 +1574,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1189,8 +1584,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must 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. @@ -1199,6 +1596,7 @@ def __call__( http_options = ( _BaseApiHubPluginRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseApiHubPluginRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1209,6 +1607,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ApiHubPluginClient.ListOperations", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHubPlugin", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApiHubPluginRestTransport._ListOperations._get_response( self._host, @@ -1228,6 +1653,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.apihub_v1.ApiHubPluginAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.apihub.v1.ApiHubPlugin", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-apihub/google/cloud/apihub_v1/services/host_project_registration_service/client.py b/packages/google-cloud-apihub/google/cloud/apihub_v1/services/host_project_registration_service/client.py index e977d349f283..285335177055 100644 --- a/packages/google-cloud-apihub/google/cloud/apihub_v1/services/host_project_registration_service/client.py +++ b/packages/google-cloud-apihub/google/cloud/apihub_v1/services/host_project_registration_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.longrunning import operations_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -595,6 +605,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.apihub_v1.HostProjectRegistrationServiceClient`.", + extra={ + "serviceName": "google.cloud.apihub.v1.HostProjectRegistrationService", + "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.apihub.v1.HostProjectRegistrationService", + "credentialsType": None, + }, + ) + def create_host_project_registration( self, request: Optional[ @@ -681,7 +718,7 @@ def create_host_project_registration( host_project_registration_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]]] = (), ) -> host_project_registration_service.HostProjectRegistration: r"""Create a host project registration. A Google cloud project can be registered as a host @@ -753,8 +790,10 @@ def sample_create_host_project_registration(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.types.HostProjectRegistration: @@ -840,7 +879,7 @@ def get_host_project_registration( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> host_project_registration_service.HostProjectRegistration: r"""Get a host project registration. @@ -885,8 +924,10 @@ def sample_get_host_project_registration(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.types.HostProjectRegistration: @@ -965,7 +1006,7 @@ def list_host_project_registrations( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListHostProjectRegistrationsPager: r"""Lists host project registrations. @@ -1011,8 +1052,10 @@ def sample_list_host_project_registrations(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.services.host_project_registration_service.pagers.ListHostProjectRegistrationsPager: @@ -1106,7 +1149,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. @@ -1117,8 +1160,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. @@ -1159,7 +1204,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. @@ -1170,8 +1215,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. @@ -1212,7 +1259,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. @@ -1228,8 +1275,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 """ @@ -1266,7 +1315,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. @@ -1281,8 +1330,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 """ @@ -1319,7 +1370,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. @@ -1330,8 +1381,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. @@ -1372,7 +1425,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. @@ -1383,8 +1436,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-apihub/google/cloud/apihub_v1/services/host_project_registration_service/pagers.py b/packages/google-cloud-apihub/google/cloud/apihub_v1/services/host_project_registration_service/pagers.py index 4bb7e2ec7541..ce746d087dfc 100644 --- a/packages/google-cloud-apihub/google/cloud/apihub_v1/services/host_project_registration_service/pagers.py +++ b/packages/google-cloud-apihub/google/cloud/apihub_v1/services/host_project_registration_service/pagers.py @@ -69,7 +69,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -83,8 +83,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = ( diff --git a/packages/google-cloud-apihub/google/cloud/apihub_v1/services/host_project_registration_service/transports/rest.py b/packages/google-cloud-apihub/google/cloud/apihub_v1/services/host_project_registration_service/transports/rest.py index f79885110e88..437f5503445b 100644 --- a/packages/google-cloud-apihub/google/cloud/apihub_v1/services/host_project_registration_service/transports/rest.py +++ b/packages/google-cloud-apihub/google/cloud/apihub_v1/services/host_project_registration_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, @@ -95,10 +103,10 @@ def post_list_host_project_registrations(self, response): def pre_create_host_project_registration( self, request: host_project_registration_service.CreateHostProjectRegistrationRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ host_project_registration_service.CreateHostProjectRegistrationRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_host_project_registration @@ -121,10 +129,10 @@ def post_create_host_project_registration( def pre_get_host_project_registration( self, request: host_project_registration_service.GetHostProjectRegistrationRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ host_project_registration_service.GetHostProjectRegistrationRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_host_project_registration @@ -147,10 +155,10 @@ def post_get_host_project_registration( def pre_list_host_project_registrations( self, request: host_project_registration_service.ListHostProjectRegistrationsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ host_project_registration_service.ListHostProjectRegistrationsRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_host_project_registrations @@ -174,8 +182,10 @@ def post_list_host_project_registrations( 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 @@ -197,8 +207,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 @@ -220,8 +232,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 @@ -241,8 +255,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 @@ -262,8 +278,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 @@ -285,8 +303,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 @@ -435,7 +455,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> host_project_registration_service.HostProjectRegistration: r"""Call the create host project registration method over HTTP. @@ -448,8 +468,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.host_project_registration_service.HostProjectRegistration: @@ -469,6 +491,7 @@ def __call__( http_options = ( _BaseHostProjectRegistrationServiceRestTransport._BaseCreateHostProjectRegistration._get_http_options() ) + request, metadata = self._interceptor.pre_create_host_project_registration( request, metadata ) @@ -485,6 +508,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.HostProjectRegistrationServiceClient.CreateHostProjectRegistration", + extra={ + "serviceName": "google.cloud.apihub.v1.HostProjectRegistrationService", + "rpcName": "CreateHostProjectRegistration", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = HostProjectRegistrationServiceRestTransport._CreateHostProjectRegistration._get_response( self._host, @@ -506,7 +556,31 @@ def __call__( pb_resp = host_project_registration_service.HostProjectRegistration.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_host_project_registration(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = host_project_registration_service.HostProjectRegistration.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.HostProjectRegistrationServiceClient.create_host_project_registration", + extra={ + "serviceName": "google.cloud.apihub.v1.HostProjectRegistrationService", + "rpcName": "CreateHostProjectRegistration", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetHostProjectRegistration( @@ -546,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]]] = (), ) -> host_project_registration_service.HostProjectRegistration: r"""Call the get host project registration method over HTTP. @@ -559,8 +633,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.host_project_registration_service.HostProjectRegistration: @@ -580,6 +656,7 @@ def __call__( http_options = ( _BaseHostProjectRegistrationServiceRestTransport._BaseGetHostProjectRegistration._get_http_options() ) + request, metadata = self._interceptor.pre_get_host_project_registration( request, metadata ) @@ -592,6 +669,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.HostProjectRegistrationServiceClient.GetHostProjectRegistration", + extra={ + "serviceName": "google.cloud.apihub.v1.HostProjectRegistrationService", + "rpcName": "GetHostProjectRegistration", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = HostProjectRegistrationServiceRestTransport._GetHostProjectRegistration._get_response( self._host, @@ -612,7 +716,31 @@ def __call__( pb_resp = host_project_registration_service.HostProjectRegistration.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_host_project_registration(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = host_project_registration_service.HostProjectRegistration.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.HostProjectRegistrationServiceClient.get_host_project_registration", + extra={ + "serviceName": "google.cloud.apihub.v1.HostProjectRegistrationService", + "rpcName": "GetHostProjectRegistration", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListHostProjectRegistrations( @@ -652,7 +780,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> host_project_registration_service.ListHostProjectRegistrationsResponse: r"""Call the list host project registrations method over HTTP. @@ -665,8 +793,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.host_project_registration_service.ListHostProjectRegistrationsResponse: @@ -679,6 +809,7 @@ def __call__( http_options = ( _BaseHostProjectRegistrationServiceRestTransport._BaseListHostProjectRegistrations._get_http_options() ) + request, metadata = self._interceptor.pre_list_host_project_registrations( request, metadata ) @@ -691,6 +822,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.HostProjectRegistrationServiceClient.ListHostProjectRegistrations", + extra={ + "serviceName": "google.cloud.apihub.v1.HostProjectRegistrationService", + "rpcName": "ListHostProjectRegistrations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = HostProjectRegistrationServiceRestTransport._ListHostProjectRegistrations._get_response( self._host, @@ -715,7 +873,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_host_project_registrations(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = host_project_registration_service.ListHostProjectRegistrationsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.HostProjectRegistrationServiceClient.list_host_project_registrations", + extra={ + "serviceName": "google.cloud.apihub.v1.HostProjectRegistrationService", + "rpcName": "ListHostProjectRegistrations", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -790,7 +972,7 @@ 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. @@ -800,8 +982,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -810,6 +994,7 @@ def __call__( http_options = ( _BaseHostProjectRegistrationServiceRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseHostProjectRegistrationServiceRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -820,6 +1005,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.HostProjectRegistrationServiceClient.GetLocation", + extra={ + "serviceName": "google.cloud.apihub.v1.HostProjectRegistrationService", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( HostProjectRegistrationServiceRestTransport._GetLocation._get_response( @@ -841,6 +1053,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.apihub_v1.HostProjectRegistrationServiceAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.apihub.v1.HostProjectRegistrationService", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -882,7 +1115,7 @@ 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. @@ -892,8 +1125,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -902,6 +1137,7 @@ def __call__( http_options = ( _BaseHostProjectRegistrationServiceRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseHostProjectRegistrationServiceRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -912,6 +1148,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.HostProjectRegistrationServiceClient.ListLocations", + extra={ + "serviceName": "google.cloud.apihub.v1.HostProjectRegistrationService", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = HostProjectRegistrationServiceRestTransport._ListLocations._get_response( self._host, @@ -931,6 +1194,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.apihub_v1.HostProjectRegistrationServiceAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.apihub.v1.HostProjectRegistrationService", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -973,7 +1257,7 @@ 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. @@ -983,13 +1267,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 = ( _BaseHostProjectRegistrationServiceRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1006,6 +1293,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.HostProjectRegistrationServiceClient.CancelOperation", + extra={ + "serviceName": "google.cloud.apihub.v1.HostProjectRegistrationService", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = HostProjectRegistrationServiceRestTransport._CancelOperation._get_response( self._host, @@ -1063,7 +1377,7 @@ 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. @@ -1073,13 +1387,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 = ( _BaseHostProjectRegistrationServiceRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -1092,6 +1409,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.HostProjectRegistrationServiceClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.apihub.v1.HostProjectRegistrationService", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = HostProjectRegistrationServiceRestTransport._DeleteOperation._get_response( self._host, @@ -1148,7 +1492,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1158,8 +1502,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: operations_pb2.Operation: Response from GetOperation method. @@ -1168,6 +1514,7 @@ def __call__( http_options = ( _BaseHostProjectRegistrationServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseHostProjectRegistrationServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1178,6 +1525,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.HostProjectRegistrationServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.apihub.v1.HostProjectRegistrationService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( HostProjectRegistrationServiceRestTransport._GetOperation._get_response( @@ -1199,6 +1573,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.apihub_v1.HostProjectRegistrationServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.apihub.v1.HostProjectRegistrationService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1240,7 +1635,7 @@ def __call__( *, 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. @@ -1250,8 +1645,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must 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. @@ -1260,6 +1657,7 @@ def __call__( http_options = ( _BaseHostProjectRegistrationServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseHostProjectRegistrationServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1270,6 +1668,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.HostProjectRegistrationServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.apihub.v1.HostProjectRegistrationService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = HostProjectRegistrationServiceRestTransport._ListOperations._get_response( self._host, @@ -1289,6 +1714,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.apihub_v1.HostProjectRegistrationServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.apihub.v1.HostProjectRegistrationService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-apihub/google/cloud/apihub_v1/services/linting_service/client.py b/packages/google-cloud-apihub/google/cloud/apihub_v1/services/linting_service/client.py index 6e65e8a84af9..0754a3fee0d0 100644 --- a/packages/google-cloud-apihub/google/cloud/apihub_v1/services/linting_service/client.py +++ b/packages/google-cloud-apihub/google/cloud/apihub_v1/services/linting_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.longrunning import operations_pb2 # type: ignore from google.protobuf import field_mask_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( @@ -668,6 +682,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.apihub_v1.LintingServiceClient`.", + extra={ + "serviceName": "google.cloud.apihub.v1.LintingService", + "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.apihub.v1.LintingService", + "credentialsType": None, + }, + ) + def get_style_guide( self, request: Optional[Union[linting_service.GetStyleGuideRequest, dict]] = None, @@ -675,7 +712,7 @@ def get_style_guide( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> linting_service.StyleGuide: r"""Get the style guide being used for linting. @@ -719,8 +756,10 @@ def sample_get_style_guide(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.types.StyleGuide: @@ -780,7 +819,7 @@ def update_style_guide( 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]]] = (), ) -> linting_service.StyleGuide: r"""Update the styleGuide to be used for liniting in by API hub. @@ -837,8 +876,10 @@ def sample_update_style_guide(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.types.StyleGuide: @@ -903,7 +944,7 @@ def get_style_guide_contents( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> linting_service.StyleGuideContents: r"""Get the contents of the style guide. @@ -951,8 +992,10 @@ def sample_get_style_guide_contents(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.types.StyleGuideContents: @@ -1007,7 +1050,7 @@ def lint_spec( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Lints the requested spec and updates the corresponding API Spec with the lint response. This lint @@ -1043,8 +1086,10 @@ def sample_lint_spec(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Use the request object if provided (there's no risk of modifying the input as @@ -1092,7 +1137,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1103,8 +1148,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1145,7 +1192,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1156,8 +1203,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1198,7 +1247,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. @@ -1214,8 +1263,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 """ @@ -1252,7 +1303,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. @@ -1267,8 +1318,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 """ @@ -1305,7 +1358,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. @@ -1316,8 +1369,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. @@ -1358,7 +1413,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. @@ -1369,8 +1424,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-apihub/google/cloud/apihub_v1/services/linting_service/transports/rest.py b/packages/google-cloud-apihub/google/cloud/apihub_v1/services/linting_service/transports/rest.py index f8fca34b1bfe..4f2819108c83 100644 --- a/packages/google-cloud-apihub/google/cloud/apihub_v1/services/linting_service/transports/rest.py +++ b/packages/google-cloud-apihub/google/cloud/apihub_v1/services/linting_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, @@ -100,8 +108,10 @@ def post_update_style_guide(self, response): def pre_get_style_guide( self, request: linting_service.GetStyleGuideRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[linting_service.GetStyleGuideRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + linting_service.GetStyleGuideRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_style_guide Override in a subclass to manipulate the request or metadata @@ -123,8 +133,11 @@ def post_get_style_guide( def pre_get_style_guide_contents( self, request: linting_service.GetStyleGuideContentsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[linting_service.GetStyleGuideContentsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + linting_service.GetStyleGuideContentsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_style_guide_contents Override in a subclass to manipulate the request or metadata @@ -146,8 +159,10 @@ def post_get_style_guide_contents( def pre_lint_spec( self, request: linting_service.LintSpecRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[linting_service.LintSpecRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + linting_service.LintSpecRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for lint_spec Override in a subclass to manipulate the request or metadata @@ -158,8 +173,10 @@ def pre_lint_spec( def pre_update_style_guide( self, request: linting_service.UpdateStyleGuideRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[linting_service.UpdateStyleGuideRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + linting_service.UpdateStyleGuideRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_style_guide Override in a subclass to manipulate the request or metadata @@ -181,8 +198,10 @@ def post_update_style_guide( 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 @@ -204,8 +223,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 @@ -227,8 +248,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 @@ -248,8 +271,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 @@ -269,8 +294,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 @@ -292,8 +319,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -433,7 +462,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> linting_service.StyleGuide: r"""Call the get style guide method over HTTP. @@ -444,8 +473,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.linting_service.StyleGuide: @@ -458,6 +489,7 @@ def __call__( http_options = ( _BaseLintingServiceRestTransport._BaseGetStyleGuide._get_http_options() ) + request, metadata = self._interceptor.pre_get_style_guide(request, metadata) transcoded_request = _BaseLintingServiceRestTransport._BaseGetStyleGuide._get_transcoded_request( http_options, request @@ -468,6 +500,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.LintingServiceClient.GetStyleGuide", + extra={ + "serviceName": "google.cloud.apihub.v1.LintingService", + "rpcName": "GetStyleGuide", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LintingServiceRestTransport._GetStyleGuide._get_response( self._host, @@ -488,7 +547,29 @@ def __call__( pb_resp = linting_service.StyleGuide.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_style_guide(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = linting_service.StyleGuide.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.LintingServiceClient.get_style_guide", + extra={ + "serviceName": "google.cloud.apihub.v1.LintingService", + "rpcName": "GetStyleGuide", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetStyleGuideContents( @@ -526,7 +607,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> linting_service.StyleGuideContents: r"""Call the get style guide contents method over HTTP. @@ -538,8 +619,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.linting_service.StyleGuideContents: @@ -549,6 +632,7 @@ def __call__( http_options = ( _BaseLintingServiceRestTransport._BaseGetStyleGuideContents._get_http_options() ) + request, metadata = self._interceptor.pre_get_style_guide_contents( request, metadata ) @@ -561,6 +645,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.LintingServiceClient.GetStyleGuideContents", + extra={ + "serviceName": "google.cloud.apihub.v1.LintingService", + "rpcName": "GetStyleGuideContents", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LintingServiceRestTransport._GetStyleGuideContents._get_response( self._host, @@ -581,7 +692,31 @@ def __call__( pb_resp = linting_service.StyleGuideContents.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_style_guide_contents(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = linting_service.StyleGuideContents.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.LintingServiceClient.get_style_guide_contents", + extra={ + "serviceName": "google.cloud.apihub.v1.LintingService", + "rpcName": "GetStyleGuideContents", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _LintSpec( @@ -619,7 +754,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the lint spec method over HTTP. @@ -629,13 +764,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 = ( _BaseLintingServiceRestTransport._BaseLintSpec._get_http_options() ) + request, metadata = self._interceptor.pre_lint_spec(request, metadata) transcoded_request = ( _BaseLintingServiceRestTransport._BaseLintSpec._get_transcoded_request( @@ -656,6 +794,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.LintingServiceClient.LintSpec", + extra={ + "serviceName": "google.cloud.apihub.v1.LintingService", + "rpcName": "LintSpec", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LintingServiceRestTransport._LintSpec._get_response( self._host, @@ -707,7 +872,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> linting_service.StyleGuide: r"""Call the update style guide method over HTTP. @@ -718,8 +883,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.linting_service.StyleGuide: @@ -732,6 +899,7 @@ def __call__( http_options = ( _BaseLintingServiceRestTransport._BaseUpdateStyleGuide._get_http_options() ) + request, metadata = self._interceptor.pre_update_style_guide( request, metadata ) @@ -748,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.apihub_v1.LintingServiceClient.UpdateStyleGuide", + extra={ + "serviceName": "google.cloud.apihub.v1.LintingService", + "rpcName": "UpdateStyleGuide", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LintingServiceRestTransport._UpdateStyleGuide._get_response( self._host, @@ -769,7 +964,29 @@ def __call__( pb_resp = linting_service.StyleGuide.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_style_guide(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = linting_service.StyleGuide.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.LintingServiceClient.update_style_guide", + extra={ + "serviceName": "google.cloud.apihub.v1.LintingService", + "rpcName": "UpdateStyleGuide", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -845,7 +1062,7 @@ 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. @@ -855,8 +1072,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: locations_pb2.Location: Response from GetLocation method. @@ -865,6 +1084,7 @@ def __call__( http_options = ( _BaseLintingServiceRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseLintingServiceRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -875,6 +1095,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.LintingServiceClient.GetLocation", + extra={ + "serviceName": "google.cloud.apihub.v1.LintingService", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LintingServiceRestTransport._GetLocation._get_response( self._host, @@ -894,6 +1141,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.apihub_v1.LintingServiceAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.apihub.v1.LintingService", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -934,7 +1202,7 @@ 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. @@ -944,8 +1212,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -954,6 +1224,7 @@ def __call__( http_options = ( _BaseLintingServiceRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseLintingServiceRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -964,6 +1235,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.LintingServiceClient.ListLocations", + extra={ + "serviceName": "google.cloud.apihub.v1.LintingService", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LintingServiceRestTransport._ListLocations._get_response( self._host, @@ -983,6 +1281,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.apihub_v1.LintingServiceAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.apihub.v1.LintingService", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1024,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1034,13 +1353,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 = ( _BaseLintingServiceRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1057,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 = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.LintingServiceClient.CancelOperation", + extra={ + "serviceName": "google.cloud.apihub.v1.LintingService", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LintingServiceRestTransport._CancelOperation._get_response( self._host, @@ -1113,7 +1462,7 @@ 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. @@ -1123,13 +1472,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 = ( _BaseLintingServiceRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -1142,6 +1494,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.LintingServiceClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.apihub.v1.LintingService", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LintingServiceRestTransport._DeleteOperation._get_response( self._host, @@ -1197,7 +1576,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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. @@ -1207,8 +1586,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -1217,6 +1598,7 @@ def __call__( http_options = ( _BaseLintingServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseLintingServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1227,6 +1609,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.LintingServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.apihub.v1.LintingService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LintingServiceRestTransport._GetOperation._get_response( self._host, @@ -1246,6 +1655,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.apihub_v1.LintingServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.apihub.v1.LintingService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1286,7 +1716,7 @@ def __call__( *, 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. @@ -1296,8 +1726,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must 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. @@ -1306,6 +1738,7 @@ def __call__( http_options = ( _BaseLintingServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseLintingServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1316,6 +1749,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.LintingServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.apihub.v1.LintingService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = LintingServiceRestTransport._ListOperations._get_response( self._host, @@ -1335,6 +1795,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.apihub_v1.LintingServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.apihub.v1.LintingService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-apihub/google/cloud/apihub_v1/services/provisioning/client.py b/packages/google-cloud-apihub/google/cloud/apihub_v1/services/provisioning/client.py index 3ac25e6aa355..0782e35b0559 100644 --- a/packages/google-cloud-apihub/google/cloud/apihub_v1/services/provisioning/client.py +++ b/packages/google-cloud-apihub/google/cloud/apihub_v1/services/provisioning/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 @@ -579,6 +589,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -641,6 +655,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.apihub_v1.ProvisioningClient`.", + extra={ + "serviceName": "google.cloud.apihub.v1.Provisioning", + "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.apihub.v1.Provisioning", + "credentialsType": None, + }, + ) + def create_api_hub_instance( self, request: Optional[ @@ -652,7 +689,7 @@ def create_api_hub_instance( api_hub_instance_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Provisions instance resources for the API Hub. @@ -723,8 +760,10 @@ def sample_create_api_hub_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -799,7 +838,7 @@ def get_api_hub_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]]] = (), ) -> common_fields.ApiHubInstance: r"""Gets details of a single API Hub instance. @@ -845,8 +884,10 @@ def sample_get_api_hub_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.apihub_v1.types.ApiHubInstance: @@ -908,7 +949,7 @@ def lookup_api_hub_instance( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> provisioning_service.LookupApiHubInstanceResponse: r"""Looks up an Api Hub instance in a given GCP project. There will always be only one Api Hub instance for a GCP @@ -957,8 +998,10 @@ def sample_lookup_api_hub_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.apihub_v1.types.LookupApiHubInstanceResponse: @@ -1029,7 +1072,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. @@ -1040,8 +1083,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. @@ -1082,7 +1127,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. @@ -1093,8 +1138,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. @@ -1135,7 +1182,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. @@ -1151,8 +1198,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 """ @@ -1189,7 +1238,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. @@ -1204,8 +1253,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 """ @@ -1242,7 +1293,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. @@ -1253,8 +1304,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. @@ -1295,7 +1348,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. @@ -1306,8 +1359,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-apihub/google/cloud/apihub_v1/services/provisioning/transports/rest.py b/packages/google-cloud-apihub/google/cloud/apihub_v1/services/provisioning/transports/rest.py index 6d1522d3e57c..d10fa7b8c6a6 100644 --- a/packages/google-cloud-apihub/google/cloud/apihub_v1/services/provisioning/transports/rest.py +++ b/packages/google-cloud-apihub/google/cloud/apihub_v1/services/provisioning/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, @@ -95,9 +103,10 @@ def post_lookup_api_hub_instance(self, response): def pre_create_api_hub_instance( self, request: provisioning_service.CreateApiHubInstanceRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - provisioning_service.CreateApiHubInstanceRequest, Sequence[Tuple[str, str]] + provisioning_service.CreateApiHubInstanceRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_api_hub_instance @@ -120,9 +129,10 @@ def post_create_api_hub_instance( def pre_get_api_hub_instance( self, request: provisioning_service.GetApiHubInstanceRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - provisioning_service.GetApiHubInstanceRequest, Sequence[Tuple[str, str]] + provisioning_service.GetApiHubInstanceRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_api_hub_instance @@ -145,9 +155,10 @@ def post_get_api_hub_instance( def pre_lookup_api_hub_instance( self, request: provisioning_service.LookupApiHubInstanceRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - provisioning_service.LookupApiHubInstanceRequest, Sequence[Tuple[str, str]] + provisioning_service.LookupApiHubInstanceRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for lookup_api_hub_instance @@ -170,8 +181,10 @@ def post_lookup_api_hub_instance( def pre_get_location( self, request: locations_pb2.GetLocationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.GetLocationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_location Override in a subclass to manipulate the request or metadata @@ -193,8 +206,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 @@ -216,8 +231,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 @@ -237,8 +254,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 @@ -258,8 +277,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 @@ -281,8 +302,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 @@ -478,7 +501,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create api hub instance method over HTTP. @@ -490,8 +513,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -504,6 +529,7 @@ def __call__( http_options = ( _BaseProvisioningRestTransport._BaseCreateApiHubInstance._get_http_options() ) + request, metadata = self._interceptor.pre_create_api_hub_instance( request, metadata ) @@ -520,6 +546,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ProvisioningClient.CreateApiHubInstance", + extra={ + "serviceName": "google.cloud.apihub.v1.Provisioning", + "rpcName": "CreateApiHubInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProvisioningRestTransport._CreateApiHubInstance._get_response( self._host, @@ -539,7 +592,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_api_hub_instance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ProvisioningClient.create_api_hub_instance", + extra={ + "serviceName": "google.cloud.apihub.v1.Provisioning", + "rpcName": "CreateApiHubInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetApiHubInstance( @@ -576,7 +651,7 @@ 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_fields.ApiHubInstance: r"""Call the get api hub instance method over HTTP. @@ -588,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: ~.common_fields.ApiHubInstance: @@ -603,6 +680,7 @@ def __call__( http_options = ( _BaseProvisioningRestTransport._BaseGetApiHubInstance._get_http_options() ) + request, metadata = self._interceptor.pre_get_api_hub_instance( request, metadata ) @@ -615,6 +693,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ProvisioningClient.GetApiHubInstance", + extra={ + "serviceName": "google.cloud.apihub.v1.Provisioning", + "rpcName": "GetApiHubInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProvisioningRestTransport._GetApiHubInstance._get_response( self._host, @@ -635,7 +740,29 @@ def __call__( pb_resp = common_fields.ApiHubInstance.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_api_hub_instance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = common_fields.ApiHubInstance.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ProvisioningClient.get_api_hub_instance", + extra={ + "serviceName": "google.cloud.apihub.v1.Provisioning", + "rpcName": "GetApiHubInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _LookupApiHubInstance( @@ -672,7 +799,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> provisioning_service.LookupApiHubInstanceResponse: r"""Call the lookup api hub instance method over HTTP. @@ -684,8 +811,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.provisioning_service.LookupApiHubInstanceResponse: @@ -698,6 +827,7 @@ def __call__( http_options = ( _BaseProvisioningRestTransport._BaseLookupApiHubInstance._get_http_options() ) + request, metadata = self._interceptor.pre_lookup_api_hub_instance( request, metadata ) @@ -710,6 +840,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ProvisioningClient.LookupApiHubInstance", + extra={ + "serviceName": "google.cloud.apihub.v1.Provisioning", + "rpcName": "LookupApiHubInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProvisioningRestTransport._LookupApiHubInstance._get_response( self._host, @@ -730,7 +887,33 @@ def __call__( pb_resp = provisioning_service.LookupApiHubInstanceResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_lookup_api_hub_instance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + provisioning_service.LookupApiHubInstanceResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.ProvisioningClient.lookup_api_hub_instance", + extra={ + "serviceName": "google.cloud.apihub.v1.Provisioning", + "rpcName": "LookupApiHubInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -802,7 +985,7 @@ 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. @@ -812,8 +995,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -822,6 +1007,7 @@ def __call__( http_options = ( _BaseProvisioningRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseProvisioningRestTransport._BaseGetLocation._get_transcoded_request( @@ -836,6 +1022,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ProvisioningClient.GetLocation", + extra={ + "serviceName": "google.cloud.apihub.v1.Provisioning", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProvisioningRestTransport._GetLocation._get_response( self._host, @@ -855,6 +1068,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.apihub_v1.ProvisioningAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.apihub.v1.Provisioning", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -895,7 +1129,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -905,8 +1139,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -915,6 +1151,7 @@ def __call__( http_options = ( _BaseProvisioningRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseProvisioningRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -925,6 +1162,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ProvisioningClient.ListLocations", + extra={ + "serviceName": "google.cloud.apihub.v1.Provisioning", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProvisioningRestTransport._ListLocations._get_response( self._host, @@ -944,6 +1208,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.apihub_v1.ProvisioningAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.apihub.v1.Provisioning", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -985,7 +1270,7 @@ 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. @@ -995,13 +1280,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 = ( _BaseProvisioningRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1018,6 +1306,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ProvisioningClient.CancelOperation", + extra={ + "serviceName": "google.cloud.apihub.v1.Provisioning", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProvisioningRestTransport._CancelOperation._get_response( self._host, @@ -1074,7 +1389,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -1084,13 +1399,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseProvisioningRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -1103,6 +1421,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ProvisioningClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.apihub.v1.Provisioning", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProvisioningRestTransport._DeleteOperation._get_response( self._host, @@ -1158,7 +1503,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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. @@ -1168,8 +1513,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -1178,6 +1525,7 @@ def __call__( http_options = ( _BaseProvisioningRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseProvisioningRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1190,6 +1538,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ProvisioningClient.GetOperation", + extra={ + "serviceName": "google.cloud.apihub.v1.Provisioning", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProvisioningRestTransport._GetOperation._get_response( self._host, @@ -1209,6 +1584,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.apihub_v1.ProvisioningAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.apihub.v1.Provisioning", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1249,7 +1645,7 @@ def __call__( *, 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. @@ -1259,8 +1655,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1269,6 +1667,7 @@ def __call__( http_options = ( _BaseProvisioningRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseProvisioningRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1279,6 +1678,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.ProvisioningClient.ListOperations", + extra={ + "serviceName": "google.cloud.apihub.v1.Provisioning", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ProvisioningRestTransport._ListOperations._get_response( self._host, @@ -1298,6 +1724,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.apihub_v1.ProvisioningAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.apihub.v1.Provisioning", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-apihub/google/cloud/apihub_v1/services/runtime_project_attachment_service/client.py b/packages/google-cloud-apihub/google/cloud/apihub_v1/services/runtime_project_attachment_service/client.py index 16f69c687758..0ca48901fd15 100644 --- a/packages/google-cloud-apihub/google/cloud/apihub_v1/services/runtime_project_attachment_service/client.py +++ b/packages/google-cloud-apihub/google/cloud/apihub_v1/services/runtime_project_attachment_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.longrunning import operations_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore @@ -595,6 +605,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.apihub_v1.RuntimeProjectAttachmentServiceClient`.", + extra={ + "serviceName": "google.cloud.apihub.v1.RuntimeProjectAttachmentService", + "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.apihub.v1.RuntimeProjectAttachmentService", + "credentialsType": None, + }, + ) + def create_runtime_project_attachment( self, request: Optional[ @@ -681,7 +718,7 @@ def create_runtime_project_attachment( runtime_project_attachment_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]]] = (), ) -> runtime_project_attachment_service.RuntimeProjectAttachment: r"""Attaches a runtime project to the host project. @@ -750,8 +787,10 @@ def sample_create_runtime_project_attachment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.types.RuntimeProjectAttachment: @@ -832,7 +871,7 @@ def get_runtime_project_attachment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> runtime_project_attachment_service.RuntimeProjectAttachment: r"""Gets a runtime project attachment. @@ -878,8 +917,10 @@ def sample_get_runtime_project_attachment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.types.RuntimeProjectAttachment: @@ -956,7 +997,7 @@ def list_runtime_project_attachments( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListRuntimeProjectAttachmentsPager: r"""List runtime projects attached to the host project. @@ -1003,8 +1044,10 @@ def sample_list_runtime_project_attachments(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.services.runtime_project_attachment_service.pagers.ListRuntimeProjectAttachmentsPager: @@ -1091,7 +1134,7 @@ def delete_runtime_project_attachment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Delete a runtime project attachment in the API Hub. This call will detach the runtime project from the host @@ -1136,8 +1179,10 @@ def sample_delete_runtime_project_attachment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1198,7 +1243,7 @@ def lookup_runtime_project_attachment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> runtime_project_attachment_service.LookupRuntimeProjectAttachmentResponse: r"""Look up a runtime project attachment. This API can be called in the context of any project. @@ -1246,8 +1291,10 @@ def sample_lookup_runtime_project_attachment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apihub_v1.types.LookupRuntimeProjectAttachmentResponse: @@ -1325,7 +1372,7 @@ def list_operations( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1336,8 +1383,10 @@ def list_operations( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.ListOperationsResponse: Response message for ``ListOperations`` method. @@ -1378,7 +1427,7 @@ def get_operation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1389,8 +1438,10 @@ def get_operation( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: An ``Operation`` object. @@ -1431,7 +1482,7 @@ def 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. @@ -1447,8 +1498,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 """ @@ -1485,7 +1538,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. @@ -1500,8 +1553,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 """ @@ -1538,7 +1593,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. @@ -1549,8 +1604,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. @@ -1591,7 +1648,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. @@ -1602,8 +1659,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-apihub/google/cloud/apihub_v1/services/runtime_project_attachment_service/pagers.py b/packages/google-cloud-apihub/google/cloud/apihub_v1/services/runtime_project_attachment_service/pagers.py index 7e63e765df51..3b079b84f428 100644 --- a/packages/google-cloud-apihub/google/cloud/apihub_v1/services/runtime_project_attachment_service/pagers.py +++ b/packages/google-cloud-apihub/google/cloud/apihub_v1/services/runtime_project_attachment_service/pagers.py @@ -70,7 +70,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -84,8 +84,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = ( diff --git a/packages/google-cloud-apihub/google/cloud/apihub_v1/services/runtime_project_attachment_service/transports/rest.py b/packages/google-cloud-apihub/google/cloud/apihub_v1/services/runtime_project_attachment_service/transports/rest.py index c989f62343ac..1b3597fec0b4 100644 --- a/packages/google-cloud-apihub/google/cloud/apihub_v1/services/runtime_project_attachment_service/transports/rest.py +++ b/packages/google-cloud-apihub/google/cloud/apihub_v1/services/runtime_project_attachment_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, @@ -108,10 +116,10 @@ def post_lookup_runtime_project_attachment(self, response): def pre_create_runtime_project_attachment( self, request: runtime_project_attachment_service.CreateRuntimeProjectAttachmentRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ runtime_project_attachment_service.CreateRuntimeProjectAttachmentRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_runtime_project_attachment @@ -134,10 +142,10 @@ def post_create_runtime_project_attachment( def pre_delete_runtime_project_attachment( self, request: runtime_project_attachment_service.DeleteRuntimeProjectAttachmentRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ runtime_project_attachment_service.DeleteRuntimeProjectAttachmentRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_runtime_project_attachment @@ -149,10 +157,10 @@ def pre_delete_runtime_project_attachment( def pre_get_runtime_project_attachment( self, request: runtime_project_attachment_service.GetRuntimeProjectAttachmentRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ runtime_project_attachment_service.GetRuntimeProjectAttachmentRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_runtime_project_attachment @@ -175,10 +183,10 @@ def post_get_runtime_project_attachment( def pre_list_runtime_project_attachments( self, request: runtime_project_attachment_service.ListRuntimeProjectAttachmentsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ runtime_project_attachment_service.ListRuntimeProjectAttachmentsRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_runtime_project_attachments @@ -202,10 +210,10 @@ def post_list_runtime_project_attachments( def pre_lookup_runtime_project_attachment( self, request: runtime_project_attachment_service.LookupRuntimeProjectAttachmentRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ runtime_project_attachment_service.LookupRuntimeProjectAttachmentRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for lookup_runtime_project_attachment @@ -229,8 +237,10 @@ def post_lookup_runtime_project_attachment( 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 @@ -252,8 +262,10 @@ def post_get_location( def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + locations_pb2.ListLocationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -275,8 +287,10 @@ def post_list_locations( def pre_cancel_operation( self, request: operations_pb2.CancelOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.CancelOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.CancelOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for cancel_operation Override in a subclass to manipulate the request or metadata @@ -296,8 +310,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 @@ -317,8 +333,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 @@ -340,8 +358,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 @@ -490,7 +510,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> runtime_project_attachment_service.RuntimeProjectAttachment: r"""Call the create runtime project attachment method over HTTP. @@ -503,8 +523,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.runtime_project_attachment_service.RuntimeProjectAttachment: @@ -521,6 +543,7 @@ def __call__( http_options = ( _BaseRuntimeProjectAttachmentServiceRestTransport._BaseCreateRuntimeProjectAttachment._get_http_options() ) + request, metadata = self._interceptor.pre_create_runtime_project_attachment( request, metadata ) @@ -537,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 google.cloud.apihub_v1.RuntimeProjectAttachmentServiceClient.CreateRuntimeProjectAttachment", + extra={ + "serviceName": "google.cloud.apihub.v1.RuntimeProjectAttachmentService", + "rpcName": "CreateRuntimeProjectAttachment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RuntimeProjectAttachmentServiceRestTransport._CreateRuntimeProjectAttachment._get_response( self._host, @@ -560,7 +610,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_runtime_project_attachment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = runtime_project_attachment_service.RuntimeProjectAttachment.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.RuntimeProjectAttachmentServiceClient.create_runtime_project_attachment", + extra={ + "serviceName": "google.cloud.apihub.v1.RuntimeProjectAttachmentService", + "rpcName": "CreateRuntimeProjectAttachment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteRuntimeProjectAttachment( @@ -600,7 +674,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete runtime project attachment method over HTTP. @@ -613,13 +687,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 = ( _BaseRuntimeProjectAttachmentServiceRestTransport._BaseDeleteRuntimeProjectAttachment._get_http_options() ) + request, metadata = self._interceptor.pre_delete_runtime_project_attachment( request, metadata ) @@ -632,6 +709,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.RuntimeProjectAttachmentServiceClient.DeleteRuntimeProjectAttachment", + extra={ + "serviceName": "google.cloud.apihub.v1.RuntimeProjectAttachmentService", + "rpcName": "DeleteRuntimeProjectAttachment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RuntimeProjectAttachmentServiceRestTransport._DeleteRuntimeProjectAttachment._get_response( self._host, @@ -684,7 +788,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> runtime_project_attachment_service.RuntimeProjectAttachment: r"""Call the get runtime project attachment method over HTTP. @@ -697,8 +801,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.runtime_project_attachment_service.RuntimeProjectAttachment: @@ -715,6 +821,7 @@ def __call__( http_options = ( _BaseRuntimeProjectAttachmentServiceRestTransport._BaseGetRuntimeProjectAttachment._get_http_options() ) + request, metadata = self._interceptor.pre_get_runtime_project_attachment( request, metadata ) @@ -727,6 +834,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.RuntimeProjectAttachmentServiceClient.GetRuntimeProjectAttachment", + extra={ + "serviceName": "google.cloud.apihub.v1.RuntimeProjectAttachmentService", + "rpcName": "GetRuntimeProjectAttachment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RuntimeProjectAttachmentServiceRestTransport._GetRuntimeProjectAttachment._get_response( self._host, @@ -749,7 +883,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_runtime_project_attachment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = runtime_project_attachment_service.RuntimeProjectAttachment.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.RuntimeProjectAttachmentServiceClient.get_runtime_project_attachment", + extra={ + "serviceName": "google.cloud.apihub.v1.RuntimeProjectAttachmentService", + "rpcName": "GetRuntimeProjectAttachment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListRuntimeProjectAttachments( @@ -789,7 +947,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> runtime_project_attachment_service.ListRuntimeProjectAttachmentsResponse: r"""Call the list runtime project attachments method over HTTP. @@ -802,8 +960,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.runtime_project_attachment_service.ListRuntimeProjectAttachmentsResponse: @@ -816,6 +976,7 @@ def __call__( http_options = ( _BaseRuntimeProjectAttachmentServiceRestTransport._BaseListRuntimeProjectAttachments._get_http_options() ) + request, metadata = self._interceptor.pre_list_runtime_project_attachments( request, metadata ) @@ -828,6 +989,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.RuntimeProjectAttachmentServiceClient.ListRuntimeProjectAttachments", + extra={ + "serviceName": "google.cloud.apihub.v1.RuntimeProjectAttachmentService", + "rpcName": "ListRuntimeProjectAttachments", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RuntimeProjectAttachmentServiceRestTransport._ListRuntimeProjectAttachments._get_response( self._host, @@ -852,7 +1040,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_runtime_project_attachments(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = runtime_project_attachment_service.ListRuntimeProjectAttachmentsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.RuntimeProjectAttachmentServiceClient.list_runtime_project_attachments", + extra={ + "serviceName": "google.cloud.apihub.v1.RuntimeProjectAttachmentService", + "rpcName": "ListRuntimeProjectAttachments", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _LookupRuntimeProjectAttachment( @@ -892,7 +1104,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> runtime_project_attachment_service.LookupRuntimeProjectAttachmentResponse: r"""Call the lookup runtime project attachment method over HTTP. @@ -905,8 +1117,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.runtime_project_attachment_service.LookupRuntimeProjectAttachmentResponse: @@ -919,6 +1133,7 @@ def __call__( http_options = ( _BaseRuntimeProjectAttachmentServiceRestTransport._BaseLookupRuntimeProjectAttachment._get_http_options() ) + request, metadata = self._interceptor.pre_lookup_runtime_project_attachment( request, metadata ) @@ -931,6 +1146,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.RuntimeProjectAttachmentServiceClient.LookupRuntimeProjectAttachment", + extra={ + "serviceName": "google.cloud.apihub.v1.RuntimeProjectAttachmentService", + "rpcName": "LookupRuntimeProjectAttachment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RuntimeProjectAttachmentServiceRestTransport._LookupRuntimeProjectAttachment._get_response( self._host, @@ -955,7 +1197,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_lookup_runtime_project_attachment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = runtime_project_attachment_service.LookupRuntimeProjectAttachmentResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apihub_v1.RuntimeProjectAttachmentServiceClient.lookup_runtime_project_attachment", + extra={ + "serviceName": "google.cloud.apihub.v1.RuntimeProjectAttachmentService", + "rpcName": "LookupRuntimeProjectAttachment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1052,7 +1318,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -1062,8 +1328,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -1072,6 +1340,7 @@ def __call__( http_options = ( _BaseRuntimeProjectAttachmentServiceRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseRuntimeProjectAttachmentServiceRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -1082,6 +1351,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.RuntimeProjectAttachmentServiceClient.GetLocation", + extra={ + "serviceName": "google.cloud.apihub.v1.RuntimeProjectAttachmentService", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RuntimeProjectAttachmentServiceRestTransport._GetLocation._get_response( @@ -1103,6 +1399,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.apihub_v1.RuntimeProjectAttachmentServiceAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.apihub.v1.RuntimeProjectAttachmentService", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1144,7 +1461,7 @@ 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. @@ -1154,8 +1471,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -1164,6 +1483,7 @@ def __call__( http_options = ( _BaseRuntimeProjectAttachmentServiceRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseRuntimeProjectAttachmentServiceRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -1174,6 +1494,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.RuntimeProjectAttachmentServiceClient.ListLocations", + extra={ + "serviceName": "google.cloud.apihub.v1.RuntimeProjectAttachmentService", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RuntimeProjectAttachmentServiceRestTransport._ListLocations._get_response( self._host, @@ -1193,6 +1540,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.apihub_v1.RuntimeProjectAttachmentServiceAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.apihub.v1.RuntimeProjectAttachmentService", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1235,7 +1603,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1245,13 +1613,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 = ( _BaseRuntimeProjectAttachmentServiceRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1268,6 +1639,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.RuntimeProjectAttachmentServiceClient.CancelOperation", + extra={ + "serviceName": "google.cloud.apihub.v1.RuntimeProjectAttachmentService", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RuntimeProjectAttachmentServiceRestTransport._CancelOperation._get_response( self._host, @@ -1325,7 +1723,7 @@ 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. @@ -1335,13 +1733,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 = ( _BaseRuntimeProjectAttachmentServiceRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -1354,6 +1755,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.RuntimeProjectAttachmentServiceClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.apihub.v1.RuntimeProjectAttachmentService", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RuntimeProjectAttachmentServiceRestTransport._DeleteOperation._get_response( self._host, @@ -1410,7 +1838,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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. @@ -1420,8 +1848,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -1430,6 +1860,7 @@ def __call__( http_options = ( _BaseRuntimeProjectAttachmentServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseRuntimeProjectAttachmentServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1440,6 +1871,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.RuntimeProjectAttachmentServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.apihub.v1.RuntimeProjectAttachmentService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RuntimeProjectAttachmentServiceRestTransport._GetOperation._get_response( self._host, @@ -1459,6 +1917,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.apihub_v1.RuntimeProjectAttachmentServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.apihub.v1.RuntimeProjectAttachmentService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1500,7 +1979,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1510,8 +1989,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must 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. @@ -1520,6 +2001,7 @@ def __call__( http_options = ( _BaseRuntimeProjectAttachmentServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseRuntimeProjectAttachmentServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1530,6 +2012,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apihub_v1.RuntimeProjectAttachmentServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.apihub.v1.RuntimeProjectAttachmentService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RuntimeProjectAttachmentServiceRestTransport._ListOperations._get_response( self._host, @@ -1549,6 +2058,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.apihub_v1.RuntimeProjectAttachmentServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.apihub.v1.RuntimeProjectAttachmentService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-apihub/samples/generated_samples/snippet_metadata_google.cloud.apihub.v1.json b/packages/google-cloud-apihub/samples/generated_samples/snippet_metadata_google.cloud.apihub.v1.json index 208b34aaaa8e..f91c8ea92da1 100644 --- a/packages/google-cloud-apihub/samples/generated_samples/snippet_metadata_google.cloud.apihub.v1.json +++ b/packages/google-cloud-apihub/samples/generated_samples/snippet_metadata_google.cloud.apihub.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-apihub", - "version": "0.2.2" + "version": "0.1.0" }, "snippets": [ { @@ -54,7 +54,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.types.Dependency", @@ -134,7 +134,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_dependency" @@ -211,7 +211,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.types.Dependency", @@ -291,7 +291,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.services.api_hub_dependencies.pagers.ListDependenciesPager", @@ -375,7 +375,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.types.Dependency", @@ -455,7 +455,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.types.Plugin", @@ -535,7 +535,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.types.Plugin", @@ -615,7 +615,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.types.Plugin", @@ -703,7 +703,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.types.Api", @@ -791,7 +791,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.types.Attribute", @@ -879,7 +879,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.types.Deployment", @@ -967,7 +967,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.types.ExternalApi", @@ -1055,7 +1055,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.types.Spec", @@ -1143,7 +1143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.types.Version", @@ -1223,7 +1223,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_api" @@ -1300,7 +1300,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_attribute" @@ -1377,7 +1377,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_deployment" @@ -1454,7 +1454,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_external_api" @@ -1531,7 +1531,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_spec" @@ -1608,7 +1608,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_version" @@ -1685,7 +1685,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.types.ApiOperation", @@ -1765,7 +1765,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.types.Api", @@ -1845,7 +1845,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.types.Attribute", @@ -1925,7 +1925,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.types.Definition", @@ -2005,7 +2005,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.types.Deployment", @@ -2085,7 +2085,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.types.ExternalApi", @@ -2165,7 +2165,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.types.SpecContents", @@ -2245,7 +2245,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.types.Spec", @@ -2325,7 +2325,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.types.Version", @@ -2405,7 +2405,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.services.api_hub.pagers.ListApiOperationsPager", @@ -2485,7 +2485,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.services.api_hub.pagers.ListApisPager", @@ -2565,7 +2565,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.services.api_hub.pagers.ListAttributesPager", @@ -2645,7 +2645,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.services.api_hub.pagers.ListDeploymentsPager", @@ -2725,7 +2725,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.services.api_hub.pagers.ListExternalApisPager", @@ -2805,7 +2805,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.services.api_hub.pagers.ListSpecsPager", @@ -2885,7 +2885,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.services.api_hub.pagers.ListVersionsPager", @@ -2969,7 +2969,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.services.api_hub.pagers.SearchResourcesPager", @@ -3053,7 +3053,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.types.Api", @@ -3137,7 +3137,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.types.Attribute", @@ -3221,7 +3221,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.types.Deployment", @@ -3305,7 +3305,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.types.ExternalApi", @@ -3389,7 +3389,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.types.Spec", @@ -3473,7 +3473,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.types.Version", @@ -3561,7 +3561,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.types.HostProjectRegistration", @@ -3641,7 +3641,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.types.HostProjectRegistration", @@ -3721,7 +3721,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.services.host_project_registration_service.pagers.ListHostProjectRegistrationsPager", @@ -3801,7 +3801,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.types.StyleGuideContents", @@ -3881,7 +3881,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.types.StyleGuide", @@ -3957,7 +3957,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "lint_spec" @@ -4038,7 +4038,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.types.StyleGuide", @@ -4126,7 +4126,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4206,7 +4206,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.types.ApiHubInstance", @@ -4286,7 +4286,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.types.LookupApiHubInstanceResponse", @@ -4374,7 +4374,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.types.RuntimeProjectAttachment", @@ -4454,7 +4454,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_runtime_project_attachment" @@ -4531,7 +4531,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.types.RuntimeProjectAttachment", @@ -4611,7 +4611,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.services.runtime_project_attachment_service.pagers.ListRuntimeProjectAttachmentsPager", @@ -4691,7 +4691,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apihub_v1.types.LookupRuntimeProjectAttachmentResponse", diff --git a/packages/google-cloud-apihub/tests/unit/gapic/apihub_v1/test_api_hub.py b/packages/google-cloud-apihub/tests/unit/gapic/apihub_v1/test_api_hub.py index 8557fbc9ac5f..5bfa4b5cc4e7 100644 --- a/packages/google-cloud-apihub/tests/unit/gapic/apihub_v1/test_api_hub.py +++ b/packages/google-cloud-apihub/tests/unit/gapic/apihub_v1/test_api_hub.py @@ -956,6 +956,7 @@ def test_create_api_rest_required_fields(request_type=apihub_service.CreateApiRe response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_api(request) @@ -1011,6 +1012,7 @@ def test_create_api_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_api(**mock_args) @@ -1141,6 +1143,7 @@ def test_get_api_rest_required_fields(request_type=apihub_service.GetApiRequest) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_api(request) @@ -1186,6 +1189,7 @@ def test_get_api_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_api(**mock_args) @@ -1322,6 +1326,7 @@ def test_list_apis_rest_required_fields(request_type=apihub_service.ListApisRequ response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_apis(request) @@ -1376,6 +1381,7 @@ def test_list_apis_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_apis(**mock_args) @@ -1563,6 +1569,7 @@ def test_update_api_rest_required_fields(request_type=apihub_service.UpdateApiRe response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_api(request) @@ -1619,6 +1626,7 @@ def test_update_api_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_api(**mock_args) @@ -1747,6 +1755,7 @@ def test_delete_api_rest_required_fields(request_type=apihub_service.DeleteApiRe response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_api(request) @@ -1790,6 +1799,7 @@ def test_delete_api_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_api(**mock_args) @@ -1923,6 +1933,7 @@ def test_create_version_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_version(request) @@ -1978,6 +1989,7 @@ def test_create_version_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_version(**mock_args) @@ -2111,6 +2123,7 @@ def test_get_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_version(request) @@ -2158,6 +2171,7 @@ def test_get_version_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_version(**mock_args) @@ -2297,6 +2311,7 @@ def test_list_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_versions(request) @@ -2351,6 +2366,7 @@ def test_list_versions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_versions(**mock_args) @@ -2543,6 +2559,7 @@ def test_update_version_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_version(request) @@ -2601,6 +2618,7 @@ def test_update_version_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_version(**mock_args) @@ -2732,6 +2750,7 @@ def test_delete_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.delete_version(request) @@ -2777,6 +2796,7 @@ def test_delete_version_rest_flattened(): json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_version(**mock_args) @@ -2911,6 +2931,7 @@ def test_create_spec_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_spec(request) @@ -2968,6 +2989,7 @@ def test_create_spec_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_spec(**mock_args) @@ -3099,6 +3121,7 @@ def test_get_spec_rest_required_fields(request_type=apihub_service.GetSpecReques response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_spec(request) @@ -3146,6 +3169,7 @@ def test_get_spec_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_spec(**mock_args) @@ -3279,6 +3303,7 @@ def test_get_spec_contents_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_spec_contents(request) @@ -3326,6 +3351,7 @@ def test_get_spec_contents_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_spec_contents(**mock_args) @@ -3463,6 +3489,7 @@ def test_list_specs_rest_required_fields(request_type=apihub_service.ListSpecsRe response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_specs(request) @@ -3519,6 +3546,7 @@ def test_list_specs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_specs(**mock_args) @@ -3711,6 +3739,7 @@ def test_update_spec_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_spec(request) @@ -3769,6 +3798,7 @@ def test_update_spec_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_spec(**mock_args) @@ -3898,6 +3928,7 @@ def test_delete_spec_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_spec(request) @@ -3943,6 +3974,7 @@ def test_delete_spec_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_spec(**mock_args) @@ -4076,6 +4108,7 @@ def test_get_api_operation_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_api_operation(request) @@ -4123,6 +4156,7 @@ def test_get_api_operation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_api_operation(**mock_args) @@ -4266,6 +4300,7 @@ def test_list_api_operations_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_api_operations(request) @@ -4322,6 +4357,7 @@ def test_list_api_operations_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_api_operations(**mock_args) @@ -4518,6 +4554,7 @@ def test_get_definition_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_definition(request) @@ -4565,6 +4602,7 @@ def test_get_definition_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_definition(**mock_args) @@ -4701,6 +4739,7 @@ def test_create_deployment_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_deployment(request) @@ -4756,6 +4795,7 @@ def test_create_deployment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_deployment(**mock_args) @@ -4889,6 +4929,7 @@ def test_get_deployment_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_deployment(request) @@ -4936,6 +4977,7 @@ def test_get_deployment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_deployment(**mock_args) @@ -5077,6 +5119,7 @@ def test_list_deployments_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_deployments(request) @@ -5131,6 +5174,7 @@ def test_list_deployments_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_deployments(**mock_args) @@ -5325,6 +5369,7 @@ def test_update_deployment_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_deployment(request) @@ -5383,6 +5428,7 @@ def test_update_deployment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_deployment(**mock_args) @@ -5514,6 +5560,7 @@ def test_delete_deployment_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_deployment(request) @@ -5559,6 +5606,7 @@ def test_delete_deployment_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_deployment(**mock_args) @@ -5695,6 +5743,7 @@ def test_create_attribute_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_attribute(request) @@ -5750,6 +5799,7 @@ def test_create_attribute_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_attribute(**mock_args) @@ -5882,6 +5932,7 @@ def test_get_attribute_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_attribute(request) @@ -5929,6 +5980,7 @@ def test_get_attribute_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_attribute(**mock_args) @@ -6059,6 +6111,7 @@ def test_update_attribute_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_attribute(request) @@ -6117,6 +6170,7 @@ def test_update_attribute_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_attribute(**mock_args) @@ -6248,6 +6302,7 @@ def test_delete_attribute_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_attribute(request) @@ -6293,6 +6348,7 @@ def test_delete_attribute_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_attribute(**mock_args) @@ -6431,6 +6487,7 @@ def test_list_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.list_attributes(request) @@ -6485,6 +6542,7 @@ def test_list_attributes_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_attributes(**mock_args) @@ -6685,6 +6743,7 @@ def test_search_resources_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.search_resources(request) @@ -6739,6 +6798,7 @@ def test_search_resources_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.search_resources(**mock_args) @@ -6941,6 +7001,7 @@ def test_create_external_api_rest_required_fields( response_value._content = json_return_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_api(request) @@ -6996,6 +7057,7 @@ def test_create_external_api_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_api(**mock_args) @@ -7131,6 +7193,7 @@ def test_get_external_api_rest_required_fields( response_value._content = json_return_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_api(request) @@ -7178,6 +7241,7 @@ def test_get_external_api_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_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_api(**mock_args) @@ -7311,6 +7375,7 @@ def test_update_external_api_rest_required_fields( response_value._content = json_return_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_api(request) @@ -7369,6 +7434,7 @@ def test_update_external_api_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_api(**mock_args) @@ -7502,6 +7568,7 @@ def test_delete_external_api_rest_required_fields( response_value._content = json_return_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_api(request) @@ -7547,6 +7614,7 @@ def test_delete_external_api_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_external_api(**mock_args) @@ -7689,6 +7757,7 @@ def test_list_external_apis_rest_required_fields( response_value._content = json_return_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_apis(request) @@ -7742,6 +7811,7 @@ def test_list_external_apis_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_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_apis(**mock_args) @@ -7935,6 +8005,7 @@ def test_create_api_rest_bad_request(request_type=apihub_service.CreateApiReques response_value.status_code = 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_api(request) @@ -8072,6 +8143,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_api(request) # Establish that the response is the type that we expect. @@ -8114,6 +8186,7 @@ def test_create_api_rest_interceptors(null_interceptor): req.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_fields.Api.to_json(common_fields.Api()) req.return_value.content = return_value @@ -8156,6 +8229,7 @@ def test_get_api_rest_bad_request(request_type=apihub_service.GetApiRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_api(request) @@ -8195,6 +8269,7 @@ def test_get_api_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_api(request) # Establish that the response is the type that we expect. @@ -8235,6 +8310,7 @@ def test_get_api_rest_interceptors(null_interceptor): req.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_fields.Api.to_json(common_fields.Api()) req.return_value.content = return_value @@ -8277,6 +8353,7 @@ def test_list_apis_rest_bad_request(request_type=apihub_service.ListApisRequest) response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_apis(request) @@ -8312,6 +8389,7 @@ def test_list_apis_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_apis(request) # Establish that the response is the type that we expect. @@ -8348,6 +8426,7 @@ def test_list_apis_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = apihub_service.ListApisResponse.to_json( apihub_service.ListApisResponse() ) @@ -8392,6 +8471,7 @@ def test_update_api_rest_bad_request(request_type=apihub_service.UpdateApiReques response_value.status_code = 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_api(request) @@ -8529,6 +8609,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_api(request) # Establish that the response is the type that we expect. @@ -8571,6 +8652,7 @@ def test_update_api_rest_interceptors(null_interceptor): req.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_fields.Api.to_json(common_fields.Api()) req.return_value.content = return_value @@ -8613,6 +8695,7 @@ def test_delete_api_rest_bad_request(request_type=apihub_service.DeleteApiReques response_value.status_code = 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_api(request) @@ -8643,6 +8726,7 @@ def test_delete_api_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_api(request) # Establish that the response is the type that we expect. @@ -8677,6 +8761,7 @@ def test_delete_api_rest_interceptors(null_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 = apihub_service.DeleteApiRequest() metadata = [ @@ -8717,6 +8802,7 @@ def test_create_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.create_version(request) @@ -8857,6 +8943,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_version(request) # Establish that the response is the type that we expect. @@ -8902,6 +8989,7 @@ def test_create_version_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = common_fields.Version.to_json(common_fields.Version()) req.return_value.content = return_value @@ -8946,6 +9034,7 @@ def test_get_version_rest_bad_request(request_type=apihub_service.GetVersionRequ response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_version(request) @@ -8990,6 +9079,7 @@ def test_get_version_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_version(request) # Establish that the response is the type that we expect. @@ -9035,6 +9125,7 @@ def test_get_version_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = common_fields.Version.to_json(common_fields.Version()) req.return_value.content = return_value @@ -9079,6 +9170,7 @@ def test_list_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_versions(request) @@ -9114,6 +9206,7 @@ def test_list_versions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_versions(request) # Establish that the response is the type that we expect. @@ -9152,6 +9245,7 @@ def test_list_versions_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = apihub_service.ListVersionsResponse.to_json( apihub_service.ListVersionsResponse() ) @@ -9202,6 +9296,7 @@ def test_update_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.update_version(request) @@ -9346,6 +9441,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_version(request) # Establish that the response is the type that we expect. @@ -9391,6 +9487,7 @@ def test_update_version_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = common_fields.Version.to_json(common_fields.Version()) req.return_value.content = return_value @@ -9437,6 +9534,7 @@ def test_delete_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.delete_version(request) @@ -9469,6 +9567,7 @@ def test_delete_version_rest_call_success(request_type): json_return_value = "" response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_version(request) # Establish that the response is the type that we expect. @@ -9503,6 +9602,7 @@ def test_delete_version_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = apihub_service.DeleteVersionRequest() metadata = [ @@ -9543,6 +9643,7 @@ def test_create_spec_rest_bad_request(request_type=apihub_service.CreateSpecRequ response_value.status_code = 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_spec(request) @@ -9700,6 +9801,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_spec(request) # Establish that the response is the type that we expect. @@ -9741,6 +9843,7 @@ def test_create_spec_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = common_fields.Spec.to_json(common_fields.Spec()) req.return_value.content = return_value @@ -9785,6 +9888,7 @@ def test_get_spec_rest_bad_request(request_type=apihub_service.GetSpecRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_spec(request) @@ -9825,6 +9929,7 @@ def test_get_spec_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_spec(request) # Establish that the response is the type that we expect. @@ -9864,6 +9969,7 @@ def test_get_spec_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = common_fields.Spec.to_json(common_fields.Spec()) req.return_value.content = return_value @@ -9910,6 +10016,7 @@ def test_get_spec_contents_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_spec_contents(request) @@ -9948,6 +10055,7 @@ def test_get_spec_contents_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_spec_contents(request) # Establish that the response is the type that we expect. @@ -9987,6 +10095,7 @@ def test_get_spec_contents_rest_interceptors(null_interceptor): req.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_fields.SpecContents.to_json(common_fields.SpecContents()) req.return_value.content = return_value @@ -10031,6 +10140,7 @@ def test_list_specs_rest_bad_request(request_type=apihub_service.ListSpecsReques response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_specs(request) @@ -10068,6 +10178,7 @@ def test_list_specs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_specs(request) # Establish that the response is the type that we expect. @@ -10106,6 +10217,7 @@ def test_list_specs_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = apihub_service.ListSpecsResponse.to_json( apihub_service.ListSpecsResponse() ) @@ -10154,6 +10266,7 @@ def test_update_spec_rest_bad_request(request_type=apihub_service.UpdateSpecRequ response_value.status_code = 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_spec(request) @@ -10313,6 +10426,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_spec(request) # Establish that the response is the type that we expect. @@ -10354,6 +10468,7 @@ def test_update_spec_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = common_fields.Spec.to_json(common_fields.Spec()) req.return_value.content = return_value @@ -10398,6 +10513,7 @@ def test_delete_spec_rest_bad_request(request_type=apihub_service.DeleteSpecRequ response_value.status_code = 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_spec(request) @@ -10430,6 +10546,7 @@ def test_delete_spec_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_spec(request) # Establish that the response is the type that we expect. @@ -10464,6 +10581,7 @@ def test_delete_spec_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = apihub_service.DeleteSpecRequest() metadata = [ @@ -10506,6 +10624,7 @@ def test_get_api_operation_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_api_operation(request) @@ -10544,6 +10663,7 @@ def test_get_api_operation_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_api_operation(request) # Establish that the response is the type that we expect. @@ -10583,6 +10703,7 @@ def test_get_api_operation_rest_interceptors(null_interceptor): req.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_fields.ApiOperation.to_json(common_fields.ApiOperation()) req.return_value.content = return_value @@ -10629,6 +10750,7 @@ def test_list_api_operations_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_api_operations(request) @@ -10666,6 +10788,7 @@ def test_list_api_operations_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_api_operations(request) # Establish that the response is the type that we expect. @@ -10704,6 +10827,7 @@ def test_list_api_operations_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = apihub_service.ListApiOperationsResponse.to_json( apihub_service.ListApiOperationsResponse() ) @@ -10752,6 +10876,7 @@ def test_get_definition_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_definition(request) @@ -10791,6 +10916,7 @@ def test_get_definition_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_definition(request) # Establish that the response is the type that we expect. @@ -10831,6 +10957,7 @@ def test_get_definition_rest_interceptors(null_interceptor): req.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_fields.Definition.to_json(common_fields.Definition()) req.return_value.content = return_value @@ -10875,6 +11002,7 @@ def test_create_deployment_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_deployment(request) @@ -11011,6 +11139,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_deployment(request) # Establish that the response is the type that we expect. @@ -11054,6 +11183,7 @@ def test_create_deployment_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = common_fields.Deployment.to_json(common_fields.Deployment()) req.return_value.content = return_value @@ -11098,6 +11228,7 @@ def test_get_deployment_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_deployment(request) @@ -11138,6 +11269,7 @@ def test_get_deployment_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_deployment(request) # Establish that the response is the type that we expect. @@ -11181,6 +11313,7 @@ def test_get_deployment_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = common_fields.Deployment.to_json(common_fields.Deployment()) req.return_value.content = return_value @@ -11225,6 +11358,7 @@ def test_list_deployments_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_deployments(request) @@ -11260,6 +11394,7 @@ def test_list_deployments_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_deployments(request) # Establish that the response is the type that we expect. @@ -11298,6 +11433,7 @@ def test_list_deployments_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = apihub_service.ListDeploymentsResponse.to_json( apihub_service.ListDeploymentsResponse() ) @@ -11346,6 +11482,7 @@ def test_update_deployment_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_deployment(request) @@ -11484,6 +11621,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_deployment(request) # Establish that the response is the type that we expect. @@ -11527,6 +11665,7 @@ def test_update_deployment_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = common_fields.Deployment.to_json(common_fields.Deployment()) req.return_value.content = return_value @@ -11571,6 +11710,7 @@ def test_delete_deployment_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_deployment(request) @@ -11601,6 +11741,7 @@ def test_delete_deployment_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_deployment(request) # Establish that the response is the type that we expect. @@ -11635,6 +11776,7 @@ def test_delete_deployment_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = apihub_service.DeleteDeploymentRequest() metadata = [ @@ -11675,6 +11817,7 @@ def test_create_attribute_rest_bad_request( response_value.status_code = 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_attribute(request) @@ -11804,6 +11947,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_attribute(request) # Establish that the response is the type that we expect. @@ -11852,6 +11996,7 @@ def test_create_attribute_rest_interceptors(null_interceptor): req.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_fields.Attribute.to_json(common_fields.Attribute()) req.return_value.content = return_value @@ -11896,6 +12041,7 @@ def test_get_attribute_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_attribute(request) @@ -11938,6 +12084,7 @@ def test_get_attribute_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_attribute(request) # Establish that the response is the type that we expect. @@ -11986,6 +12133,7 @@ def test_get_attribute_rest_interceptors(null_interceptor): req.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_fields.Attribute.to_json(common_fields.Attribute()) req.return_value.content = return_value @@ -12032,6 +12180,7 @@ def test_update_attribute_rest_bad_request( response_value.status_code = 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_attribute(request) @@ -12163,6 +12312,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_attribute(request) # Establish that the response is the type that we expect. @@ -12211,6 +12361,7 @@ def test_update_attribute_rest_interceptors(null_interceptor): req.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_fields.Attribute.to_json(common_fields.Attribute()) req.return_value.content = return_value @@ -12255,6 +12406,7 @@ def test_delete_attribute_rest_bad_request( response_value.status_code = 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_attribute(request) @@ -12285,6 +12437,7 @@ def test_delete_attribute_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_attribute(request) # Establish that the response is the type that we expect. @@ -12319,6 +12472,7 @@ def test_delete_attribute_rest_interceptors(null_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 = apihub_service.DeleteAttributeRequest() metadata = [ @@ -12359,6 +12513,7 @@ def test_list_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.list_attributes(request) @@ -12394,6 +12549,7 @@ def test_list_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.list_attributes(request) # Establish that the response is the type that we expect. @@ -12432,6 +12588,7 @@ def test_list_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 = apihub_service.ListAttributesResponse.to_json( apihub_service.ListAttributesResponse() ) @@ -12478,6 +12635,7 @@ def test_search_resources_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.search_resources(request) @@ -12513,6 +12671,7 @@ def test_search_resources_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.search_resources(request) # Establish that the response is the type that we expect. @@ -12551,6 +12710,7 @@ def test_search_resources_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = apihub_service.SearchResourcesResponse.to_json( apihub_service.SearchResourcesResponse() ) @@ -12597,6 +12757,7 @@ def test_create_external_api_rest_bad_request( response_value.status_code = 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_api(request) @@ -12714,6 +12875,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_api(request) # Establish that the response is the type that we expect. @@ -12756,6 +12918,7 @@ def test_create_external_api_rest_interceptors(null_interceptor): req.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_fields.ExternalApi.to_json(common_fields.ExternalApi()) req.return_value.content = return_value @@ -12800,6 +12963,7 @@ def test_get_external_api_rest_bad_request( response_value.status_code = 400 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_api(request) @@ -12839,6 +13003,7 @@ def test_get_external_api_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_api(request) # Establish that the response is the type that we expect. @@ -12881,6 +13046,7 @@ def test_get_external_api_rest_interceptors(null_interceptor): req.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_fields.ExternalApi.to_json(common_fields.ExternalApi()) req.return_value.content = return_value @@ -12929,6 +13095,7 @@ def test_update_external_api_rest_bad_request( response_value.status_code = 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_api(request) @@ -13050,6 +13217,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_api(request) # Establish that the response is the type that we expect. @@ -13092,6 +13260,7 @@ def test_update_external_api_rest_interceptors(null_interceptor): req.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_fields.ExternalApi.to_json(common_fields.ExternalApi()) req.return_value.content = return_value @@ -13136,6 +13305,7 @@ def test_delete_external_api_rest_bad_request( response_value.status_code = 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_api(request) @@ -13166,6 +13336,7 @@ def test_delete_external_api_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_external_api(request) # Establish that the response is the type that we expect. @@ -13200,6 +13371,7 @@ def test_delete_external_api_rest_interceptors(null_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 = apihub_service.DeleteExternalApiRequest() metadata = [ @@ -13240,6 +13412,7 @@ def test_list_external_apis_rest_bad_request( response_value.status_code = 400 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_apis(request) @@ -13275,6 +13448,7 @@ def test_list_external_apis_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_apis(request) # Establish that the response is the type that we expect. @@ -13313,6 +13487,7 @@ def test_list_external_apis_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = apihub_service.ListExternalApisResponse.to_json( apihub_service.ListExternalApisResponse() ) @@ -13359,6 +13534,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) @@ -13389,6 +13565,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) @@ -13417,6 +13594,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) @@ -13447,6 +13625,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) @@ -13477,6 +13656,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) @@ -13507,6 +13687,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) @@ -13537,6 +13718,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) @@ -13567,6 +13749,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) @@ -13597,6 +13780,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) @@ -13627,6 +13811,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) @@ -13657,6 +13842,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) @@ -13687,6 +13873,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-apihub/tests/unit/gapic/apihub_v1/test_api_hub_dependencies.py b/packages/google-cloud-apihub/tests/unit/gapic/apihub_v1/test_api_hub_dependencies.py index 576d49cc9b83..0f2b7a7b4cbf 100644 --- a/packages/google-cloud-apihub/tests/unit/gapic/apihub_v1/test_api_hub_dependencies.py +++ b/packages/google-cloud-apihub/tests/unit/gapic/apihub_v1/test_api_hub_dependencies.py @@ -1038,6 +1038,7 @@ def test_create_dependency_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_dependency(request) @@ -1093,6 +1094,7 @@ def test_create_dependency_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_dependency(**mock_args) @@ -1226,6 +1228,7 @@ def test_get_dependency_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_dependency(request) @@ -1273,6 +1276,7 @@ def test_get_dependency_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_dependency(**mock_args) @@ -1404,6 +1408,7 @@ def test_update_dependency_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_dependency(request) @@ -1462,6 +1467,7 @@ def test_update_dependency_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_dependency(**mock_args) @@ -1593,6 +1599,7 @@ def test_delete_dependency_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_dependency(request) @@ -1638,6 +1645,7 @@ def test_delete_dependency_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_dependency(**mock_args) @@ -1779,6 +1787,7 @@ def test_list_dependencies_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_dependencies(request) @@ -1833,6 +1842,7 @@ def test_list_dependencies_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_dependencies(**mock_args) @@ -2028,6 +2038,7 @@ def test_create_dependency_rest_bad_request( response_value.status_code = 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_dependency(request) @@ -2149,6 +2160,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_dependency(request) # Establish that the response is the type that we expect. @@ -2192,6 +2204,7 @@ def test_create_dependency_rest_interceptors(null_interceptor): req.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_fields.Dependency.to_json(common_fields.Dependency()) req.return_value.content = return_value @@ -2236,6 +2249,7 @@ def test_get_dependency_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_dependency(request) @@ -2274,6 +2288,7 @@ def test_get_dependency_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_dependency(request) # Establish that the response is the type that we expect. @@ -2317,6 +2332,7 @@ def test_get_dependency_rest_interceptors(null_interceptor): req.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_fields.Dependency.to_json(common_fields.Dependency()) req.return_value.content = return_value @@ -2365,6 +2381,7 @@ def test_update_dependency_rest_bad_request( response_value.status_code = 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_dependency(request) @@ -2490,6 +2507,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_dependency(request) # Establish that the response is the type that we expect. @@ -2533,6 +2551,7 @@ def test_update_dependency_rest_interceptors(null_interceptor): req.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_fields.Dependency.to_json(common_fields.Dependency()) req.return_value.content = return_value @@ -2577,6 +2596,7 @@ def test_delete_dependency_rest_bad_request( response_value.status_code = 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_dependency(request) @@ -2607,6 +2627,7 @@ def test_delete_dependency_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_dependency(request) # Establish that the response is the type that we expect. @@ -2643,6 +2664,7 @@ def test_delete_dependency_rest_interceptors(null_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 = apihub_service.DeleteDependencyRequest() metadata = [ @@ -2683,6 +2705,7 @@ def test_list_dependencies_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_dependencies(request) @@ -2718,6 +2741,7 @@ def test_list_dependencies_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_dependencies(request) # Establish that the response is the type that we expect. @@ -2758,6 +2782,7 @@ def test_list_dependencies_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = apihub_service.ListDependenciesResponse.to_json( apihub_service.ListDependenciesResponse() ) @@ -2804,6 +2829,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) @@ -2834,6 +2860,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) @@ -2862,6 +2889,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) @@ -2892,6 +2920,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) @@ -2922,6 +2951,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) @@ -2952,6 +2982,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) @@ -2982,6 +3013,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) @@ -3012,6 +3044,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) @@ -3042,6 +3075,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) @@ -3072,6 +3106,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) @@ -3102,6 +3137,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) @@ -3132,6 +3168,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-apihub/tests/unit/gapic/apihub_v1/test_api_hub_plugin.py b/packages/google-cloud-apihub/tests/unit/gapic/apihub_v1/test_api_hub_plugin.py index 51b127a5a5f7..d90cab162dae 100644 --- a/packages/google-cloud-apihub/tests/unit/gapic/apihub_v1/test_api_hub_plugin.py +++ b/packages/google-cloud-apihub/tests/unit/gapic/apihub_v1/test_api_hub_plugin.py @@ -979,6 +979,7 @@ def test_get_plugin_rest_required_fields(request_type=plugin_service.GetPluginRe response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_plugin(request) @@ -1024,6 +1025,7 @@ def test_get_plugin_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_plugin(**mock_args) @@ -1155,6 +1157,7 @@ def test_enable_plugin_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.enable_plugin(request) @@ -1200,6 +1203,7 @@ def test_enable_plugin_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.enable_plugin(**mock_args) @@ -1332,6 +1336,7 @@ def test_disable_plugin_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.disable_plugin(request) @@ -1377,6 +1382,7 @@ def test_disable_plugin_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.disable_plugin(**mock_args) @@ -1507,6 +1513,7 @@ def test_get_plugin_rest_bad_request(request_type=plugin_service.GetPluginReques response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_plugin(request) @@ -1545,6 +1552,7 @@ def test_get_plugin_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_plugin(request) # Establish that the response is the type that we expect. @@ -1588,6 +1596,7 @@ def test_get_plugin_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = plugin_service.Plugin.to_json(plugin_service.Plugin()) req.return_value.content = return_value @@ -1632,6 +1641,7 @@ def test_enable_plugin_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.enable_plugin(request) @@ -1670,6 +1680,7 @@ def test_enable_plugin_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.enable_plugin(request) # Establish that the response is the type that we expect. @@ -1713,6 +1724,7 @@ def test_enable_plugin_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = plugin_service.Plugin.to_json(plugin_service.Plugin()) req.return_value.content = return_value @@ -1757,6 +1769,7 @@ def test_disable_plugin_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.disable_plugin(request) @@ -1795,6 +1808,7 @@ def test_disable_plugin_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.disable_plugin(request) # Establish that the response is the type that we expect. @@ -1838,6 +1852,7 @@ def test_disable_plugin_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = plugin_service.Plugin.to_json(plugin_service.Plugin()) req.return_value.content = return_value @@ -1882,6 +1897,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) @@ -1912,6 +1928,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) @@ -1940,6 +1957,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) @@ -1970,6 +1988,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) @@ -2000,6 +2019,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) @@ -2030,6 +2050,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) @@ -2060,6 +2081,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) @@ -2090,6 +2112,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) @@ -2120,6 +2143,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) @@ -2150,6 +2174,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) @@ -2180,6 +2205,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) @@ -2210,6 +2236,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-apihub/tests/unit/gapic/apihub_v1/test_host_project_registration_service.py b/packages/google-cloud-apihub/tests/unit/gapic/apihub_v1/test_host_project_registration_service.py index c5d1ab19ecec..645a06d5663f 100644 --- a/packages/google-cloud-apihub/tests/unit/gapic/apihub_v1/test_host_project_registration_service.py +++ b/packages/google-cloud-apihub/tests/unit/gapic/apihub_v1/test_host_project_registration_service.py @@ -1094,6 +1094,7 @@ def test_create_host_project_registration_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_host_project_registration(request) @@ -1162,6 +1163,7 @@ def test_create_host_project_registration_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_host_project_registration(**mock_args) @@ -1304,6 +1306,7 @@ def test_get_host_project_registration_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_host_project_registration(request) @@ -1355,6 +1358,7 @@ def test_get_host_project_registration_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_host_project_registration(**mock_args) @@ -1504,6 +1508,7 @@ def test_list_host_project_registrations_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_host_project_registrations(request) @@ -1567,6 +1572,7 @@ def test_list_host_project_registrations_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_host_project_registrations(**mock_args) @@ -1770,6 +1776,7 @@ def test_create_host_project_registration_rest_bad_request( response_value.status_code = 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_host_project_registration(request) @@ -1886,6 +1893,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_host_project_registration(request) # Establish that the response is the type that we expect. @@ -1933,6 +1941,7 @@ def test_create_host_project_registration_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = ( host_project_registration_service.HostProjectRegistration.to_json( host_project_registration_service.HostProjectRegistration() @@ -1985,6 +1994,7 @@ def test_get_host_project_registration_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_host_project_registration(request) @@ -2025,6 +2035,7 @@ def test_get_host_project_registration_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_host_project_registration(request) # Establish that the response is the type that we expect. @@ -2072,6 +2083,7 @@ def test_get_host_project_registration_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = ( host_project_registration_service.HostProjectRegistration.to_json( host_project_registration_service.HostProjectRegistration() @@ -2120,6 +2132,7 @@ def test_list_host_project_registrations_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_host_project_registrations(request) @@ -2161,6 +2174,7 @@ def test_list_host_project_registrations_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_host_project_registrations(request) # Establish that the response is the type that we expect. @@ -2205,6 +2219,7 @@ def test_list_host_project_registrations_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = host_project_registration_service.ListHostProjectRegistrationsResponse.to_json( host_project_registration_service.ListHostProjectRegistrationsResponse() ) @@ -2255,6 +2270,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) @@ -2285,6 +2301,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) @@ -2313,6 +2330,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) @@ -2343,6 +2361,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) @@ -2373,6 +2392,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) @@ -2403,6 +2423,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) @@ -2433,6 +2454,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) @@ -2463,6 +2485,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) @@ -2493,6 +2516,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) @@ -2523,6 +2547,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) @@ -2553,6 +2578,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) @@ -2583,6 +2609,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-apihub/tests/unit/gapic/apihub_v1/test_linting_service.py b/packages/google-cloud-apihub/tests/unit/gapic/apihub_v1/test_linting_service.py index 3dd2b4a666d9..0971bf3da968 100644 --- a/packages/google-cloud-apihub/tests/unit/gapic/apihub_v1/test_linting_service.py +++ b/packages/google-cloud-apihub/tests/unit/gapic/apihub_v1/test_linting_service.py @@ -999,6 +999,7 @@ def test_get_style_guide_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_style_guide(request) @@ -1046,6 +1047,7 @@ def test_get_style_guide_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_style_guide(**mock_args) @@ -1179,6 +1181,7 @@ def test_update_style_guide_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_style_guide(request) @@ -1229,6 +1232,7 @@ def test_update_style_guide_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_style_guide(**mock_args) @@ -1366,6 +1370,7 @@ def test_get_style_guide_contents_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_style_guide_contents(request) @@ -1413,6 +1418,7 @@ def test_get_style_guide_contents_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_style_guide_contents(**mock_args) @@ -1540,6 +1546,7 @@ def test_lint_spec_rest_required_fields(request_type=linting_service.LintSpecReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.lint_spec(request) @@ -1662,6 +1669,7 @@ def test_get_style_guide_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_style_guide(request) @@ -1700,6 +1708,7 @@ def test_get_style_guide_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_style_guide(request) # Establish that the response is the type that we expect. @@ -1741,6 +1750,7 @@ def test_get_style_guide_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = linting_service.StyleGuide.to_json(linting_service.StyleGuide()) req.return_value.content = return_value @@ -1789,6 +1799,7 @@ def test_update_style_guide_rest_bad_request( response_value.status_code = 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_style_guide(request) @@ -1901,6 +1912,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_style_guide(request) # Establish that the response is the type that we expect. @@ -1942,6 +1954,7 @@ def test_update_style_guide_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = linting_service.StyleGuide.to_json(linting_service.StyleGuide()) req.return_value.content = return_value @@ -1988,6 +2001,7 @@ def test_get_style_guide_contents_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_style_guide_contents(request) @@ -2026,6 +2040,7 @@ def test_get_style_guide_contents_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_style_guide_contents(request) # Establish that the response is the type that we expect. @@ -2067,6 +2082,7 @@ def test_get_style_guide_contents_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = linting_service.StyleGuideContents.to_json( linting_service.StyleGuideContents() ) @@ -2113,6 +2129,7 @@ def test_lint_spec_rest_bad_request(request_type=linting_service.LintSpecRequest response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.lint_spec(request) @@ -2145,6 +2162,7 @@ def test_lint_spec_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.lint_spec(request) # Establish that the response is the type that we expect. @@ -2181,6 +2199,7 @@ def test_lint_spec_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = linting_service.LintSpecRequest() metadata = [ @@ -2221,6 +2240,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) @@ -2251,6 +2271,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) @@ -2279,6 +2300,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) @@ -2309,6 +2331,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) @@ -2339,6 +2362,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) @@ -2369,6 +2393,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) @@ -2399,6 +2424,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) @@ -2429,6 +2455,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) @@ -2459,6 +2486,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) @@ -2489,6 +2517,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) @@ -2519,6 +2548,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) @@ -2549,6 +2579,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-apihub/tests/unit/gapic/apihub_v1/test_provisioning.py b/packages/google-cloud-apihub/tests/unit/gapic/apihub_v1/test_provisioning.py index aea58fb4b312..d1d2ff5a7526 100644 --- a/packages/google-cloud-apihub/tests/unit/gapic/apihub_v1/test_provisioning.py +++ b/packages/google-cloud-apihub/tests/unit/gapic/apihub_v1/test_provisioning.py @@ -997,6 +997,7 @@ def test_create_api_hub_instance_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_api_hub_instance(request) @@ -1050,6 +1051,7 @@ def test_create_api_hub_instance_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_api_hub_instance(**mock_args) @@ -1187,6 +1189,7 @@ def test_get_api_hub_instance_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_api_hub_instance(request) @@ -1234,6 +1237,7 @@ def test_get_api_hub_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_api_hub_instance(**mock_args) @@ -1372,6 +1376,7 @@ def test_lookup_api_hub_instance_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.lookup_api_hub_instance(request) @@ -1419,6 +1424,7 @@ def test_lookup_api_hub_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.lookup_api_hub_instance(**mock_args) @@ -1551,6 +1557,7 @@ def test_create_api_hub_instance_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_api_hub_instance(request) @@ -1660,6 +1667,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_api_hub_instance(request) # Establish that the response is the type that we expect. @@ -1701,6 +1709,7 @@ def test_create_api_hub_instance_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -1747,6 +1756,7 @@ def test_get_api_hub_instance_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_api_hub_instance(request) @@ -1787,6 +1797,7 @@ def test_get_api_hub_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_api_hub_instance(request) # Establish that the response is the type that we expect. @@ -1830,6 +1841,7 @@ def test_get_api_hub_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 = common_fields.ApiHubInstance.to_json( common_fields.ApiHubInstance() ) @@ -1876,6 +1888,7 @@ def test_lookup_api_hub_instance_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.lookup_api_hub_instance(request) @@ -1911,6 +1924,7 @@ def test_lookup_api_hub_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.lookup_api_hub_instance(request) # Establish that the response is the type that we expect. @@ -1950,6 +1964,7 @@ def test_lookup_api_hub_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 = provisioning_service.LookupApiHubInstanceResponse.to_json( provisioning_service.LookupApiHubInstanceResponse() ) @@ -1996,6 +2011,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) @@ -2026,6 +2042,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) @@ -2054,6 +2071,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) @@ -2084,6 +2102,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) @@ -2114,6 +2133,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) @@ -2144,6 +2164,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) @@ -2174,6 +2195,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) @@ -2204,6 +2226,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) @@ -2234,6 +2257,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) @@ -2264,6 +2288,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) @@ -2294,6 +2319,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) @@ -2324,6 +2350,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-apihub/tests/unit/gapic/apihub_v1/test_runtime_project_attachment_service.py b/packages/google-cloud-apihub/tests/unit/gapic/apihub_v1/test_runtime_project_attachment_service.py index 9ca7085c4847..895ab6aec87d 100644 --- a/packages/google-cloud-apihub/tests/unit/gapic/apihub_v1/test_runtime_project_attachment_service.py +++ b/packages/google-cloud-apihub/tests/unit/gapic/apihub_v1/test_runtime_project_attachment_service.py @@ -1100,6 +1100,7 @@ def test_create_runtime_project_attachment_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_runtime_project_attachment(request) @@ -1168,6 +1169,7 @@ def test_create_runtime_project_attachment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_runtime_project_attachment(**mock_args) @@ -1314,6 +1316,7 @@ def test_get_runtime_project_attachment_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_runtime_project_attachment(request) @@ -1365,6 +1368,7 @@ def test_get_runtime_project_attachment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_runtime_project_attachment(**mock_args) @@ -1514,6 +1518,7 @@ def test_list_runtime_project_attachments_rest_required_fields( response_value._content = json_return_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_project_attachments(request) @@ -1577,6 +1582,7 @@ def test_list_runtime_project_attachments_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_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_project_attachments(**mock_args) @@ -1781,6 +1787,7 @@ def test_delete_runtime_project_attachment_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_runtime_project_attachment(request) @@ -1828,6 +1835,7 @@ def test_delete_runtime_project_attachment_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_runtime_project_attachment(**mock_args) @@ -1970,6 +1978,7 @@ def test_lookup_runtime_project_attachment_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.lookup_runtime_project_attachment(request) @@ -2021,6 +2030,7 @@ def test_lookup_runtime_project_attachment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.lookup_runtime_project_attachment(**mock_args) @@ -2155,6 +2165,7 @@ def test_create_runtime_project_attachment_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_runtime_project_attachment(request) @@ -2271,6 +2282,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_runtime_project_attachment(request) # Establish that the response is the type that we expect. @@ -2316,6 +2328,7 @@ def test_create_runtime_project_attachment_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = ( runtime_project_attachment_service.RuntimeProjectAttachment.to_json( runtime_project_attachment_service.RuntimeProjectAttachment() @@ -2370,6 +2383,7 @@ def test_get_runtime_project_attachment_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_runtime_project_attachment(request) @@ -2410,6 +2424,7 @@ def test_get_runtime_project_attachment_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_runtime_project_attachment(request) # Establish that the response is the type that we expect. @@ -2457,6 +2472,7 @@ def test_get_runtime_project_attachment_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = ( runtime_project_attachment_service.RuntimeProjectAttachment.to_json( runtime_project_attachment_service.RuntimeProjectAttachment() @@ -2509,6 +2525,7 @@ def test_list_runtime_project_attachments_rest_bad_request( response_value.status_code = 400 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_project_attachments(request) @@ -2550,6 +2567,7 @@ def test_list_runtime_project_attachments_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_project_attachments(request) # Establish that the response is the type that we expect. @@ -2592,6 +2610,7 @@ def test_list_runtime_project_attachments_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = runtime_project_attachment_service.ListRuntimeProjectAttachmentsResponse.to_json( runtime_project_attachment_service.ListRuntimeProjectAttachmentsResponse() ) @@ -2644,6 +2663,7 @@ def test_delete_runtime_project_attachment_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_runtime_project_attachment(request) @@ -2676,6 +2696,7 @@ def test_delete_runtime_project_attachment_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_runtime_project_attachment(request) # Establish that the response is the type that we expect. @@ -2713,6 +2734,7 @@ def test_delete_runtime_project_attachment_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = ( runtime_project_attachment_service.DeleteRuntimeProjectAttachmentRequest() @@ -2755,6 +2777,7 @@ def test_lookup_runtime_project_attachment_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.lookup_runtime_project_attachment(request) @@ -2792,6 +2815,7 @@ def test_lookup_runtime_project_attachment_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.lookup_runtime_project_attachment(request) # Establish that the response is the type that we expect. @@ -2836,6 +2860,7 @@ def test_lookup_runtime_project_attachment_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = runtime_project_attachment_service.LookupRuntimeProjectAttachmentResponse.to_json( runtime_project_attachment_service.LookupRuntimeProjectAttachmentResponse() ) @@ -2886,6 +2911,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) @@ -2916,6 +2942,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) @@ -2944,6 +2971,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) @@ -2974,6 +3002,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) @@ -3004,6 +3033,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) @@ -3034,6 +3064,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) @@ -3064,6 +3095,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) @@ -3094,6 +3126,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) @@ -3124,6 +3157,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) @@ -3154,6 +3188,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) @@ -3184,6 +3219,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) @@ -3214,6 +3250,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-appengine-admin/google/cloud/appengine_admin/gapic_version.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin/gapic_version.py index 49ddc22ee702..558c8aab67c5 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin/gapic_version.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.12.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/gapic_version.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/gapic_version.py index 49ddc22ee702..558c8aab67c5 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/gapic_version.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.12.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/async_client.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/async_client.py index 2cc4ae19de5c..b1ec2f082c46 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/async_client.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/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, ApplicationsTransport from .transports.grpc_asyncio import ApplicationsGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class ApplicationsAsyncClient: """Manages App Engine applications.""" @@ -252,6 +262,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.appengine_v1.ApplicationsAsyncClient`.", + extra={ + "serviceName": "google.appengine.v1.Applications", + "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.appengine.v1.Applications", + "credentialsType": None, + }, + ) + async def get_application( self, request: Optional[Union[appengine.GetApplicationRequest, dict]] = None, @@ -259,7 +291,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]]] = (), ) -> application.Application: r"""Gets information about an application. @@ -301,8 +333,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.appengine_admin_v1.types.Application: @@ -363,7 +397,7 @@ async def create_application( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 App Engine application for a Google Cloud Platform project. Required fields: @@ -412,8 +446,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: @@ -463,7 +499,7 @@ async def update_application( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 Application resource. You can update the following fields: @@ -510,8 +546,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: @@ -567,7 +605,7 @@ async def repair_application( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Recreates the required App Engine features for the specified App Engine application, for example a Cloud Storage bucket or App @@ -617,8 +655,10 @@ async def sample_repair_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: diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/client.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/client.py index 8c9c44b9389d..7897b1713042 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/client.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/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 as gac_operation # type: ignore from google.api_core import operation_async # type: ignore from google.protobuf import duration_pb2 # type: ignore @@ -558,6 +568,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -620,6 +634,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.appengine_v1.ApplicationsClient`.", + extra={ + "serviceName": "google.appengine.v1.Applications", + "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.appengine.v1.Applications", + "credentialsType": None, + }, + ) + def get_application( self, request: Optional[Union[appengine.GetApplicationRequest, dict]] = None, @@ -627,7 +664,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]]] = (), ) -> application.Application: r"""Gets information about an application. @@ -669,8 +706,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.appengine_admin_v1.types.Application: @@ -728,7 +767,7 @@ def create_application( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gac_operation.Operation: r"""Creates an App Engine application for a Google Cloud Platform project. Required fields: @@ -777,8 +816,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: @@ -826,7 +867,7 @@ def update_application( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gac_operation.Operation: r"""Updates the specified Application resource. You can update the following fields: @@ -873,8 +914,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: @@ -928,7 +971,7 @@ def repair_application( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gac_operation.Operation: r"""Recreates the required App Engine features for the specified App Engine application, for example a Cloud Storage bucket or App @@ -978,8 +1021,10 @@ def sample_repair_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: diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/transports/grpc.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/transports/grpc.py index 29ab4dafa1ff..525d7f450837 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/transports/grpc.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/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.appengine_admin_v1.types import appengine, application from .base import DEFAULT_CLIENT_INFO, ApplicationsTransport +try: + from google.api_core import client_logging # 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.appengine.v1.Applications", + "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.appengine.v1.Applications", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ApplicationsGrpcTransport(ApplicationsTransport): """gRPC backend transport for Applications. @@ -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 @@ -269,7 +357,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.appengine.v1.Applications/GetApplication", request_serializer=appengine.GetApplicationRequest.serialize, response_deserializer=application.Application.deserialize, @@ -305,7 +393,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.appengine.v1.Applications/CreateApplication", request_serializer=appengine.CreateApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -339,7 +427,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.appengine.v1.Applications/UpdateApplication", request_serializer=appengine.UpdateApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -375,7 +463,7 @@ def repair_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "repair_application" not in self._stubs: - self._stubs["repair_application"] = self.grpc_channel.unary_unary( + self._stubs["repair_application"] = self._logged_channel.unary_unary( "/google.appengine.v1.Applications/RepairApplication", request_serializer=appengine.RepairApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -383,7 +471,7 @@ def repair_application( return self._stubs["repair_application"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/transports/grpc_asyncio.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/transports/grpc_asyncio.py index 6f9372de9f19..1b3093e4c4f5 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/transports/grpc_asyncio.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/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.appengine_admin_v1.types import appengine, application from .base import DEFAULT_CLIENT_INFO, ApplicationsTransport from .grpc import ApplicationsGrpcTransport +try: + from google.api_core import client_logging # 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.appengine.v1.Applications", + "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.appengine.v1.Applications", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ApplicationsGrpcAsyncIOTransport(ApplicationsTransport): """gRPC AsyncIO backend transport for Applications. @@ -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. @@ -281,7 +366,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.appengine.v1.Applications/GetApplication", request_serializer=appengine.GetApplicationRequest.serialize, response_deserializer=application.Application.deserialize, @@ -319,7 +404,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.appengine.v1.Applications/CreateApplication", request_serializer=appengine.CreateApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -355,7 +440,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.appengine.v1.Applications/UpdateApplication", request_serializer=appengine.UpdateApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -393,7 +478,7 @@ def repair_application( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "repair_application" not in self._stubs: - self._stubs["repair_application"] = self.grpc_channel.unary_unary( + self._stubs["repair_application"] = self._logged_channel.unary_unary( "/google.appengine.v1.Applications/RepairApplication", request_serializer=appengine.RepairApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -431,7 +516,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-appengine-admin/google/cloud/appengine_admin_v1/services/applications/transports/rest.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/transports/rest.py index f500cd2d13fc..9d60835f0d57 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/transports/rest.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/applications/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,8 +110,10 @@ def post_update_application(self, response): def pre_create_application( self, request: appengine.CreateApplicationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[appengine.CreateApplicationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + appengine.CreateApplicationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_application Override in a subclass to manipulate the request or metadata @@ -125,8 +135,10 @@ def post_create_application( def pre_get_application( self, request: appengine.GetApplicationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[appengine.GetApplicationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + appengine.GetApplicationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_application Override in a subclass to manipulate the request or metadata @@ -148,8 +160,10 @@ def post_get_application( def pre_repair_application( self, request: appengine.RepairApplicationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[appengine.RepairApplicationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + appengine.RepairApplicationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for repair_application Override in a subclass to manipulate the request or metadata @@ -171,8 +185,10 @@ def post_repair_application( def pre_update_application( self, request: appengine.UpdateApplicationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[appengine.UpdateApplicationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + appengine.UpdateApplicationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_application Override in a subclass to manipulate the request or metadata @@ -354,7 +370,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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. @@ -364,8 +380,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -378,6 +396,7 @@ def __call__( http_options = ( _BaseApplicationsRestTransport._BaseCreateApplication._get_http_options() ) + request, metadata = self._interceptor.pre_create_application( request, metadata ) @@ -394,6 +413,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.appengine_v1.ApplicationsClient.CreateApplication", + extra={ + "serviceName": "google.appengine.v1.Applications", + "rpcName": "CreateApplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApplicationsRestTransport._CreateApplication._get_response( self._host, @@ -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_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.appengine_v1.ApplicationsClient.create_application", + extra={ + "serviceName": "google.appengine.v1.Applications", + "rpcName": "CreateApplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetApplication( @@ -450,7 +518,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> application.Application: r"""Call the get application method over HTTP. @@ -460,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: ~.application.Application: @@ -474,6 +544,7 @@ def __call__( http_options = ( _BaseApplicationsRestTransport._BaseGetApplication._get_http_options() ) + request, metadata = self._interceptor.pre_get_application(request, metadata) transcoded_request = _BaseApplicationsRestTransport._BaseGetApplication._get_transcoded_request( http_options, request @@ -484,6 +555,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.appengine_v1.ApplicationsClient.GetApplication", + extra={ + "serviceName": "google.appengine.v1.Applications", + "rpcName": "GetApplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApplicationsRestTransport._GetApplication._get_response( self._host, @@ -504,7 +602,29 @@ def __call__( pb_resp = application.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 = application.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.appengine_v1.ApplicationsClient.get_application", + extra={ + "serviceName": "google.appengine.v1.Applications", + "rpcName": "GetApplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RepairApplication( @@ -542,7 +662,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 application method over HTTP. @@ -553,8 +673,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -567,6 +689,7 @@ def __call__( http_options = ( _BaseApplicationsRestTransport._BaseRepairApplication._get_http_options() ) + request, metadata = self._interceptor.pre_repair_application( request, metadata ) @@ -583,6 +706,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.appengine_v1.ApplicationsClient.RepairApplication", + extra={ + "serviceName": "google.appengine.v1.Applications", + "rpcName": "RepairApplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApplicationsRestTransport._RepairApplication._get_response( self._host, @@ -602,7 +752,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_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.appengine_v1.ApplicationsClient.repair_application", + extra={ + "serviceName": "google.appengine.v1.Applications", + "rpcName": "RepairApplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateApplication( @@ -640,7 +812,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update application method over HTTP. @@ -650,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: @@ -664,6 +838,7 @@ def __call__( http_options = ( _BaseApplicationsRestTransport._BaseUpdateApplication._get_http_options() ) + request, metadata = self._interceptor.pre_update_application( request, metadata ) @@ -680,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.appengine_v1.ApplicationsClient.UpdateApplication", + extra={ + "serviceName": "google.appengine.v1.Applications", + "rpcName": "UpdateApplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ApplicationsRestTransport._UpdateApplication._get_response( self._host, @@ -699,7 +901,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.appengine_v1.ApplicationsClient.update_application", + extra={ + "serviceName": "google.appengine.v1.Applications", + "rpcName": "UpdateApplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_certificates/async_client.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_certificates/async_client.py index f50144f9ebd2..66dc6310f0f7 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_certificates/async_client.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_certificates/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, AuthorizedCertificatesTransport from .transports.grpc_asyncio import AuthorizedCertificatesGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class AuthorizedCertificatesAsyncClient: """Manages SSL certificates a user is authorized to administer. @@ -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.appengine_v1.AuthorizedCertificatesAsyncClient`.", + extra={ + "serviceName": "google.appengine.v1.AuthorizedCertificates", + "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.appengine.v1.AuthorizedCertificates", + "credentialsType": None, + }, + ) + async def list_authorized_certificates( self, request: Optional[ @@ -271,7 +303,7 @@ async def list_authorized_certificates( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAuthorizedCertificatesAsyncPager: r"""Lists all SSL certificates the user is authorized to administer. @@ -309,8 +341,10 @@ async def sample_list_authorized_certificates(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.appengine_admin_v1.services.authorized_certificates.pagers.ListAuthorizedCertificatesAsyncPager: @@ -372,7 +406,7 @@ async def get_authorized_certificate( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> certificate.AuthorizedCertificate: r"""Gets the specified SSL certificate. @@ -408,8 +442,10 @@ async def sample_get_authorized_certificate(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.appengine_admin_v1.types.AuthorizedCertificate: @@ -460,7 +496,7 @@ async def create_authorized_certificate( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> certificate.AuthorizedCertificate: r"""Uploads the specified SSL certificate. @@ -496,8 +532,10 @@ async def sample_create_authorized_certificate(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.appengine_admin_v1.types.AuthorizedCertificate: @@ -548,7 +586,7 @@ async def update_authorized_certificate( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> certificate.AuthorizedCertificate: r"""Updates the specified SSL certificate. To renew a certificate and maintain its existing domain mappings, update @@ -589,8 +627,10 @@ async def sample_update_authorized_certificate(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.appengine_admin_v1.types.AuthorizedCertificate: @@ -641,7 +681,7 @@ async def delete_authorized_certificate( *, retry: OptionalRetry = gapic_v1.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 SSL certificate. @@ -674,8 +714,10 @@ async def sample_delete_authorized_certificate(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_certificates/client.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_certificates/client.py index fab20c6c3455..3ad8ad264dc2 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_certificates/client.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_certificates/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.appengine_admin_v1.services.authorized_certificates import pagers @@ -567,6 +577,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -633,6 +647,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.appengine_v1.AuthorizedCertificatesClient`.", + extra={ + "serviceName": "google.appengine.v1.AuthorizedCertificates", + "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.appengine.v1.AuthorizedCertificates", + "credentialsType": None, + }, + ) + def list_authorized_certificates( self, request: Optional[ @@ -641,7 +678,7 @@ def list_authorized_certificates( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAuthorizedCertificatesPager: r"""Lists all SSL certificates the user is authorized to administer. @@ -679,8 +716,10 @@ def sample_list_authorized_certificates(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.appengine_admin_v1.services.authorized_certificates.pagers.ListAuthorizedCertificatesPager: @@ -742,7 +781,7 @@ def get_authorized_certificate( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> certificate.AuthorizedCertificate: r"""Gets the specified SSL certificate. @@ -778,8 +817,10 @@ def sample_get_authorized_certificate(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.appengine_admin_v1.types.AuthorizedCertificate: @@ -830,7 +871,7 @@ def create_authorized_certificate( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> certificate.AuthorizedCertificate: r"""Uploads the specified SSL certificate. @@ -866,8 +907,10 @@ def sample_create_authorized_certificate(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.appengine_admin_v1.types.AuthorizedCertificate: @@ -918,7 +961,7 @@ def update_authorized_certificate( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> certificate.AuthorizedCertificate: r"""Updates the specified SSL certificate. To renew a certificate and maintain its existing domain mappings, update @@ -959,8 +1002,10 @@ def sample_update_authorized_certificate(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.appengine_admin_v1.types.AuthorizedCertificate: @@ -1011,7 +1056,7 @@ def delete_authorized_certificate( *, retry: OptionalRetry = gapic_v1.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 SSL certificate. @@ -1044,8 +1089,10 @@ def sample_delete_authorized_certificate(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_certificates/pagers.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_certificates/pagers.py index d8cda102f4f4..e0a6f8f4766c 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_certificates/pagers.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_certificates/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = appengine.ListAuthorizedCertificatesRequest(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 = appengine.ListAuthorizedCertificatesRequest(request) diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_certificates/transports/grpc.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_certificates/transports/grpc.py index 9ec4a9e494b7..d695fc995306 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_certificates/transports/grpc.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_certificates/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.appengine_admin_v1.types import appengine, certificate from .base import DEFAULT_CLIENT_INFO, AuthorizedCertificatesTransport +try: + from google.api_core import client_logging # 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.appengine.v1.AuthorizedCertificates", + "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.appengine.v1.AuthorizedCertificates", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AuthorizedCertificatesGrpcTransport(AuthorizedCertificatesTransport): """gRPC backend transport for AuthorizedCertificates. @@ -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,9 @@ def list_authorized_certificates( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_authorized_certificates" not in self._stubs: - self._stubs["list_authorized_certificates"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_authorized_certificates" + ] = self._logged_channel.unary_unary( "/google.appengine.v1.AuthorizedCertificates/ListAuthorizedCertificates", request_serializer=appengine.ListAuthorizedCertificatesRequest.serialize, response_deserializer=appengine.ListAuthorizedCertificatesResponse.deserialize, @@ -288,7 +376,9 @@ def get_authorized_certificate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_authorized_certificate" not in self._stubs: - self._stubs["get_authorized_certificate"] = self.grpc_channel.unary_unary( + self._stubs[ + "get_authorized_certificate" + ] = self._logged_channel.unary_unary( "/google.appengine.v1.AuthorizedCertificates/GetAuthorizedCertificate", request_serializer=appengine.GetAuthorizedCertificateRequest.serialize, response_deserializer=certificate.AuthorizedCertificate.deserialize, @@ -319,7 +409,7 @@ def create_authorized_certificate( if "create_authorized_certificate" not in self._stubs: self._stubs[ "create_authorized_certificate" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.appengine.v1.AuthorizedCertificates/CreateAuthorizedCertificate", request_serializer=appengine.CreateAuthorizedCertificateRequest.serialize, response_deserializer=certificate.AuthorizedCertificate.deserialize, @@ -355,7 +445,7 @@ def update_authorized_certificate( if "update_authorized_certificate" not in self._stubs: self._stubs[ "update_authorized_certificate" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.appengine.v1.AuthorizedCertificates/UpdateAuthorizedCertificate", request_serializer=appengine.UpdateAuthorizedCertificateRequest.serialize, response_deserializer=certificate.AuthorizedCertificate.deserialize, @@ -383,7 +473,7 @@ def delete_authorized_certificate( if "delete_authorized_certificate" not in self._stubs: self._stubs[ "delete_authorized_certificate" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.appengine.v1.AuthorizedCertificates/DeleteAuthorizedCertificate", request_serializer=appengine.DeleteAuthorizedCertificateRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -391,7 +481,7 @@ def delete_authorized_certificate( return self._stubs["delete_authorized_certificate"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_certificates/transports/grpc_asyncio.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_certificates/transports/grpc_asyncio.py index 8af3b3be2da2..55246465f470 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_certificates/transports/grpc_asyncio.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_certificates/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.appengine_admin_v1.types import appengine, certificate from .base import DEFAULT_CLIENT_INFO, AuthorizedCertificatesTransport from .grpc import AuthorizedCertificatesGrpcTransport +try: + from google.api_core import client_logging # 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.appengine.v1.AuthorizedCertificates", + "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.appengine.v1.AuthorizedCertificates", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AuthorizedCertificatesGrpcAsyncIOTransport(AuthorizedCertificatesTransport): """gRPC AsyncIO backend transport for AuthorizedCertificates. @@ -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,9 @@ def list_authorized_certificates( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_authorized_certificates" not in self._stubs: - self._stubs["list_authorized_certificates"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_authorized_certificates" + ] = self._logged_channel.unary_unary( "/google.appengine.v1.AuthorizedCertificates/ListAuthorizedCertificates", request_serializer=appengine.ListAuthorizedCertificatesRequest.serialize, response_deserializer=appengine.ListAuthorizedCertificatesResponse.deserialize, @@ -297,7 +384,9 @@ def get_authorized_certificate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_authorized_certificate" not in self._stubs: - self._stubs["get_authorized_certificate"] = self.grpc_channel.unary_unary( + self._stubs[ + "get_authorized_certificate" + ] = self._logged_channel.unary_unary( "/google.appengine.v1.AuthorizedCertificates/GetAuthorizedCertificate", request_serializer=appengine.GetAuthorizedCertificateRequest.serialize, response_deserializer=certificate.AuthorizedCertificate.deserialize, @@ -328,7 +417,7 @@ def create_authorized_certificate( if "create_authorized_certificate" not in self._stubs: self._stubs[ "create_authorized_certificate" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.appengine.v1.AuthorizedCertificates/CreateAuthorizedCertificate", request_serializer=appengine.CreateAuthorizedCertificateRequest.serialize, response_deserializer=certificate.AuthorizedCertificate.deserialize, @@ -364,7 +453,7 @@ def update_authorized_certificate( if "update_authorized_certificate" not in self._stubs: self._stubs[ "update_authorized_certificate" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.appengine.v1.AuthorizedCertificates/UpdateAuthorizedCertificate", request_serializer=appengine.UpdateAuthorizedCertificateRequest.serialize, response_deserializer=certificate.AuthorizedCertificate.deserialize, @@ -394,7 +483,7 @@ def delete_authorized_certificate( if "delete_authorized_certificate" not in self._stubs: self._stubs[ "delete_authorized_certificate" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.appengine.v1.AuthorizedCertificates/DeleteAuthorizedCertificate", request_serializer=appengine.DeleteAuthorizedCertificateRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -437,7 +526,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-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_certificates/transports/rest.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_certificates/transports/rest.py index 0409e0fa556e..5710cbbe06f0 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_certificates/transports/rest.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_certificates/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -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, @@ -106,8 +114,11 @@ def post_update_authorized_certificate(self, response): def pre_create_authorized_certificate( self, request: appengine.CreateAuthorizedCertificateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[appengine.CreateAuthorizedCertificateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + appengine.CreateAuthorizedCertificateRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_authorized_certificate Override in a subclass to manipulate the request or metadata @@ -129,8 +140,11 @@ def post_create_authorized_certificate( def pre_delete_authorized_certificate( self, request: appengine.DeleteAuthorizedCertificateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[appengine.DeleteAuthorizedCertificateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + appengine.DeleteAuthorizedCertificateRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_authorized_certificate Override in a subclass to manipulate the request or metadata @@ -141,8 +155,11 @@ def pre_delete_authorized_certificate( def pre_get_authorized_certificate( self, request: appengine.GetAuthorizedCertificateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[appengine.GetAuthorizedCertificateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + appengine.GetAuthorizedCertificateRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_authorized_certificate Override in a subclass to manipulate the request or metadata @@ -164,8 +181,11 @@ def post_get_authorized_certificate( def pre_list_authorized_certificates( self, request: appengine.ListAuthorizedCertificatesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[appengine.ListAuthorizedCertificatesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + appengine.ListAuthorizedCertificatesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_authorized_certificates Override in a subclass to manipulate the request or metadata @@ -187,8 +207,11 @@ def post_list_authorized_certificates( def pre_update_authorized_certificate( self, request: appengine.UpdateAuthorizedCertificateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[appengine.UpdateAuthorizedCertificateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + appengine.UpdateAuthorizedCertificateRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_authorized_certificate Override in a subclass to manipulate the request or metadata @@ -334,7 +357,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> certificate.AuthorizedCertificate: r"""Call the create authorized certificate method over HTTP. @@ -346,8 +369,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.certificate.AuthorizedCertificate: @@ -362,6 +387,7 @@ def __call__( http_options = ( _BaseAuthorizedCertificatesRestTransport._BaseCreateAuthorizedCertificate._get_http_options() ) + request, metadata = self._interceptor.pre_create_authorized_certificate( request, metadata ) @@ -378,6 +404,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.appengine_v1.AuthorizedCertificatesClient.CreateAuthorizedCertificate", + extra={ + "serviceName": "google.appengine.v1.AuthorizedCertificates", + "rpcName": "CreateAuthorizedCertificate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AuthorizedCertificatesRestTransport._CreateAuthorizedCertificate._get_response( self._host, @@ -399,7 +452,31 @@ def __call__( pb_resp = certificate.AuthorizedCertificate.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_authorized_certificate(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = certificate.AuthorizedCertificate.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.appengine_v1.AuthorizedCertificatesClient.create_authorized_certificate", + extra={ + "serviceName": "google.appengine.v1.AuthorizedCertificates", + "rpcName": "CreateAuthorizedCertificate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteAuthorizedCertificate( @@ -439,7 +516,7 @@ 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 authorized certificate method over HTTP. @@ -451,13 +528,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 = ( _BaseAuthorizedCertificatesRestTransport._BaseDeleteAuthorizedCertificate._get_http_options() ) + request, metadata = self._interceptor.pre_delete_authorized_certificate( request, metadata ) @@ -470,6 +550,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.appengine_v1.AuthorizedCertificatesClient.DeleteAuthorizedCertificate", + extra={ + "serviceName": "google.appengine.v1.AuthorizedCertificates", + "rpcName": "DeleteAuthorizedCertificate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AuthorizedCertificatesRestTransport._DeleteAuthorizedCertificate._get_response( self._host, @@ -520,7 +627,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> certificate.AuthorizedCertificate: r"""Call the get authorized certificate method over HTTP. @@ -532,8 +639,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.certificate.AuthorizedCertificate: @@ -548,6 +657,7 @@ def __call__( http_options = ( _BaseAuthorizedCertificatesRestTransport._BaseGetAuthorizedCertificate._get_http_options() ) + request, metadata = self._interceptor.pre_get_authorized_certificate( request, metadata ) @@ -560,6 +670,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.appengine_v1.AuthorizedCertificatesClient.GetAuthorizedCertificate", + extra={ + "serviceName": "google.appengine.v1.AuthorizedCertificates", + "rpcName": "GetAuthorizedCertificate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AuthorizedCertificatesRestTransport._GetAuthorizedCertificate._get_response( self._host, @@ -580,7 +717,31 @@ def __call__( pb_resp = certificate.AuthorizedCertificate.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_authorized_certificate(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = certificate.AuthorizedCertificate.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.appengine_v1.AuthorizedCertificatesClient.get_authorized_certificate", + extra={ + "serviceName": "google.appengine.v1.AuthorizedCertificates", + "rpcName": "GetAuthorizedCertificate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAuthorizedCertificates( @@ -620,7 +781,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> appengine.ListAuthorizedCertificatesResponse: r"""Call the list authorized certificates method over HTTP. @@ -632,8 +793,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.appengine.ListAuthorizedCertificatesResponse: @@ -645,6 +808,7 @@ def __call__( http_options = ( _BaseAuthorizedCertificatesRestTransport._BaseListAuthorizedCertificates._get_http_options() ) + request, metadata = self._interceptor.pre_list_authorized_certificates( request, metadata ) @@ -657,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 = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.appengine_v1.AuthorizedCertificatesClient.ListAuthorizedCertificates", + extra={ + "serviceName": "google.appengine.v1.AuthorizedCertificates", + "rpcName": "ListAuthorizedCertificates", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AuthorizedCertificatesRestTransport._ListAuthorizedCertificates._get_response( self._host, @@ -677,7 +868,31 @@ def __call__( pb_resp = appengine.ListAuthorizedCertificatesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_authorized_certificates(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + appengine.ListAuthorizedCertificatesResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.appengine_v1.AuthorizedCertificatesClient.list_authorized_certificates", + extra={ + "serviceName": "google.appengine.v1.AuthorizedCertificates", + "rpcName": "ListAuthorizedCertificates", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateAuthorizedCertificate( @@ -718,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]]] = (), ) -> certificate.AuthorizedCertificate: r"""Call the update authorized certificate method over HTTP. @@ -730,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: ~.certificate.AuthorizedCertificate: @@ -746,6 +963,7 @@ def __call__( http_options = ( _BaseAuthorizedCertificatesRestTransport._BaseUpdateAuthorizedCertificate._get_http_options() ) + request, metadata = self._interceptor.pre_update_authorized_certificate( request, metadata ) @@ -762,6 +980,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.appengine_v1.AuthorizedCertificatesClient.UpdateAuthorizedCertificate", + extra={ + "serviceName": "google.appengine.v1.AuthorizedCertificates", + "rpcName": "UpdateAuthorizedCertificate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AuthorizedCertificatesRestTransport._UpdateAuthorizedCertificate._get_response( self._host, @@ -783,7 +1028,31 @@ def __call__( pb_resp = certificate.AuthorizedCertificate.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_authorized_certificate(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = certificate.AuthorizedCertificate.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.appengine_v1.AuthorizedCertificatesClient.update_authorized_certificate", + extra={ + "serviceName": "google.appengine.v1.AuthorizedCertificates", + "rpcName": "UpdateAuthorizedCertificate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_domains/async_client.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_domains/async_client.py index 4f6356077aaf..4f71bb8f04e4 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_domains/async_client.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_domains/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, AuthorizedDomainsTransport from .transports.grpc_asyncio import AuthorizedDomainsGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class AuthorizedDomainsAsyncClient: """Manages domains a user is authorized to administer. To authorize use @@ -259,13 +269,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.appengine_v1.AuthorizedDomainsAsyncClient`.", + extra={ + "serviceName": "google.appengine.v1.AuthorizedDomains", + "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.appengine.v1.AuthorizedDomains", + "credentialsType": None, + }, + ) + async def list_authorized_domains( self, request: Optional[Union[appengine.ListAuthorizedDomainsRequest, 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]]] = (), ) -> pagers.ListAuthorizedDomainsAsyncPager: r"""Lists all domains the user is authorized to administer. @@ -303,8 +335,10 @@ async def sample_list_authorized_domains(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.appengine_admin_v1.services.authorized_domains.pagers.ListAuthorizedDomainsAsyncPager: diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_domains/client.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_domains/client.py index c020391620e7..9483909886d3 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_domains/client.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_domains/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.appengine_admin_v1.services.authorized_domains import pagers from google.cloud.appengine_admin_v1.types import appengine, domain @@ -563,6 +573,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( @@ -629,13 +643,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.appengine_v1.AuthorizedDomainsClient`.", + extra={ + "serviceName": "google.appengine.v1.AuthorizedDomains", + "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.appengine.v1.AuthorizedDomains", + "credentialsType": None, + }, + ) + def list_authorized_domains( self, request: Optional[Union[appengine.ListAuthorizedDomainsRequest, 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]]] = (), ) -> pagers.ListAuthorizedDomainsPager: r"""Lists all domains the user is authorized to administer. @@ -673,8 +710,10 @@ def sample_list_authorized_domains(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.appengine_admin_v1.services.authorized_domains.pagers.ListAuthorizedDomainsPager: diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_domains/pagers.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_domains/pagers.py index e982475ebf89..75447eb24ffd 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_domains/pagers.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_domains/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 = appengine.ListAuthorizedDomainsRequest(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 = appengine.ListAuthorizedDomainsRequest(request) diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_domains/transports/grpc.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_domains/transports/grpc.py index 8e45f9091018..af5fc55ae36f 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_domains/transports/grpc.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_domains/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.appengine_admin_v1.types import appengine from .base import DEFAULT_CLIENT_INFO, AuthorizedDomainsTransport +try: + from google.api_core import client_logging # 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.appengine.v1.AuthorizedDomains", + "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.appengine.v1.AuthorizedDomains", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AuthorizedDomainsGrpcTransport(AuthorizedDomainsTransport): """gRPC backend transport for AuthorizedDomains. @@ -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 @@ -259,7 +345,7 @@ def list_authorized_domains( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_authorized_domains" not in self._stubs: - self._stubs["list_authorized_domains"] = self.grpc_channel.unary_unary( + self._stubs["list_authorized_domains"] = self._logged_channel.unary_unary( "/google.appengine.v1.AuthorizedDomains/ListAuthorizedDomains", request_serializer=appengine.ListAuthorizedDomainsRequest.serialize, response_deserializer=appengine.ListAuthorizedDomainsResponse.deserialize, @@ -267,7 +353,7 @@ def list_authorized_domains( return self._stubs["list_authorized_domains"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_domains/transports/grpc_asyncio.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_domains/transports/grpc_asyncio.py index 08cf9a8ceb33..8700cf342bea 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_domains/transports/grpc_asyncio.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_domains/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.appengine_admin_v1.types import appengine from .base import DEFAULT_CLIENT_INFO, AuthorizedDomainsTransport from .grpc import AuthorizedDomainsGrpcTransport +try: + from google.api_core import client_logging # 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.appengine.v1.AuthorizedDomains", + "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.appengine.v1.AuthorizedDomains", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AuthorizedDomainsGrpcAsyncIOTransport(AuthorizedDomainsTransport): """gRPC AsyncIO backend transport for AuthorizedDomains. @@ -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 @@ -267,7 +352,7 @@ def list_authorized_domains( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_authorized_domains" not in self._stubs: - self._stubs["list_authorized_domains"] = self.grpc_channel.unary_unary( + self._stubs["list_authorized_domains"] = self._logged_channel.unary_unary( "/google.appengine.v1.AuthorizedDomains/ListAuthorizedDomains", request_serializer=appengine.ListAuthorizedDomainsRequest.serialize, response_deserializer=appengine.ListAuthorizedDomainsResponse.deserialize, @@ -290,7 +375,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-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_domains/transports/rest.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_domains/transports/rest.py index 76405105899b..0441ac22e8a9 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_domains/transports/rest.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/authorized_domains/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -37,6 +37,14 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = logging.getLogger(__name__) DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, @@ -77,8 +85,10 @@ def post_list_authorized_domains(self, response): def pre_list_authorized_domains( self, request: appengine.ListAuthorizedDomainsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[appengine.ListAuthorizedDomainsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + appengine.ListAuthorizedDomainsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_authorized_domains Override in a subclass to manipulate the request or metadata @@ -221,7 +231,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> appengine.ListAuthorizedDomainsResponse: r"""Call the list authorized domains method over HTTP. @@ -232,8 +242,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.appengine.ListAuthorizedDomainsResponse: @@ -245,6 +257,7 @@ def __call__( http_options = ( _BaseAuthorizedDomainsRestTransport._BaseListAuthorizedDomains._get_http_options() ) + request, metadata = self._interceptor.pre_list_authorized_domains( request, metadata ) @@ -257,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.appengine_v1.AuthorizedDomainsClient.ListAuthorizedDomains", + extra={ + "serviceName": "google.appengine.v1.AuthorizedDomains", + "rpcName": "ListAuthorizedDomains", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AuthorizedDomainsRestTransport._ListAuthorizedDomains._get_response( @@ -279,7 +319,31 @@ def __call__( pb_resp = appengine.ListAuthorizedDomainsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_authorized_domains(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = appengine.ListAuthorizedDomainsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.appengine_v1.AuthorizedDomainsClient.list_authorized_domains", + extra={ + "serviceName": "google.appengine.v1.AuthorizedDomains", + "rpcName": "ListAuthorizedDomains", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/domain_mappings/async_client.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/domain_mappings/async_client.py index 59539a765ab9..e0ac16791756 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/domain_mappings/async_client.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/domain_mappings/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, DomainMappingsTransport from .transports.grpc_asyncio import DomainMappingsGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class DomainMappingsAsyncClient: """Manages domains serving an application.""" @@ -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 `google.appengine_v1.DomainMappingsAsyncClient`.", + extra={ + "serviceName": "google.appengine.v1.DomainMappings", + "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.appengine.v1.DomainMappings", + "credentialsType": None, + }, + ) + async def list_domain_mappings( self, request: Optional[Union[appengine.ListDomainMappingsRequest, 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]]] = (), ) -> pagers.ListDomainMappingsAsyncPager: r"""Lists the domain mappings on an application. @@ -300,8 +332,10 @@ async def sample_list_domain_mappings(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.appengine_admin_v1.services.domain_mappings.pagers.ListDomainMappingsAsyncPager: @@ -360,7 +394,7 @@ async def get_domain_mapping( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> domain_mapping.DomainMapping: r"""Gets the specified domain mapping. @@ -395,8 +429,10 @@ async def sample_get_domain_mapping(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.appengine_admin_v1.types.DomainMapping: @@ -442,7 +478,7 @@ async def create_domain_mapping( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Maps a domain to an application. A user must be authorized to administer a domain in order to map it to an application. For a @@ -485,8 +521,10 @@ async def sample_create_domain_mapping(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -543,7 +581,7 @@ async def update_domain_mapping( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 domain mapping. To map an SSL certificate to a domain mapping, update ``certificate_id`` to point to an @@ -587,8 +625,10 @@ async def sample_update_domain_mapping(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -645,7 +685,7 @@ async def delete_domain_mapping( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 domain mapping. A user must be authorized to administer the associated domain in order to delete a @@ -687,8 +727,10 @@ async def sample_delete_domain_mapping(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + 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-appengine-admin/google/cloud/appengine_admin_v1/services/domain_mappings/client.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/domain_mappings/client.py index 7d180628344e..8fae3ea02743 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/domain_mappings/client.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/domain_mappings/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 as gac_operation # type: ignore from google.api_core import operation_async # type: ignore from google.protobuf import empty_pb2 # type: ignore @@ -561,6 +571,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -626,13 +640,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.appengine_v1.DomainMappingsClient`.", + extra={ + "serviceName": "google.appengine.v1.DomainMappings", + "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.appengine.v1.DomainMappings", + "credentialsType": None, + }, + ) + def list_domain_mappings( self, request: Optional[Union[appengine.ListDomainMappingsRequest, 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]]] = (), ) -> pagers.ListDomainMappingsPager: r"""Lists the domain mappings on an application. @@ -669,8 +706,10 @@ def sample_list_domain_mappings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.appengine_admin_v1.services.domain_mappings.pagers.ListDomainMappingsPager: @@ -727,7 +766,7 @@ def get_domain_mapping( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> domain_mapping.DomainMapping: r"""Gets the specified domain mapping. @@ -762,8 +801,10 @@ def sample_get_domain_mapping(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.appengine_admin_v1.types.DomainMapping: @@ -807,7 +848,7 @@ def create_domain_mapping( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gac_operation.Operation: r"""Maps a domain to an application. A user must be authorized to administer a domain in order to map it to an application. For a @@ -850,8 +891,10 @@ def sample_create_domain_mapping(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -906,7 +949,7 @@ def update_domain_mapping( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gac_operation.Operation: r"""Updates the specified domain mapping. To map an SSL certificate to a domain mapping, update ``certificate_id`` to point to an @@ -950,8 +993,10 @@ def sample_update_domain_mapping(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -1006,7 +1051,7 @@ def delete_domain_mapping( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gac_operation.Operation: r"""Deletes the specified domain mapping. A user must be authorized to administer the associated domain in order to delete a @@ -1048,8 +1093,10 @@ def sample_delete_domain_mapping(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `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-appengine-admin/google/cloud/appengine_admin_v1/services/domain_mappings/pagers.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/domain_mappings/pagers.py index 41897a0f5842..dc366899edfd 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/domain_mappings/pagers.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/domain_mappings/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 = appengine.ListDomainMappingsRequest(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 = appengine.ListDomainMappingsRequest(request) diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/domain_mappings/transports/grpc.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/domain_mappings/transports/grpc.py index 5566ab74c45a..50f015cd84cd 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/domain_mappings/transports/grpc.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/domain_mappings/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.appengine_admin_v1.types import appengine, domain_mapping from .base import DEFAULT_CLIENT_INFO, DomainMappingsTransport +try: + from google.api_core import client_logging # 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.appengine.v1.DomainMappings", + "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.appengine.v1.DomainMappings", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class DomainMappingsGrpcTransport(DomainMappingsTransport): """gRPC backend transport for DomainMappings. @@ -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 @@ -271,7 +359,7 @@ def list_domain_mappings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_domain_mappings" not in self._stubs: - self._stubs["list_domain_mappings"] = self.grpc_channel.unary_unary( + self._stubs["list_domain_mappings"] = self._logged_channel.unary_unary( "/google.appengine.v1.DomainMappings/ListDomainMappings", request_serializer=appengine.ListDomainMappingsRequest.serialize, response_deserializer=appengine.ListDomainMappingsResponse.deserialize, @@ -297,7 +385,7 @@ def get_domain_mapping( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_domain_mapping" not in self._stubs: - self._stubs["get_domain_mapping"] = self.grpc_channel.unary_unary( + self._stubs["get_domain_mapping"] = self._logged_channel.unary_unary( "/google.appengine.v1.DomainMappings/GetDomainMapping", request_serializer=appengine.GetDomainMappingRequest.serialize, response_deserializer=domain_mapping.DomainMapping.deserialize, @@ -326,7 +414,7 @@ def create_domain_mapping( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_domain_mapping" not in self._stubs: - self._stubs["create_domain_mapping"] = self.grpc_channel.unary_unary( + self._stubs["create_domain_mapping"] = self._logged_channel.unary_unary( "/google.appengine.v1.DomainMappings/CreateDomainMapping", request_serializer=appengine.CreateDomainMappingRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -356,7 +444,7 @@ def update_domain_mapping( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_domain_mapping" not in self._stubs: - self._stubs["update_domain_mapping"] = self.grpc_channel.unary_unary( + self._stubs["update_domain_mapping"] = self._logged_channel.unary_unary( "/google.appengine.v1.DomainMappings/UpdateDomainMapping", request_serializer=appengine.UpdateDomainMappingRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -384,7 +472,7 @@ def delete_domain_mapping( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_domain_mapping" not in self._stubs: - self._stubs["delete_domain_mapping"] = self.grpc_channel.unary_unary( + self._stubs["delete_domain_mapping"] = self._logged_channel.unary_unary( "/google.appengine.v1.DomainMappings/DeleteDomainMapping", request_serializer=appengine.DeleteDomainMappingRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -392,7 +480,7 @@ def delete_domain_mapping( return self._stubs["delete_domain_mapping"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/domain_mappings/transports/grpc_asyncio.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/domain_mappings/transports/grpc_asyncio.py index 6df37cc0a595..246558d4baa3 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/domain_mappings/transports/grpc_asyncio.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/domain_mappings/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.appengine_admin_v1.types import appengine, domain_mapping from .base import DEFAULT_CLIENT_INFO, DomainMappingsTransport from .grpc import DomainMappingsGrpcTransport +try: + from google.api_core import client_logging # 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.appengine.v1.DomainMappings", + "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.appengine.v1.DomainMappings", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class DomainMappingsGrpcAsyncIOTransport(DomainMappingsTransport): """gRPC AsyncIO backend transport for DomainMappings. @@ -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 list_domain_mappings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_domain_mappings" not in self._stubs: - self._stubs["list_domain_mappings"] = self.grpc_channel.unary_unary( + self._stubs["list_domain_mappings"] = self._logged_channel.unary_unary( "/google.appengine.v1.DomainMappings/ListDomainMappings", request_serializer=appengine.ListDomainMappingsRequest.serialize, response_deserializer=appengine.ListDomainMappingsResponse.deserialize, @@ -310,7 +395,7 @@ def get_domain_mapping( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_domain_mapping" not in self._stubs: - self._stubs["get_domain_mapping"] = self.grpc_channel.unary_unary( + self._stubs["get_domain_mapping"] = self._logged_channel.unary_unary( "/google.appengine.v1.DomainMappings/GetDomainMapping", request_serializer=appengine.GetDomainMappingRequest.serialize, response_deserializer=domain_mapping.DomainMapping.deserialize, @@ -341,7 +426,7 @@ def create_domain_mapping( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_domain_mapping" not in self._stubs: - self._stubs["create_domain_mapping"] = self.grpc_channel.unary_unary( + self._stubs["create_domain_mapping"] = self._logged_channel.unary_unary( "/google.appengine.v1.DomainMappings/CreateDomainMapping", request_serializer=appengine.CreateDomainMappingRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -373,7 +458,7 @@ def update_domain_mapping( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_domain_mapping" not in self._stubs: - self._stubs["update_domain_mapping"] = self.grpc_channel.unary_unary( + self._stubs["update_domain_mapping"] = self._logged_channel.unary_unary( "/google.appengine.v1.DomainMappings/UpdateDomainMapping", request_serializer=appengine.UpdateDomainMappingRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -403,7 +488,7 @@ def delete_domain_mapping( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_domain_mapping" not in self._stubs: - self._stubs["delete_domain_mapping"] = self.grpc_channel.unary_unary( + self._stubs["delete_domain_mapping"] = self._logged_channel.unary_unary( "/google.appengine.v1.DomainMappings/DeleteDomainMapping", request_serializer=appengine.DeleteDomainMappingRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -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-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/domain_mappings/transports/rest.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/domain_mappings/transports/rest.py index 432d56466090..a57146f94322 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/domain_mappings/transports/rest.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/domain_mappings/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_domain_mapping(self, response): def pre_create_domain_mapping( self, request: appengine.CreateDomainMappingRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[appengine.CreateDomainMappingRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + appengine.CreateDomainMappingRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_domain_mapping Override in a subclass to manipulate the request or metadata @@ -133,8 +143,10 @@ def post_create_domain_mapping( def pre_delete_domain_mapping( self, request: appengine.DeleteDomainMappingRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[appengine.DeleteDomainMappingRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + appengine.DeleteDomainMappingRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_domain_mapping Override in a subclass to manipulate the request or metadata @@ -156,8 +168,10 @@ def post_delete_domain_mapping( def pre_get_domain_mapping( self, request: appengine.GetDomainMappingRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[appengine.GetDomainMappingRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + appengine.GetDomainMappingRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_domain_mapping Override in a subclass to manipulate the request or metadata @@ -179,8 +193,10 @@ def post_get_domain_mapping( def pre_list_domain_mappings( self, request: appengine.ListDomainMappingsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[appengine.ListDomainMappingsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + appengine.ListDomainMappingsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_domain_mappings Override in a subclass to manipulate the request or metadata @@ -202,8 +218,10 @@ def post_list_domain_mappings( def pre_update_domain_mapping( self, request: appengine.UpdateDomainMappingRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[appengine.UpdateDomainMappingRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + appengine.UpdateDomainMappingRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_domain_mapping Override in a subclass to manipulate the request or metadata @@ -386,7 +404,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 domain mapping method over HTTP. @@ -397,8 +415,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -411,6 +431,7 @@ def __call__( http_options = ( _BaseDomainMappingsRestTransport._BaseCreateDomainMapping._get_http_options() ) + request, metadata = self._interceptor.pre_create_domain_mapping( request, metadata ) @@ -427,6 +448,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.appengine_v1.DomainMappingsClient.CreateDomainMapping", + extra={ + "serviceName": "google.appengine.v1.DomainMappings", + "rpcName": "CreateDomainMapping", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DomainMappingsRestTransport._CreateDomainMapping._get_response( self._host, @@ -446,7 +494,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_domain_mapping(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.appengine_v1.DomainMappingsClient.create_domain_mapping", + extra={ + "serviceName": "google.appengine.v1.DomainMappings", + "rpcName": "CreateDomainMapping", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteDomainMapping( @@ -484,7 +554,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete domain mapping method over HTTP. @@ -495,8 +565,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -509,6 +581,7 @@ def __call__( http_options = ( _BaseDomainMappingsRestTransport._BaseDeleteDomainMapping._get_http_options() ) + request, metadata = self._interceptor.pre_delete_domain_mapping( request, metadata ) @@ -521,6 +594,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.appengine_v1.DomainMappingsClient.DeleteDomainMapping", + extra={ + "serviceName": "google.appengine.v1.DomainMappings", + "rpcName": "DeleteDomainMapping", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DomainMappingsRestTransport._DeleteDomainMapping._get_response( self._host, @@ -539,7 +639,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_domain_mapping(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.appengine_v1.DomainMappingsClient.delete_domain_mapping", + extra={ + "serviceName": "google.appengine.v1.DomainMappings", + "rpcName": "DeleteDomainMapping", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDomainMapping( @@ -576,7 +698,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> domain_mapping.DomainMapping: r"""Call the get domain mapping method over HTTP. @@ -586,8 +708,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.domain_mapping.DomainMapping: @@ -599,6 +723,7 @@ def __call__( http_options = ( _BaseDomainMappingsRestTransport._BaseGetDomainMapping._get_http_options() ) + request, metadata = self._interceptor.pre_get_domain_mapping( request, metadata ) @@ -611,6 +736,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.appengine_v1.DomainMappingsClient.GetDomainMapping", + extra={ + "serviceName": "google.appengine.v1.DomainMappings", + "rpcName": "GetDomainMapping", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DomainMappingsRestTransport._GetDomainMapping._get_response( self._host, @@ -631,7 +783,29 @@ def __call__( pb_resp = domain_mapping.DomainMapping.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_domain_mapping(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = domain_mapping.DomainMapping.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.appengine_v1.DomainMappingsClient.get_domain_mapping", + extra={ + "serviceName": "google.appengine.v1.DomainMappings", + "rpcName": "GetDomainMapping", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDomainMappings( @@ -668,7 +842,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> appengine.ListDomainMappingsResponse: r"""Call the list domain mappings method over HTTP. @@ -679,8 +853,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.appengine.ListDomainMappingsResponse: @@ -692,6 +868,7 @@ def __call__( http_options = ( _BaseDomainMappingsRestTransport._BaseListDomainMappings._get_http_options() ) + request, metadata = self._interceptor.pre_list_domain_mappings( request, metadata ) @@ -704,6 +881,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.appengine_v1.DomainMappingsClient.ListDomainMappings", + extra={ + "serviceName": "google.appengine.v1.DomainMappings", + "rpcName": "ListDomainMappings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DomainMappingsRestTransport._ListDomainMappings._get_response( self._host, @@ -724,7 +928,31 @@ def __call__( pb_resp = appengine.ListDomainMappingsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_domain_mappings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = appengine.ListDomainMappingsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.appengine_v1.DomainMappingsClient.list_domain_mappings", + extra={ + "serviceName": "google.appengine.v1.DomainMappings", + "rpcName": "ListDomainMappings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateDomainMapping( @@ -763,7 +991,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 domain mapping method over HTTP. @@ -774,8 +1002,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -788,6 +1018,7 @@ def __call__( http_options = ( _BaseDomainMappingsRestTransport._BaseUpdateDomainMapping._get_http_options() ) + request, metadata = self._interceptor.pre_update_domain_mapping( request, metadata ) @@ -804,6 +1035,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.appengine_v1.DomainMappingsClient.UpdateDomainMapping", + extra={ + "serviceName": "google.appengine.v1.DomainMappings", + "rpcName": "UpdateDomainMapping", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DomainMappingsRestTransport._UpdateDomainMapping._get_response( self._host, @@ -823,7 +1081,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_domain_mapping(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.appengine_v1.DomainMappingsClient.update_domain_mapping", + extra={ + "serviceName": "google.appengine.v1.DomainMappings", + "rpcName": "UpdateDomainMapping", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/firewall/async_client.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/firewall/async_client.py index 399bca77546a..0e88eebe036c 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/firewall/async_client.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/firewall/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, FirewallTransport from .transports.grpc_asyncio import FirewallGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class FirewallAsyncClient: """Firewall resources are used to define a collection of access @@ -256,13 +266,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.appengine_v1.FirewallAsyncClient`.", + extra={ + "serviceName": "google.appengine.v1.Firewall", + "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.appengine.v1.Firewall", + "credentialsType": None, + }, + ) + async def list_ingress_rules( self, request: Optional[Union[appengine.ListIngressRulesRequest, 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]]] = (), ) -> pagers.ListIngressRulesAsyncPager: r"""Lists the firewall rules of an application. @@ -298,8 +330,10 @@ async def sample_list_ingress_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.appengine_admin_v1.services.firewall.pagers.ListIngressRulesAsyncPager: @@ -358,7 +392,7 @@ async def batch_update_ingress_rules( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> appengine.BatchUpdateIngressRulesResponse: r"""Replaces the entire firewall ruleset in one bulk operation. This overrides and replaces the rules of an existing firewall with @@ -400,8 +434,10 @@ async def sample_batch_update_ingress_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.appengine_admin_v1.types.BatchUpdateIngressRulesResponse: @@ -445,7 +481,7 @@ async def create_ingress_rule( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> firewall.FirewallRule: r"""Creates a firewall rule for the application. @@ -480,8 +516,10 @@ async def sample_create_ingress_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.appengine_admin_v1.types.FirewallRule: @@ -529,7 +567,7 @@ async def get_ingress_rule( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> firewall.FirewallRule: r"""Gets the specified firewall rule. @@ -564,8 +602,10 @@ async def sample_get_ingress_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.appengine_admin_v1.types.FirewallRule: @@ -613,7 +653,7 @@ async def update_ingress_rule( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> firewall.FirewallRule: r"""Updates the specified firewall rule. @@ -648,8 +688,10 @@ async def sample_update_ingress_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.appengine_admin_v1.types.FirewallRule: @@ -697,7 +739,7 @@ async def delete_ingress_rule( *, retry: OptionalRetry = gapic_v1.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 firewall rule. @@ -729,8 +771,10 @@ async def sample_delete_ingress_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`. """ # Create or coerce a protobuf request object. # - Use the request object if provided (there's no risk of modifying the input as diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/firewall/client.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/firewall/client.py index 0dcffd4dc2eb..448017e11fff 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/firewall/client.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/firewall/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.appengine_admin_v1.services.firewall import pagers from google.cloud.appengine_admin_v1.types import appengine, firewall @@ -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( @@ -628,13 +642,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.appengine_v1.FirewallClient`.", + extra={ + "serviceName": "google.appengine.v1.Firewall", + "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.appengine.v1.Firewall", + "credentialsType": None, + }, + ) + def list_ingress_rules( self, request: Optional[Union[appengine.ListIngressRulesRequest, 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]]] = (), ) -> pagers.ListIngressRulesPager: r"""Lists the firewall rules of an application. @@ -670,8 +707,10 @@ def sample_list_ingress_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.appengine_admin_v1.services.firewall.pagers.ListIngressRulesPager: @@ -728,7 +767,7 @@ def batch_update_ingress_rules( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> appengine.BatchUpdateIngressRulesResponse: r"""Replaces the entire firewall ruleset in one bulk operation. This overrides and replaces the rules of an existing firewall with @@ -770,8 +809,10 @@ def sample_batch_update_ingress_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.appengine_admin_v1.types.BatchUpdateIngressRulesResponse: @@ -815,7 +856,7 @@ def create_ingress_rule( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> firewall.FirewallRule: r"""Creates a firewall rule for the application. @@ -850,8 +891,10 @@ def sample_create_ingress_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.appengine_admin_v1.types.FirewallRule: @@ -897,7 +940,7 @@ def get_ingress_rule( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> firewall.FirewallRule: r"""Gets the specified firewall rule. @@ -932,8 +975,10 @@ def sample_get_ingress_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.appengine_admin_v1.types.FirewallRule: @@ -979,7 +1024,7 @@ def update_ingress_rule( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> firewall.FirewallRule: r"""Updates the specified firewall rule. @@ -1014,8 +1059,10 @@ def sample_update_ingress_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.appengine_admin_v1.types.FirewallRule: @@ -1061,7 +1108,7 @@ def delete_ingress_rule( *, retry: OptionalRetry = gapic_v1.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 firewall rule. @@ -1093,8 +1140,10 @@ def sample_delete_ingress_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`. """ # Create or coerce a protobuf request object. # - Use the request object if provided (there's no risk of modifying the input as diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/firewall/pagers.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/firewall/pagers.py index 054965552c83..dc33f1a1452a 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/firewall/pagers.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/firewall/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 = appengine.ListIngressRulesRequest(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 = appengine.ListIngressRulesRequest(request) diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/firewall/transports/grpc.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/firewall/transports/grpc.py index 7e4d67f2b742..af29866598f8 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/firewall/transports/grpc.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/firewall/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.appengine_admin_v1.types import appengine, firewall from .base import DEFAULT_CLIENT_INFO, FirewallTransport +try: + from google.api_core import client_logging # 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.appengine.v1.Firewall", + "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.appengine.v1.Firewall", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class FirewallGrpcTransport(FirewallTransport): """gRPC backend transport for Firewall. @@ -191,7 +272,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientInterceptor() + self._logged_channel = grpc.intercept_channel( + self._grpc_channel, self._interceptor + ) + + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @classmethod @@ -267,7 +353,7 @@ def list_ingress_rules( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_ingress_rules" not in self._stubs: - self._stubs["list_ingress_rules"] = self.grpc_channel.unary_unary( + self._stubs["list_ingress_rules"] = self._logged_channel.unary_unary( "/google.appengine.v1.Firewall/ListIngressRules", request_serializer=appengine.ListIngressRulesRequest.serialize, response_deserializer=appengine.ListIngressRulesResponse.deserialize, @@ -302,7 +388,9 @@ def batch_update_ingress_rules( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_update_ingress_rules" not in self._stubs: - self._stubs["batch_update_ingress_rules"] = self.grpc_channel.unary_unary( + self._stubs[ + "batch_update_ingress_rules" + ] = self._logged_channel.unary_unary( "/google.appengine.v1.Firewall/BatchUpdateIngressRules", request_serializer=appengine.BatchUpdateIngressRulesRequest.serialize, response_deserializer=appengine.BatchUpdateIngressRulesResponse.deserialize, @@ -328,7 +416,7 @@ def create_ingress_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_ingress_rule" not in self._stubs: - self._stubs["create_ingress_rule"] = self.grpc_channel.unary_unary( + self._stubs["create_ingress_rule"] = self._logged_channel.unary_unary( "/google.appengine.v1.Firewall/CreateIngressRule", request_serializer=appengine.CreateIngressRuleRequest.serialize, response_deserializer=firewall.FirewallRule.deserialize, @@ -354,7 +442,7 @@ def get_ingress_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_ingress_rule" not in self._stubs: - self._stubs["get_ingress_rule"] = self.grpc_channel.unary_unary( + self._stubs["get_ingress_rule"] = self._logged_channel.unary_unary( "/google.appengine.v1.Firewall/GetIngressRule", request_serializer=appengine.GetIngressRuleRequest.serialize, response_deserializer=firewall.FirewallRule.deserialize, @@ -380,7 +468,7 @@ def update_ingress_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_ingress_rule" not in self._stubs: - self._stubs["update_ingress_rule"] = self.grpc_channel.unary_unary( + self._stubs["update_ingress_rule"] = self._logged_channel.unary_unary( "/google.appengine.v1.Firewall/UpdateIngressRule", request_serializer=appengine.UpdateIngressRuleRequest.serialize, response_deserializer=firewall.FirewallRule.deserialize, @@ -406,7 +494,7 @@ def delete_ingress_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_ingress_rule" not in self._stubs: - self._stubs["delete_ingress_rule"] = self.grpc_channel.unary_unary( + self._stubs["delete_ingress_rule"] = self._logged_channel.unary_unary( "/google.appengine.v1.Firewall/DeleteIngressRule", request_serializer=appengine.DeleteIngressRuleRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -414,7 +502,7 @@ def delete_ingress_rule( return self._stubs["delete_ingress_rule"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/firewall/transports/grpc_asyncio.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/firewall/transports/grpc_asyncio.py index d98fe5d62935..39a66c44e3d5 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/firewall/transports/grpc_asyncio.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/firewall/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.appengine_admin_v1.types import appengine, firewall from .base import DEFAULT_CLIENT_INFO, FirewallTransport from .grpc import FirewallGrpcTransport +try: + from google.api_core import client_logging # 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.appengine.v1.Firewall", + "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.appengine.v1.Firewall", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class FirewallGrpcAsyncIOTransport(FirewallTransport): """gRPC AsyncIO backend transport for Firewall. @@ -238,10 +320,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientAIOInterceptor() + self._grpc_channel._unary_unary_interceptors.append(self._interceptor) + self._logged_channel = self._grpc_channel self._wrap_with_kind = ( "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters ) + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @property @@ -276,7 +361,7 @@ def list_ingress_rules( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_ingress_rules" not in self._stubs: - self._stubs["list_ingress_rules"] = self.grpc_channel.unary_unary( + self._stubs["list_ingress_rules"] = self._logged_channel.unary_unary( "/google.appengine.v1.Firewall/ListIngressRules", request_serializer=appengine.ListIngressRulesRequest.serialize, response_deserializer=appengine.ListIngressRulesResponse.deserialize, @@ -311,7 +396,9 @@ def batch_update_ingress_rules( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_update_ingress_rules" not in self._stubs: - self._stubs["batch_update_ingress_rules"] = self.grpc_channel.unary_unary( + self._stubs[ + "batch_update_ingress_rules" + ] = self._logged_channel.unary_unary( "/google.appengine.v1.Firewall/BatchUpdateIngressRules", request_serializer=appengine.BatchUpdateIngressRulesRequest.serialize, response_deserializer=appengine.BatchUpdateIngressRulesResponse.deserialize, @@ -339,7 +426,7 @@ def create_ingress_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_ingress_rule" not in self._stubs: - self._stubs["create_ingress_rule"] = self.grpc_channel.unary_unary( + self._stubs["create_ingress_rule"] = self._logged_channel.unary_unary( "/google.appengine.v1.Firewall/CreateIngressRule", request_serializer=appengine.CreateIngressRuleRequest.serialize, response_deserializer=firewall.FirewallRule.deserialize, @@ -365,7 +452,7 @@ def get_ingress_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_ingress_rule" not in self._stubs: - self._stubs["get_ingress_rule"] = self.grpc_channel.unary_unary( + self._stubs["get_ingress_rule"] = self._logged_channel.unary_unary( "/google.appengine.v1.Firewall/GetIngressRule", request_serializer=appengine.GetIngressRuleRequest.serialize, response_deserializer=firewall.FirewallRule.deserialize, @@ -393,7 +480,7 @@ def update_ingress_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_ingress_rule" not in self._stubs: - self._stubs["update_ingress_rule"] = self.grpc_channel.unary_unary( + self._stubs["update_ingress_rule"] = self._logged_channel.unary_unary( "/google.appengine.v1.Firewall/UpdateIngressRule", request_serializer=appengine.UpdateIngressRuleRequest.serialize, response_deserializer=firewall.FirewallRule.deserialize, @@ -419,7 +506,7 @@ def delete_ingress_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_ingress_rule" not in self._stubs: - self._stubs["delete_ingress_rule"] = self.grpc_channel.unary_unary( + self._stubs["delete_ingress_rule"] = self._logged_channel.unary_unary( "/google.appengine.v1.Firewall/DeleteIngressRule", request_serializer=appengine.DeleteIngressRuleRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -467,7 +554,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-appengine-admin/google/cloud/appengine_admin_v1/services/firewall/transports/rest.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/firewall/transports/rest.py index ce7e405658c0..c4fd9f51f6aa 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/firewall/transports/rest.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/firewall/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, @@ -114,8 +122,11 @@ def post_update_ingress_rule(self, response): def pre_batch_update_ingress_rules( self, request: appengine.BatchUpdateIngressRulesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[appengine.BatchUpdateIngressRulesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + appengine.BatchUpdateIngressRulesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for batch_update_ingress_rules Override in a subclass to manipulate the request or metadata @@ -137,8 +148,10 @@ def post_batch_update_ingress_rules( def pre_create_ingress_rule( self, request: appengine.CreateIngressRuleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[appengine.CreateIngressRuleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + appengine.CreateIngressRuleRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_ingress_rule Override in a subclass to manipulate the request or metadata @@ -160,8 +173,10 @@ def post_create_ingress_rule( def pre_delete_ingress_rule( self, request: appengine.DeleteIngressRuleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[appengine.DeleteIngressRuleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + appengine.DeleteIngressRuleRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_ingress_rule Override in a subclass to manipulate the request or metadata @@ -172,8 +187,10 @@ def pre_delete_ingress_rule( def pre_get_ingress_rule( self, request: appengine.GetIngressRuleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[appengine.GetIngressRuleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + appengine.GetIngressRuleRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_ingress_rule Override in a subclass to manipulate the request or metadata @@ -195,8 +212,10 @@ def post_get_ingress_rule( def pre_list_ingress_rules( self, request: appengine.ListIngressRulesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[appengine.ListIngressRulesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + appengine.ListIngressRulesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_ingress_rules Override in a subclass to manipulate the request or metadata @@ -218,8 +237,10 @@ def post_list_ingress_rules( def pre_update_ingress_rule( self, request: appengine.UpdateIngressRuleRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[appengine.UpdateIngressRuleRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + appengine.UpdateIngressRuleRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_ingress_rule Override in a subclass to manipulate the request or metadata @@ -371,7 +392,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> appengine.BatchUpdateIngressRulesResponse: r"""Call the batch update ingress rules method over HTTP. @@ -383,8 +404,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.appengine.BatchUpdateIngressRulesResponse: @@ -394,6 +417,7 @@ def __call__( http_options = ( _BaseFirewallRestTransport._BaseBatchUpdateIngressRules._get_http_options() ) + request, metadata = self._interceptor.pre_batch_update_ingress_rules( request, metadata ) @@ -410,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.appengine_v1.FirewallClient.BatchUpdateIngressRules", + extra={ + "serviceName": "google.appengine.v1.Firewall", + "rpcName": "BatchUpdateIngressRules", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FirewallRestTransport._BatchUpdateIngressRules._get_response( self._host, @@ -431,7 +482,31 @@ def __call__( pb_resp = appengine.BatchUpdateIngressRulesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_update_ingress_rules(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + appengine.BatchUpdateIngressRulesResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.appengine_v1.FirewallClient.batch_update_ingress_rules", + extra={ + "serviceName": "google.appengine.v1.Firewall", + "rpcName": "BatchUpdateIngressRules", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateIngressRule( @@ -469,7 +544,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> firewall.FirewallRule: r"""Call the create ingress rule method over HTTP. @@ -479,8 +554,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.firewall.FirewallRule: @@ -494,6 +571,7 @@ def __call__( http_options = ( _BaseFirewallRestTransport._BaseCreateIngressRule._get_http_options() ) + request, metadata = self._interceptor.pre_create_ingress_rule( request, metadata ) @@ -510,6 +588,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.appengine_v1.FirewallClient.CreateIngressRule", + extra={ + "serviceName": "google.appengine.v1.Firewall", + "rpcName": "CreateIngressRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FirewallRestTransport._CreateIngressRule._get_response( self._host, @@ -531,7 +636,29 @@ def __call__( pb_resp = firewall.FirewallRule.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_ingress_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = firewall.FirewallRule.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.appengine_v1.FirewallClient.create_ingress_rule", + extra={ + "serviceName": "google.appengine.v1.Firewall", + "rpcName": "CreateIngressRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteIngressRule( @@ -568,7 +695,7 @@ 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 ingress rule method over HTTP. @@ -578,13 +705,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 = ( _BaseFirewallRestTransport._BaseDeleteIngressRule._get_http_options() ) + request, metadata = self._interceptor.pre_delete_ingress_rule( request, metadata ) @@ -597,6 +727,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.appengine_v1.FirewallClient.DeleteIngressRule", + extra={ + "serviceName": "google.appengine.v1.Firewall", + "rpcName": "DeleteIngressRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FirewallRestTransport._DeleteIngressRule._get_response( self._host, @@ -646,7 +803,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> firewall.FirewallRule: r"""Call the get ingress rule method over HTTP. @@ -656,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: ~.firewall.FirewallRule: @@ -671,6 +830,7 @@ def __call__( http_options = ( _BaseFirewallRestTransport._BaseGetIngressRule._get_http_options() ) + request, metadata = self._interceptor.pre_get_ingress_rule( request, metadata ) @@ -687,6 +847,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.appengine_v1.FirewallClient.GetIngressRule", + extra={ + "serviceName": "google.appengine.v1.Firewall", + "rpcName": "GetIngressRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FirewallRestTransport._GetIngressRule._get_response( self._host, @@ -707,7 +894,29 @@ def __call__( pb_resp = firewall.FirewallRule.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_ingress_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = firewall.FirewallRule.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.appengine_v1.FirewallClient.get_ingress_rule", + extra={ + "serviceName": "google.appengine.v1.Firewall", + "rpcName": "GetIngressRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListIngressRules( @@ -744,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]]] = (), ) -> appengine.ListIngressRulesResponse: r"""Call the list ingress rules method over HTTP. @@ -754,8 +963,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.appengine.ListIngressRulesResponse: @@ -765,6 +976,7 @@ def __call__( http_options = ( _BaseFirewallRestTransport._BaseListIngressRules._get_http_options() ) + request, metadata = self._interceptor.pre_list_ingress_rules( request, metadata ) @@ -779,6 +991,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.appengine_v1.FirewallClient.ListIngressRules", + extra={ + "serviceName": "google.appengine.v1.Firewall", + "rpcName": "ListIngressRules", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FirewallRestTransport._ListIngressRules._get_response( self._host, @@ -799,7 +1038,31 @@ def __call__( pb_resp = appengine.ListIngressRulesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_ingress_rules(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = appengine.ListIngressRulesResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.appengine_v1.FirewallClient.list_ingress_rules", + extra={ + "serviceName": "google.appengine.v1.Firewall", + "rpcName": "ListIngressRules", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateIngressRule( @@ -837,7 +1100,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> firewall.FirewallRule: r"""Call the update ingress rule method over HTTP. @@ -847,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: ~.firewall.FirewallRule: @@ -862,6 +1127,7 @@ def __call__( http_options = ( _BaseFirewallRestTransport._BaseUpdateIngressRule._get_http_options() ) + request, metadata = self._interceptor.pre_update_ingress_rule( request, metadata ) @@ -878,6 +1144,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.appengine_v1.FirewallClient.UpdateIngressRule", + extra={ + "serviceName": "google.appengine.v1.Firewall", + "rpcName": "UpdateIngressRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = FirewallRestTransport._UpdateIngressRule._get_response( self._host, @@ -899,7 +1192,29 @@ def __call__( pb_resp = firewall.FirewallRule.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_ingress_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = firewall.FirewallRule.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.appengine_v1.FirewallClient.update_ingress_rule", + extra={ + "serviceName": "google.appengine.v1.Firewall", + "rpcName": "UpdateIngressRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/instances/async_client.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/instances/async_client.py index 2969b655e347..7ad28c87ef72 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/instances/async_client.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/instances/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, InstancesTransport from .transports.grpc_asyncio import InstancesGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class InstancesAsyncClient: """Manages instances of a version.""" @@ -254,13 +264,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.appengine_v1.InstancesAsyncClient`.", + extra={ + "serviceName": "google.appengine.v1.Instances", + "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.appengine.v1.Instances", + "credentialsType": None, + }, + ) + async def list_instances( self, request: Optional[Union[appengine.ListInstancesRequest, 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]]] = (), ) -> pagers.ListInstancesAsyncPager: r"""Lists the instances of a version. @@ -300,8 +332,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.appengine_admin_v1.services.instances.pagers.ListInstancesAsyncPager: @@ -360,7 +394,7 @@ async def get_instance( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> instance.Instance: r"""Gets instance information. @@ -395,8 +429,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.appengine_admin_v1.types.Instance: @@ -443,7 +479,7 @@ async def delete_instance( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 running instance. @@ -496,8 +532,10 @@ async def sample_delete_instance(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -561,7 +599,7 @@ async def debug_instance( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Enables debugging on a VM instance. This allows you to use the SSH command to connect to the virtual machine @@ -609,8 +647,10 @@ async def sample_debug_instance(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/instances/client.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/instances/client.py index 7463d2db4d74..518ad67b46a3 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/instances/client.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/instances/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 as gac_operation # type: ignore from google.api_core import operation_async # type: ignore from google.protobuf import empty_pb2 # type: ignore @@ -584,6 +594,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -646,13 +660,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.appengine_v1.InstancesClient`.", + extra={ + "serviceName": "google.appengine.v1.Instances", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__module__}.{type(self._transport._credentials).__qualname__}", + "credentialsInfo": getattr( + self.transport._credentials, "get_cred_info", lambda: None + )(), + } + if hasattr(self._transport, "_credentials") + else { + "serviceName": "google.appengine.v1.Instances", + "credentialsType": None, + }, + ) + def list_instances( self, request: Optional[Union[appengine.ListInstancesRequest, 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]]] = (), ) -> pagers.ListInstancesPager: r"""Lists the instances of a version. @@ -692,8 +729,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.appengine_admin_v1.services.instances.pagers.ListInstancesPager: @@ -750,7 +789,7 @@ def get_instance( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> instance.Instance: r"""Gets instance information. @@ -785,8 +824,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.appengine_admin_v1.types.Instance: @@ -831,7 +872,7 @@ def delete_instance( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gac_operation.Operation: r"""Stops a running instance. @@ -884,8 +925,10 @@ def sample_delete_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -947,7 +990,7 @@ def debug_instance( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gac_operation.Operation: r"""Enables debugging on a VM instance. This allows you to use the SSH command to connect to the virtual machine @@ -995,8 +1038,10 @@ def sample_debug_instance(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/instances/pagers.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/instances/pagers.py index d30e40c15982..ca65ad18a87c 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/instances/pagers.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/instances/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = appengine.ListInstancesRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( retry (google.api_core.retry.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = appengine.ListInstancesRequest(request) diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/instances/transports/grpc.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/instances/transports/grpc.py index c8cd45be211d..3f6392764ad8 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/instances/transports/grpc.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/instances/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.appengine_admin_v1.types import appengine, instance from .base import DEFAULT_CLIENT_INFO, InstancesTransport +try: + from google.api_core import client_logging # 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.appengine.v1.Instances", + "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.appengine.v1.Instances", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class InstancesGrpcTransport(InstancesTransport): """gRPC backend transport for Instances. @@ -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 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.appengine.v1.Instances/ListInstances", request_serializer=appengine.ListInstancesRequest.serialize, response_deserializer=appengine.ListInstancesResponse.deserialize, @@ -299,7 +387,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.appengine.v1.Instances/GetInstance", request_serializer=appengine.GetInstanceRequest.serialize, response_deserializer=instance.Instance.deserialize, @@ -339,7 +427,7 @@ def delete_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_instance" not in self._stubs: - self._stubs["delete_instance"] = self.grpc_channel.unary_unary( + self._stubs["delete_instance"] = self._logged_channel.unary_unary( "/google.appengine.v1.Instances/DeleteInstance", request_serializer=appengine.DeleteInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -374,7 +462,7 @@ def debug_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "debug_instance" not in self._stubs: - self._stubs["debug_instance"] = self.grpc_channel.unary_unary( + self._stubs["debug_instance"] = self._logged_channel.unary_unary( "/google.appengine.v1.Instances/DebugInstance", request_serializer=appengine.DebugInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -382,7 +470,7 @@ def debug_instance( return self._stubs["debug_instance"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/instances/transports/grpc_asyncio.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/instances/transports/grpc_asyncio.py index 584519831322..f78b60600081 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/instances/transports/grpc_asyncio.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/instances/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.appengine_admin_v1.types import appengine, instance from .base import DEFAULT_CLIENT_INFO, InstancesTransport from .grpc import InstancesGrpcTransport +try: + from google.api_core import client_logging # 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.appengine.v1.Instances", + "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.appengine.v1.Instances", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class InstancesGrpcAsyncIOTransport(InstancesTransport): """gRPC AsyncIO backend transport for Instances. @@ -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 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.appengine.v1.Instances/ListInstances", request_serializer=appengine.ListInstancesRequest.serialize, response_deserializer=appengine.ListInstancesResponse.deserialize, @@ -311,7 +396,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.appengine.v1.Instances/GetInstance", request_serializer=appengine.GetInstanceRequest.serialize, response_deserializer=instance.Instance.deserialize, @@ -353,7 +438,7 @@ def delete_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_instance" not in self._stubs: - self._stubs["delete_instance"] = self.grpc_channel.unary_unary( + self._stubs["delete_instance"] = self._logged_channel.unary_unary( "/google.appengine.v1.Instances/DeleteInstance", request_serializer=appengine.DeleteInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -390,7 +475,7 @@ def debug_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "debug_instance" not in self._stubs: - self._stubs["debug_instance"] = self.grpc_channel.unary_unary( + self._stubs["debug_instance"] = self._logged_channel.unary_unary( "/google.appengine.v1.Instances/DebugInstance", request_serializer=appengine.DebugInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -428,7 +513,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-appengine-admin/google/cloud/appengine_admin_v1/services/instances/transports/rest.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/instances/transports/rest.py index c2c7e9cd2fa4..5171380a9056 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/instances/transports/rest.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/instances/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -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,8 +110,8 @@ def post_list_instances(self, response): def pre_debug_instance( self, request: appengine.DebugInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[appengine.DebugInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[appengine.DebugInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for debug_instance Override in a subclass to manipulate the request or metadata @@ -125,8 +133,10 @@ def post_debug_instance( def pre_delete_instance( self, request: appengine.DeleteInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[appengine.DeleteInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + appengine.DeleteInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_instance Override in a subclass to manipulate the request or metadata @@ -146,8 +156,10 @@ def post_delete_instance( return response def pre_get_instance( - self, request: appengine.GetInstanceRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[appengine.GetInstanceRequest, Sequence[Tuple[str, str]]]: + self, + request: appengine.GetInstanceRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[appengine.GetInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_instance Override in a subclass to manipulate the request or metadata @@ -167,8 +179,8 @@ def post_get_instance(self, response: instance.Instance) -> instance.Instance: def pre_list_instances( self, request: appengine.ListInstancesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[appengine.ListInstancesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[appengine.ListInstancesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_instances Override in a subclass to manipulate the request or metadata @@ -350,7 +362,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the debug instance method over HTTP. @@ -360,8 +372,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -374,6 +388,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseDebugInstance._get_http_options() ) + request, metadata = self._interceptor.pre_debug_instance(request, metadata) transcoded_request = ( _BaseInstancesRestTransport._BaseDebugInstance._get_transcoded_request( @@ -394,6 +409,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.appengine_v1.InstancesClient.DebugInstance", + extra={ + "serviceName": "google.appengine.v1.Instances", + "rpcName": "DebugInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._DebugInstance._get_response( self._host, @@ -413,7 +455,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_debug_instance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.appengine_v1.InstancesClient.debug_instance", + extra={ + "serviceName": "google.appengine.v1.Instances", + "rpcName": "DebugInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteInstance( @@ -450,7 +514,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete instance method over HTTP. @@ -460,8 +524,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -474,6 +540,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseDeleteInstance._get_http_options() ) + request, metadata = self._interceptor.pre_delete_instance(request, metadata) transcoded_request = ( _BaseInstancesRestTransport._BaseDeleteInstance._get_transcoded_request( @@ -488,6 +555,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.appengine_v1.InstancesClient.DeleteInstance", + extra={ + "serviceName": "google.appengine.v1.Instances", + "rpcName": "DeleteInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._DeleteInstance._get_response( self._host, @@ -506,7 +600,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_instance(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.appengine_v1.InstancesClient.delete_instance", + extra={ + "serviceName": "google.appengine.v1.Instances", + "rpcName": "DeleteInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetInstance(_BaseInstancesRestTransport._BaseGetInstance, InstancesRestStub): @@ -541,7 +657,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> instance.Instance: r"""Call the get instance method over HTTP. @@ -551,8 +667,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.instance.Instance: @@ -565,6 +683,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseGetInstance._get_http_options() ) + request, metadata = self._interceptor.pre_get_instance(request, metadata) transcoded_request = ( _BaseInstancesRestTransport._BaseGetInstance._get_transcoded_request( @@ -579,6 +698,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.appengine_v1.InstancesClient.GetInstance", + extra={ + "serviceName": "google.appengine.v1.Instances", + "rpcName": "GetInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._GetInstance._get_response( self._host, @@ -599,7 +745,29 @@ def __call__( pb_resp = instance.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 = instance.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.appengine_v1.InstancesClient.get_instance", + extra={ + "serviceName": "google.appengine.v1.Instances", + "rpcName": "GetInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListInstances( @@ -636,7 +804,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> appengine.ListInstancesResponse: r"""Call the list instances method over HTTP. @@ -646,8 +814,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.appengine.ListInstancesResponse: @@ -657,6 +827,7 @@ def __call__( http_options = ( _BaseInstancesRestTransport._BaseListInstances._get_http_options() ) + request, metadata = self._interceptor.pre_list_instances(request, metadata) transcoded_request = ( _BaseInstancesRestTransport._BaseListInstances._get_transcoded_request( @@ -671,6 +842,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.appengine_v1.InstancesClient.ListInstances", + extra={ + "serviceName": "google.appengine.v1.Instances", + "rpcName": "ListInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = InstancesRestTransport._ListInstances._get_response( self._host, @@ -691,7 +889,29 @@ def __call__( pb_resp = appengine.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 = appengine.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.appengine_v1.InstancesClient.list_instances", + extra={ + "serviceName": "google.appengine.v1.Instances", + "rpcName": "ListInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/services/async_client.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/services/async_client.py index 6c1c6ff348b1..a3eff13fe4f4 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/services/async_client.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/services/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, ServicesTransport from .transports.grpc_asyncio import ServicesGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class ServicesAsyncClient: """Manages services of an application.""" @@ -250,13 +260,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.appengine_v1.ServicesAsyncClient`.", + extra={ + "serviceName": "google.appengine.v1.Services", + "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.appengine.v1.Services", + "credentialsType": None, + }, + ) + async def list_services( self, request: Optional[Union[appengine.ListServicesRequest, 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]]] = (), ) -> pagers.ListServicesAsyncPager: r"""Lists all the services in the application. @@ -292,8 +324,10 @@ async def sample_list_services(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.appengine_admin_v1.services.services.pagers.ListServicesAsyncPager: @@ -352,7 +386,7 @@ async def get_service( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.Service: r"""Gets the current configuration of the specified service. @@ -388,8 +422,10 @@ async def sample_get_service(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.appengine_admin_v1.types.Service: @@ -445,7 +481,7 @@ async def update_service( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 configuration of the specified service. @@ -484,8 +520,10 @@ async def sample_update_service(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -548,7 +586,7 @@ async def delete_service( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 service and all enclosed versions. @@ -588,8 +626,10 @@ async def sample_delete_service(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/services/client.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/services/client.py index 2ecb6e192e10..ec46847cac94 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/services/client.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/services/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 as gac_operation # type: ignore from google.api_core import operation_async # type: ignore from google.protobuf import empty_pb2 # type: ignore @@ -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,13 +636,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.appengine_v1.ServicesClient`.", + extra={ + "serviceName": "google.appengine.v1.Services", + "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.appengine.v1.Services", + "credentialsType": None, + }, + ) + def list_services( self, request: Optional[Union[appengine.ListServicesRequest, 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]]] = (), ) -> pagers.ListServicesPager: r"""Lists all the services in the application. @@ -664,8 +701,10 @@ def sample_list_services(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.appengine_admin_v1.services.services.pagers.ListServicesPager: @@ -722,7 +761,7 @@ def get_service( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.Service: r"""Gets the current configuration of the specified service. @@ -758,8 +797,10 @@ def sample_get_service(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.appengine_admin_v1.types.Service: @@ -813,7 +854,7 @@ def update_service( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gac_operation.Operation: r"""Updates the configuration of the specified service. @@ -852,8 +893,10 @@ def sample_update_service(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -914,7 +957,7 @@ def delete_service( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gac_operation.Operation: r"""Deletes the specified service and all enclosed versions. @@ -954,8 +997,10 @@ def sample_delete_service(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/services/pagers.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/services/pagers.py index 82c3d4b86441..610a52237203 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/services/pagers.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/services/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = appengine.ListServicesRequest(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 = appengine.ListServicesRequest(request) diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/services/transports/grpc.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/services/transports/grpc.py index 02b5eea647ee..384ad3290941 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/services/transports/grpc.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/services/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.appengine_admin_v1.types import appengine, service from .base import DEFAULT_CLIENT_INFO, ServicesTransport +try: + from google.api_core import client_logging # 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.appengine.v1.Services", + "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.appengine.v1.Services", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ServicesGrpcTransport(ServicesTransport): """gRPC backend transport for Services. @@ -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 @@ -269,7 +357,7 @@ def list_services( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_services" not in self._stubs: - self._stubs["list_services"] = self.grpc_channel.unary_unary( + self._stubs["list_services"] = self._logged_channel.unary_unary( "/google.appengine.v1.Services/ListServices", request_serializer=appengine.ListServicesRequest.serialize, response_deserializer=appengine.ListServicesResponse.deserialize, @@ -294,7 +382,7 @@ def get_service(self) -> Callable[[appengine.GetServiceRequest], service.Service # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_service" not in self._stubs: - self._stubs["get_service"] = self.grpc_channel.unary_unary( + self._stubs["get_service"] = self._logged_channel.unary_unary( "/google.appengine.v1.Services/GetService", request_serializer=appengine.GetServiceRequest.serialize, response_deserializer=service.Service.deserialize, @@ -320,7 +408,7 @@ def update_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_service" not in self._stubs: - self._stubs["update_service"] = self.grpc_channel.unary_unary( + self._stubs["update_service"] = self._logged_channel.unary_unary( "/google.appengine.v1.Services/UpdateService", request_serializer=appengine.UpdateServiceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -347,7 +435,7 @@ def delete_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_service" not in self._stubs: - self._stubs["delete_service"] = self.grpc_channel.unary_unary( + self._stubs["delete_service"] = self._logged_channel.unary_unary( "/google.appengine.v1.Services/DeleteService", request_serializer=appengine.DeleteServiceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -355,7 +443,7 @@ def delete_service( return self._stubs["delete_service"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/services/transports/grpc_asyncio.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/services/transports/grpc_asyncio.py index b68a451358d6..0c3f877ee2b9 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/services/transports/grpc_asyncio.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/services/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.appengine_admin_v1.types import appengine, service from .base import DEFAULT_CLIENT_INFO, ServicesTransport from .grpc import ServicesGrpcTransport +try: + from google.api_core import client_logging # 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.appengine.v1.Services", + "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.appengine.v1.Services", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ServicesGrpcAsyncIOTransport(ServicesTransport): """gRPC AsyncIO backend transport for Services. @@ -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. @@ -281,7 +366,7 @@ def list_services( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_services" not in self._stubs: - self._stubs["list_services"] = self.grpc_channel.unary_unary( + self._stubs["list_services"] = self._logged_channel.unary_unary( "/google.appengine.v1.Services/ListServices", request_serializer=appengine.ListServicesRequest.serialize, response_deserializer=appengine.ListServicesResponse.deserialize, @@ -308,7 +393,7 @@ def get_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_service" not in self._stubs: - self._stubs["get_service"] = self.grpc_channel.unary_unary( + self._stubs["get_service"] = self._logged_channel.unary_unary( "/google.appengine.v1.Services/GetService", request_serializer=appengine.GetServiceRequest.serialize, response_deserializer=service.Service.deserialize, @@ -336,7 +421,7 @@ def update_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_service" not in self._stubs: - self._stubs["update_service"] = self.grpc_channel.unary_unary( + self._stubs["update_service"] = self._logged_channel.unary_unary( "/google.appengine.v1.Services/UpdateService", request_serializer=appengine.UpdateServiceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -365,7 +450,7 @@ def delete_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_service" not in self._stubs: - self._stubs["delete_service"] = self.grpc_channel.unary_unary( + self._stubs["delete_service"] = self._logged_channel.unary_unary( "/google.appengine.v1.Services/DeleteService", request_serializer=appengine.DeleteServiceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -403,7 +488,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-appengine-admin/google/cloud/appengine_admin_v1/services/services/transports/rest.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/services/transports/rest.py index b91590e0ad8b..6912599a409d 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/services/transports/rest.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/services/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -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,8 +110,8 @@ def post_update_service(self, response): def pre_delete_service( self, request: appengine.DeleteServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[appengine.DeleteServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[appengine.DeleteServiceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_service Override in a subclass to manipulate the request or metadata @@ -123,8 +131,10 @@ def post_delete_service( return response def pre_get_service( - self, request: appengine.GetServiceRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[appengine.GetServiceRequest, Sequence[Tuple[str, str]]]: + self, + request: appengine.GetServiceRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[appengine.GetServiceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_service Override in a subclass to manipulate the request or metadata @@ -144,8 +154,8 @@ def post_get_service(self, response: service.Service) -> service.Service: def pre_list_services( self, request: appengine.ListServicesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[appengine.ListServicesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[appengine.ListServicesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_services Override in a subclass to manipulate the request or metadata @@ -167,8 +177,8 @@ def post_list_services( def pre_update_service( self, request: appengine.UpdateServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[appengine.UpdateServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[appengine.UpdateServiceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_service Override in a subclass to manipulate the request or metadata @@ -349,7 +359,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete service method over HTTP. @@ -359,8 +369,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -373,6 +385,7 @@ def __call__( http_options = ( _BaseServicesRestTransport._BaseDeleteService._get_http_options() ) + request, metadata = self._interceptor.pre_delete_service(request, metadata) transcoded_request = ( _BaseServicesRestTransport._BaseDeleteService._get_transcoded_request( @@ -387,6 +400,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.appengine_v1.ServicesClient.DeleteService", + extra={ + "serviceName": "google.appengine.v1.Services", + "rpcName": "DeleteService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServicesRestTransport._DeleteService._get_response( self._host, @@ -405,7 +445,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_service(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.appengine_v1.ServicesClient.delete_service", + extra={ + "serviceName": "google.appengine.v1.Services", + "rpcName": "DeleteService", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetService(_BaseServicesRestTransport._BaseGetService, ServicesRestStub): @@ -440,7 +502,7 @@ 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.Service: r"""Call the get service method over HTTP. @@ -450,8 +512,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.service.Service: @@ -473,6 +537,7 @@ def __call__( http_options = ( _BaseServicesRestTransport._BaseGetService._get_http_options() ) + request, metadata = self._interceptor.pre_get_service(request, metadata) transcoded_request = ( _BaseServicesRestTransport._BaseGetService._get_transcoded_request( @@ -487,6 +552,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.appengine_v1.ServicesClient.GetService", + extra={ + "serviceName": "google.appengine.v1.Services", + "rpcName": "GetService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServicesRestTransport._GetService._get_response( self._host, @@ -507,7 +599,29 @@ def __call__( pb_resp = service.Service.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_service(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.Service.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.appengine_v1.ServicesClient.get_service", + extra={ + "serviceName": "google.appengine.v1.Services", + "rpcName": "GetService", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListServices(_BaseServicesRestTransport._BaseListServices, ServicesRestStub): @@ -542,7 +656,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> appengine.ListServicesResponse: r"""Call the list services method over HTTP. @@ -552,8 +666,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.appengine.ListServicesResponse: @@ -563,6 +679,7 @@ def __call__( http_options = ( _BaseServicesRestTransport._BaseListServices._get_http_options() ) + request, metadata = self._interceptor.pre_list_services(request, metadata) transcoded_request = ( _BaseServicesRestTransport._BaseListServices._get_transcoded_request( @@ -577,6 +694,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.appengine_v1.ServicesClient.ListServices", + extra={ + "serviceName": "google.appengine.v1.Services", + "rpcName": "ListServices", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServicesRestTransport._ListServices._get_response( self._host, @@ -597,7 +741,29 @@ def __call__( pb_resp = appengine.ListServicesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_services(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = appengine.ListServicesResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.appengine_v1.ServicesClient.list_services", + extra={ + "serviceName": "google.appengine.v1.Services", + "rpcName": "ListServices", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateService( @@ -635,7 +801,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 service method over HTTP. @@ -645,8 +811,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -659,6 +827,7 @@ def __call__( http_options = ( _BaseServicesRestTransport._BaseUpdateService._get_http_options() ) + request, metadata = self._interceptor.pre_update_service(request, metadata) transcoded_request = ( _BaseServicesRestTransport._BaseUpdateService._get_transcoded_request( @@ -677,6 +846,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.appengine_v1.ServicesClient.UpdateService", + extra={ + "serviceName": "google.appengine.v1.Services", + "rpcName": "UpdateService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ServicesRestTransport._UpdateService._get_response( self._host, @@ -696,7 +892,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_service(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.appengine_v1.ServicesClient.update_service", + extra={ + "serviceName": "google.appengine.v1.Services", + "rpcName": "UpdateService", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/versions/async_client.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/versions/async_client.py index 37a9eafb9ce8..a636bcfa38c9 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/versions/async_client.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/versions/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -57,6 +58,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, VersionsTransport from .transports.grpc_asyncio import VersionsGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class VersionsAsyncClient: """Manages versions of a service.""" @@ -252,13 +262,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.appengine_v1.VersionsAsyncClient`.", + extra={ + "serviceName": "google.appengine.v1.Versions", + "universeDomain": getattr( + self._client._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._client._transport._credentials).__module__}.{type(self._client._transport._credentials).__qualname__}", + "credentialsInfo": getattr( + self.transport._credentials, "get_cred_info", lambda: None + )(), + } + if hasattr(self._client._transport, "_credentials") + else { + "serviceName": "google.appengine.v1.Versions", + "credentialsType": None, + }, + ) + async def list_versions( self, request: Optional[Union[appengine.ListVersionsRequest, 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]]] = (), ) -> pagers.ListVersionsAsyncPager: r"""Lists the versions of a service. @@ -294,8 +326,10 @@ async def sample_list_versions(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.appengine_admin_v1.services.versions.pagers.ListVersionsAsyncPager: @@ -354,7 +388,7 @@ async def get_version( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> version.Version: r"""Gets the specified Version resource. By default, only a ``BASIC_VIEW`` will be returned. Specify the ``FULL_VIEW`` @@ -391,8 +425,10 @@ async def sample_get_version(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.appengine_admin_v1.types.Version: @@ -439,7 +475,7 @@ async def create_version( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 code and resource files to a new version. @@ -478,8 +514,10 @@ async def sample_create_version(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -535,7 +573,7 @@ async def update_version( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 Version resource. You can specify the following fields depending on the App Engine environment and @@ -609,8 +647,10 @@ async def sample_update_version(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -666,7 +706,7 @@ async def delete_version( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 existing Version resource. @@ -705,8 +745,10 @@ async def sample_delete_version(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/versions/client.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/versions/client.py index bdee4bba3e16..f94be581ee94 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/versions/client.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/versions/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + from google.api_core import operation as gac_operation # type: ignore from google.api_core import operation_async # type: ignore from google.protobuf import duration_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( @@ -624,13 +638,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.appengine_v1.VersionsClient`.", + extra={ + "serviceName": "google.appengine.v1.Versions", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__module__}.{type(self._transport._credentials).__qualname__}", + "credentialsInfo": getattr( + self.transport._credentials, "get_cred_info", lambda: None + )(), + } + if hasattr(self._transport, "_credentials") + else { + "serviceName": "google.appengine.v1.Versions", + "credentialsType": None, + }, + ) + def list_versions( self, request: Optional[Union[appengine.ListVersionsRequest, 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]]] = (), ) -> pagers.ListVersionsPager: r"""Lists the versions of a service. @@ -666,8 +703,10 @@ def sample_list_versions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.appengine_admin_v1.services.versions.pagers.ListVersionsPager: @@ -724,7 +763,7 @@ def get_version( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> version.Version: r"""Gets the specified Version resource. By default, only a ``BASIC_VIEW`` will be returned. Specify the ``FULL_VIEW`` @@ -761,8 +800,10 @@ def sample_get_version(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.appengine_admin_v1.types.Version: @@ -807,7 +848,7 @@ def create_version( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gac_operation.Operation: r"""Deploys code and resource files to a new version. @@ -846,8 +887,10 @@ def sample_create_version(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -901,7 +944,7 @@ def update_version( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gac_operation.Operation: r"""Updates the specified Version resource. You can specify the following fields depending on the App Engine environment and @@ -975,8 +1018,10 @@ def sample_update_version(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -1030,7 +1075,7 @@ def delete_version( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gac_operation.Operation: r"""Deletes an existing Version resource. @@ -1069,8 +1114,10 @@ def sample_delete_version(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/versions/pagers.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/versions/pagers.py index 06876d8af980..9335a8d65a94 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/versions/pagers.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/versions/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = appengine.ListVersionsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( retry (google.api_core.retry.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = appengine.ListVersionsRequest(request) diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/versions/transports/grpc.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/versions/transports/grpc.py index 1a49879c12a0..d8a1cfa485cb 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/versions/transports/grpc.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/versions/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -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.appengine_admin_v1.types import appengine, version from .base import DEFAULT_CLIENT_INFO, VersionsTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + + +class _LoggingClientInterceptor(grpc.UnaryUnaryClientInterceptor): # pragma: NO COVER + def intercept_unary_unary(self, continuation, client_call_details, request): + logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ) + if logging_enabled: # pragma: NO COVER + request_metadata = client_call_details.metadata + if isinstance(request, proto.Message): + request_payload = type(request).to_json(request) + elif isinstance(request, google.protobuf.message.Message): + request_payload = MessageToJson(request) + else: + request_payload = f"{type(request).__name__}: {pickle.dumps(request)}" + + request_metadata = { + key: value.decode("utf-8") if isinstance(value, bytes) else value + for key, value in request_metadata + } + grpc_request = { + "payload": request_payload, + "requestMethod": "grpc", + "metadata": dict(request_metadata), + } + _LOGGER.debug( + f"Sending request for {client_call_details.method}", + extra={ + "serviceName": "google.appengine.v1.Versions", + "rpcName": client_call_details.method, + "request": grpc_request, + "metadata": grpc_request["metadata"], + }, + ) + + response = continuation(client_call_details, request) + if logging_enabled: # pragma: NO COVER + response_metadata = response.trailing_metadata() + # Convert gRPC metadata `` to list of tuples + metadata = ( + dict([(k, str(v)) for k, v in response_metadata]) + if response_metadata + else None + ) + result = response.result() + if isinstance(result, proto.Message): + response_payload = type(result).to_json(result) + elif isinstance(result, google.protobuf.message.Message): + response_payload = MessageToJson(result) + else: + response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" + grpc_response = { + "payload": response_payload, + "metadata": metadata, + "status": "OK", + } + _LOGGER.debug( + f"Received response for {client_call_details.method}.", + extra={ + "serviceName": "google.appengine.v1.Versions", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VersionsGrpcTransport(VersionsTransport): """gRPC backend transport for Versions. @@ -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 @@ -269,7 +357,7 @@ def list_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_versions" not in self._stubs: - self._stubs["list_versions"] = self.grpc_channel.unary_unary( + self._stubs["list_versions"] = self._logged_channel.unary_unary( "/google.appengine.v1.Versions/ListVersions", request_serializer=appengine.ListVersionsRequest.serialize, response_deserializer=appengine.ListVersionsResponse.deserialize, @@ -295,7 +383,7 @@ def get_version(self) -> Callable[[appengine.GetVersionRequest], version.Version # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_version" not in self._stubs: - self._stubs["get_version"] = self.grpc_channel.unary_unary( + self._stubs["get_version"] = self._logged_channel.unary_unary( "/google.appengine.v1.Versions/GetVersion", request_serializer=appengine.GetVersionRequest.serialize, response_deserializer=version.Version.deserialize, @@ -321,7 +409,7 @@ def create_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_version" not in self._stubs: - self._stubs["create_version"] = self.grpc_channel.unary_unary( + self._stubs["create_version"] = self._logged_channel.unary_unary( "/google.appengine.v1.Versions/CreateVersion", request_serializer=appengine.CreateVersionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -382,7 +470,7 @@ def update_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_version" not in self._stubs: - self._stubs["update_version"] = self.grpc_channel.unary_unary( + self._stubs["update_version"] = self._logged_channel.unary_unary( "/google.appengine.v1.Versions/UpdateVersion", request_serializer=appengine.UpdateVersionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -408,7 +496,7 @@ def delete_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_version" not in self._stubs: - self._stubs["delete_version"] = self.grpc_channel.unary_unary( + self._stubs["delete_version"] = self._logged_channel.unary_unary( "/google.appengine.v1.Versions/DeleteVersion", request_serializer=appengine.DeleteVersionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -416,7 +504,7 @@ def delete_version( return self._stubs["delete_version"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/versions/transports/grpc_asyncio.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/versions/transports/grpc_asyncio.py index 9ec3915e4955..88bb00c50ec0 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/versions/transports/grpc_asyncio.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/versions/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -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.appengine_admin_v1.types import appengine, version from .base import DEFAULT_CLIENT_INFO, VersionsTransport from .grpc import VersionsGrpcTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + + +class _LoggingClientAIOInterceptor( + grpc.aio.UnaryUnaryClientInterceptor +): # pragma: NO COVER + async def intercept_unary_unary(self, continuation, client_call_details, request): + logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ) + if logging_enabled: # pragma: NO COVER + request_metadata = client_call_details.metadata + if isinstance(request, proto.Message): + request_payload = type(request).to_json(request) + elif isinstance(request, google.protobuf.message.Message): + request_payload = MessageToJson(request) + else: + request_payload = f"{type(request).__name__}: {pickle.dumps(request)}" + + request_metadata = { + key: value.decode("utf-8") if isinstance(value, bytes) else value + for key, value in request_metadata + } + grpc_request = { + "payload": request_payload, + "requestMethod": "grpc", + "metadata": dict(request_metadata), + } + _LOGGER.debug( + f"Sending request for {client_call_details.method}", + extra={ + "serviceName": "google.appengine.v1.Versions", + "rpcName": str(client_call_details.method), + "request": grpc_request, + "metadata": grpc_request["metadata"], + }, + ) + response = await continuation(client_call_details, request) + if logging_enabled: # pragma: NO COVER + response_metadata = await response.trailing_metadata() + # Convert gRPC metadata `` to list of tuples + metadata = ( + dict([(k, str(v)) for k, v in response_metadata]) + if response_metadata + else None + ) + result = await response + if isinstance(result, proto.Message): + response_payload = type(result).to_json(result) + elif isinstance(result, google.protobuf.message.Message): + response_payload = MessageToJson(result) + else: + response_payload = f"{type(result).__name__}: {pickle.dumps(result)}" + grpc_response = { + "payload": response_payload, + "metadata": metadata, + "status": "OK", + } + _LOGGER.debug( + f"Received response to rpc {client_call_details.method}.", + extra={ + "serviceName": "google.appengine.v1.Versions", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class VersionsGrpcAsyncIOTransport(VersionsTransport): """gRPC AsyncIO backend transport for Versions. @@ -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. @@ -281,7 +366,7 @@ def list_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_versions" not in self._stubs: - self._stubs["list_versions"] = self.grpc_channel.unary_unary( + self._stubs["list_versions"] = self._logged_channel.unary_unary( "/google.appengine.v1.Versions/ListVersions", request_serializer=appengine.ListVersionsRequest.serialize, response_deserializer=appengine.ListVersionsResponse.deserialize, @@ -309,7 +394,7 @@ def get_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_version" not in self._stubs: - self._stubs["get_version"] = self.grpc_channel.unary_unary( + self._stubs["get_version"] = self._logged_channel.unary_unary( "/google.appengine.v1.Versions/GetVersion", request_serializer=appengine.GetVersionRequest.serialize, response_deserializer=version.Version.deserialize, @@ -337,7 +422,7 @@ def create_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_version" not in self._stubs: - self._stubs["create_version"] = self.grpc_channel.unary_unary( + self._stubs["create_version"] = self._logged_channel.unary_unary( "/google.appengine.v1.Versions/CreateVersion", request_serializer=appengine.CreateVersionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -400,7 +485,7 @@ def update_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_version" not in self._stubs: - self._stubs["update_version"] = self.grpc_channel.unary_unary( + self._stubs["update_version"] = self._logged_channel.unary_unary( "/google.appengine.v1.Versions/UpdateVersion", request_serializer=appengine.UpdateVersionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -428,7 +513,7 @@ def delete_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_version" not in self._stubs: - self._stubs["delete_version"] = self.grpc_channel.unary_unary( + self._stubs["delete_version"] = self._logged_channel.unary_unary( "/google.appengine.v1.Versions/DeleteVersion", request_serializer=appengine.DeleteVersionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -471,7 +556,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-appengine-admin/google/cloud/appengine_admin_v1/services/versions/transports/rest.py b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/versions/transports/rest.py index 5532a2203ebb..4c560816e40f 100644 --- a/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/versions/transports/rest.py +++ b/packages/google-cloud-appengine-admin/google/cloud/appengine_admin_v1/services/versions/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -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,8 @@ def post_update_version(self, response): def pre_create_version( self, request: appengine.CreateVersionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[appengine.CreateVersionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[appengine.CreateVersionRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_version Override in a subclass to manipulate the request or metadata @@ -133,8 +141,8 @@ def post_create_version( def pre_delete_version( self, request: appengine.DeleteVersionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[appengine.DeleteVersionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[appengine.DeleteVersionRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_version Override in a subclass to manipulate the request or metadata @@ -154,8 +162,10 @@ def post_delete_version( return response def pre_get_version( - self, request: appengine.GetVersionRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[appengine.GetVersionRequest, Sequence[Tuple[str, str]]]: + self, + request: appengine.GetVersionRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[appengine.GetVersionRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_version Override in a subclass to manipulate the request or metadata @@ -175,8 +185,8 @@ def post_get_version(self, response: version.Version) -> version.Version: def pre_list_versions( self, request: appengine.ListVersionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[appengine.ListVersionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[appengine.ListVersionsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_versions Override in a subclass to manipulate the request or metadata @@ -198,8 +208,8 @@ def post_list_versions( def pre_update_version( self, request: appengine.UpdateVersionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[appengine.UpdateVersionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[appengine.UpdateVersionRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_version Override in a subclass to manipulate the request or metadata @@ -381,7 +391,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 version method over HTTP. @@ -391,8 +401,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -405,6 +417,7 @@ def __call__( http_options = ( _BaseVersionsRestTransport._BaseCreateVersion._get_http_options() ) + request, metadata = self._interceptor.pre_create_version(request, metadata) transcoded_request = ( _BaseVersionsRestTransport._BaseCreateVersion._get_transcoded_request( @@ -423,6 +436,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.appengine_v1.VersionsClient.CreateVersion", + extra={ + "serviceName": "google.appengine.v1.Versions", + "rpcName": "CreateVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VersionsRestTransport._CreateVersion._get_response( self._host, @@ -442,7 +482,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_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.appengine_v1.VersionsClient.create_version", + extra={ + "serviceName": "google.appengine.v1.Versions", + "rpcName": "CreateVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteVersion( @@ -479,7 +541,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 version method over HTTP. @@ -489,8 +551,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -503,6 +567,7 @@ def __call__( http_options = ( _BaseVersionsRestTransport._BaseDeleteVersion._get_http_options() ) + request, metadata = self._interceptor.pre_delete_version(request, metadata) transcoded_request = ( _BaseVersionsRestTransport._BaseDeleteVersion._get_transcoded_request( @@ -517,6 +582,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.appengine_v1.VersionsClient.DeleteVersion", + extra={ + "serviceName": "google.appengine.v1.Versions", + "rpcName": "DeleteVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VersionsRestTransport._DeleteVersion._get_response( self._host, @@ -535,7 +627,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_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.appengine_v1.VersionsClient.delete_version", + extra={ + "serviceName": "google.appengine.v1.Versions", + "rpcName": "DeleteVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetVersion(_BaseVersionsRestTransport._BaseGetVersion, VersionsRestStub): @@ -570,7 +684,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> version.Version: r"""Call the get version method over HTTP. @@ -580,8 +694,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.version.Version: @@ -594,6 +710,7 @@ def __call__( http_options = ( _BaseVersionsRestTransport._BaseGetVersion._get_http_options() ) + request, metadata = self._interceptor.pre_get_version(request, metadata) transcoded_request = ( _BaseVersionsRestTransport._BaseGetVersion._get_transcoded_request( @@ -608,6 +725,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.appengine_v1.VersionsClient.GetVersion", + extra={ + "serviceName": "google.appengine.v1.Versions", + "rpcName": "GetVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VersionsRestTransport._GetVersion._get_response( self._host, @@ -628,7 +772,29 @@ def __call__( pb_resp = version.Version.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = version.Version.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.appengine_v1.VersionsClient.get_version", + extra={ + "serviceName": "google.appengine.v1.Versions", + "rpcName": "GetVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListVersions(_BaseVersionsRestTransport._BaseListVersions, VersionsRestStub): @@ -663,7 +829,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> appengine.ListVersionsResponse: r"""Call the list versions method over HTTP. @@ -673,8 +839,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.appengine.ListVersionsResponse: @@ -684,6 +852,7 @@ def __call__( http_options = ( _BaseVersionsRestTransport._BaseListVersions._get_http_options() ) + request, metadata = self._interceptor.pre_list_versions(request, metadata) transcoded_request = ( _BaseVersionsRestTransport._BaseListVersions._get_transcoded_request( @@ -698,6 +867,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.appengine_v1.VersionsClient.ListVersions", + extra={ + "serviceName": "google.appengine.v1.Versions", + "rpcName": "ListVersions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VersionsRestTransport._ListVersions._get_response( self._host, @@ -718,7 +914,29 @@ def __call__( pb_resp = appengine.ListVersionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_versions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = appengine.ListVersionsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.appengine_v1.VersionsClient.list_versions", + extra={ + "serviceName": "google.appengine.v1.Versions", + "rpcName": "ListVersions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateVersion( @@ -756,7 +974,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 version method over HTTP. @@ -766,8 +984,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -780,6 +1000,7 @@ def __call__( http_options = ( _BaseVersionsRestTransport._BaseUpdateVersion._get_http_options() ) + request, metadata = self._interceptor.pre_update_version(request, metadata) transcoded_request = ( _BaseVersionsRestTransport._BaseUpdateVersion._get_transcoded_request( @@ -798,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 = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.appengine_v1.VersionsClient.UpdateVersion", + extra={ + "serviceName": "google.appengine.v1.Versions", + "rpcName": "UpdateVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = VersionsRestTransport._UpdateVersion._get_response( self._host, @@ -817,7 +1065,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_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.appengine_v1.VersionsClient.update_version", + extra={ + "serviceName": "google.appengine.v1.Versions", + "rpcName": "UpdateVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-appengine-admin/samples/generated_samples/snippet_metadata_google.appengine.v1.json b/packages/google-cloud-appengine-admin/samples/generated_samples/snippet_metadata_google.appengine.v1.json index 81c672284b63..a039900680d7 100644 --- a/packages/google-cloud-appengine-admin/samples/generated_samples/snippet_metadata_google.appengine.v1.json +++ b/packages/google-cloud-appengine-admin/samples/generated_samples/snippet_metadata_google.appengine.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-appengine-admin", - "version": "1.12.1" + "version": "0.1.0" }, "snippets": [ { @@ -43,7 +43,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -200,7 +200,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.types.Application", @@ -280,7 +280,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.types.Application", @@ -357,7 +357,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -433,7 +433,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -510,7 +510,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -586,7 +586,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -663,7 +663,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.types.AuthorizedCertificate", @@ -739,7 +739,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.types.AuthorizedCertificate", @@ -816,7 +816,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_authorized_certificate" @@ -889,7 +889,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_authorized_certificate" @@ -963,7 +963,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.types.AuthorizedCertificate", @@ -1039,7 +1039,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.types.AuthorizedCertificate", @@ -1116,7 +1116,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.services.authorized_certificates.pagers.ListAuthorizedCertificatesAsyncPager", @@ -1192,7 +1192,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.services.authorized_certificates.pagers.ListAuthorizedCertificatesPager", @@ -1269,7 +1269,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.types.AuthorizedCertificate", @@ -1345,7 +1345,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.types.AuthorizedCertificate", @@ -1422,7 +1422,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.services.authorized_domains.pagers.ListAuthorizedDomainsAsyncPager", @@ -1498,7 +1498,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.services.authorized_domains.pagers.ListAuthorizedDomainsPager", @@ -1575,7 +1575,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1651,7 +1651,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1728,7 +1728,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1804,7 +1804,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1881,7 +1881,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.types.DomainMapping", @@ -1957,7 +1957,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.types.DomainMapping", @@ -2034,7 +2034,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.services.domain_mappings.pagers.ListDomainMappingsAsyncPager", @@ -2110,7 +2110,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.services.domain_mappings.pagers.ListDomainMappingsPager", @@ -2187,7 +2187,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2263,7 +2263,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2340,7 +2340,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.types.BatchUpdateIngressRulesResponse", @@ -2416,7 +2416,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.types.BatchUpdateIngressRulesResponse", @@ -2493,7 +2493,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.types.FirewallRule", @@ -2569,7 +2569,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.types.FirewallRule", @@ -2646,7 +2646,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_ingress_rule" @@ -2719,7 +2719,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_ingress_rule" @@ -2793,7 +2793,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.types.FirewallRule", @@ -2869,7 +2869,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.types.FirewallRule", @@ -2946,7 +2946,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.services.firewall.pagers.ListIngressRulesAsyncPager", @@ -3022,7 +3022,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.services.firewall.pagers.ListIngressRulesPager", @@ -3099,7 +3099,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.types.FirewallRule", @@ -3175,7 +3175,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.types.FirewallRule", @@ -3252,7 +3252,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3328,7 +3328,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3405,7 +3405,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3481,7 +3481,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3558,7 +3558,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.types.Instance", @@ -3634,7 +3634,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.types.Instance", @@ -3711,7 +3711,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.services.instances.pagers.ListInstancesAsyncPager", @@ -3787,7 +3787,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.services.instances.pagers.ListInstancesPager", @@ -3864,7 +3864,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3940,7 +3940,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4017,7 +4017,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.types.Service", @@ -4093,7 +4093,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.types.Service", @@ -4170,7 +4170,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.services.services.pagers.ListServicesAsyncPager", @@ -4246,7 +4246,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.services.services.pagers.ListServicesPager", @@ -4323,7 +4323,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4399,7 +4399,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4476,7 +4476,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4552,7 +4552,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4629,7 +4629,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4705,7 +4705,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4782,7 +4782,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.types.Version", @@ -4858,7 +4858,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.types.Version", @@ -4935,7 +4935,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.services.versions.pagers.ListVersionsAsyncPager", @@ -5011,7 +5011,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.appengine_admin_v1.services.versions.pagers.ListVersionsPager", @@ -5088,7 +5088,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5164,7 +5164,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-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_applications.py b/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_applications.py index b2b59b82e43c..1525ff0d0f9f 100644 --- a/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_applications.py +++ b/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_applications.py @@ -2192,6 +2192,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) @@ -2705,6 +2706,7 @@ def test_get_application_rest_bad_request(request_type=appengine.GetApplicationR response_value.status_code = 400 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) @@ -2750,6 +2752,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. @@ -2802,6 +2805,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 = application.Application.to_json(application.Application()) req.return_value.content = return_value @@ -2846,6 +2850,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) @@ -2970,6 +2975,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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. @@ -3011,6 +3017,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 @@ -3055,6 +3062,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) @@ -3179,6 +3187,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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. @@ -3220,6 +3229,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 @@ -3264,6 +3274,7 @@ def test_repair_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.repair_application(request) @@ -3294,6 +3305,7 @@ def test_repair_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.repair_application(request) # Establish that the response is the type that we expect. @@ -3335,6 +3347,7 @@ def test_repair_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 diff --git a/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_authorized_certificates.py b/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_authorized_certificates.py index 6259710fa02c..8e695cca905e 100644 --- a/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_authorized_certificates.py +++ b/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_authorized_certificates.py @@ -3356,6 +3356,7 @@ def test_list_authorized_certificates_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_authorized_certificates(request) @@ -3391,6 +3392,7 @@ def test_list_authorized_certificates_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_authorized_certificates(request) # Establish that the response is the type that we expect. @@ -3433,6 +3435,7 @@ def test_list_authorized_certificates_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = appengine.ListAuthorizedCertificatesResponse.to_json( appengine.ListAuthorizedCertificatesResponse() ) @@ -3479,6 +3482,7 @@ def test_get_authorized_certificate_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_authorized_certificate(request) @@ -3519,6 +3523,7 @@ def test_get_authorized_certificate_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_authorized_certificate(request) # Establish that the response is the type that we expect. @@ -3566,6 +3571,7 @@ def test_get_authorized_certificate_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = certificate.AuthorizedCertificate.to_json( certificate.AuthorizedCertificate() ) @@ -3612,6 +3618,7 @@ def test_create_authorized_certificate_rest_bad_request( response_value.status_code = 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_authorized_certificate(request) @@ -3736,6 +3743,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_authorized_certificate(request) # Establish that the response is the type that we expect. @@ -3783,6 +3791,7 @@ def test_create_authorized_certificate_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = certificate.AuthorizedCertificate.to_json( certificate.AuthorizedCertificate() ) @@ -3829,6 +3838,7 @@ def test_update_authorized_certificate_rest_bad_request( response_value.status_code = 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_authorized_certificate(request) @@ -3953,6 +3963,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_authorized_certificate(request) # Establish that the response is the type that we expect. @@ -4000,6 +4011,7 @@ def test_update_authorized_certificate_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = certificate.AuthorizedCertificate.to_json( certificate.AuthorizedCertificate() ) @@ -4046,6 +4058,7 @@ def test_delete_authorized_certificate_rest_bad_request( response_value.status_code = 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_authorized_certificate(request) @@ -4076,6 +4089,7 @@ def test_delete_authorized_certificate_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_authorized_certificate(request) # Establish that the response is the type that we expect. @@ -4113,6 +4127,7 @@ def test_delete_authorized_certificate_rest_interceptors(null_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 = appengine.DeleteAuthorizedCertificateRequest() metadata = [ diff --git a/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_authorized_domains.py b/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_authorized_domains.py index 60f3bb84d664..133b383b497a 100644 --- a/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_authorized_domains.py +++ b/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_authorized_domains.py @@ -1866,6 +1866,7 @@ def test_list_authorized_domains_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_authorized_domains(request) @@ -1901,6 +1902,7 @@ def test_list_authorized_domains_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_authorized_domains(request) # Establish that the response is the type that we expect. @@ -1941,6 +1943,7 @@ def test_list_authorized_domains_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = appengine.ListAuthorizedDomainsResponse.to_json( appengine.ListAuthorizedDomainsResponse() ) diff --git a/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_domain_mappings.py b/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_domain_mappings.py index 6cefee35a9e5..f870a31de214 100644 --- a/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_domain_mappings.py +++ b/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_domain_mappings.py @@ -3256,6 +3256,7 @@ def test_list_domain_mappings_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_domain_mappings(request) @@ -3291,6 +3292,7 @@ def test_list_domain_mappings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_domain_mappings(request) # Establish that the response is the type that we expect. @@ -3331,6 +3333,7 @@ def test_list_domain_mappings_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = appengine.ListDomainMappingsResponse.to_json( appengine.ListDomainMappingsResponse() ) @@ -3377,6 +3380,7 @@ def test_get_domain_mapping_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_domain_mapping(request) @@ -3413,6 +3417,7 @@ def test_get_domain_mapping_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_domain_mapping(request) # Establish that the response is the type that we expect. @@ -3454,6 +3459,7 @@ def test_get_domain_mapping_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = domain_mapping.DomainMapping.to_json( domain_mapping.DomainMapping() ) @@ -3500,6 +3506,7 @@ def test_create_domain_mapping_rest_bad_request( response_value.status_code = 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_domain_mapping(request) @@ -3609,6 +3616,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_domain_mapping(request) # Establish that the response is the type that we expect. @@ -3650,6 +3658,7 @@ def test_create_domain_mapping_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -3694,6 +3703,7 @@ def test_update_domain_mapping_rest_bad_request( response_value.status_code = 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_domain_mapping(request) @@ -3803,6 +3813,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_domain_mapping(request) # Establish that the response is the type that we expect. @@ -3844,6 +3855,7 @@ def test_update_domain_mapping_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -3888,6 +3900,7 @@ def test_delete_domain_mapping_rest_bad_request( response_value.status_code = 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_domain_mapping(request) @@ -3918,6 +3931,7 @@ def test_delete_domain_mapping_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_domain_mapping(request) # Establish that the response is the type that we expect. @@ -3959,6 +3973,7 @@ def test_delete_domain_mapping_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_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-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_firewall.py b/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_firewall.py index 44e92176cf49..e2c8f934a630 100644 --- a/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_firewall.py +++ b/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_firewall.py @@ -3516,6 +3516,7 @@ def test_list_ingress_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_ingress_rules(request) @@ -3551,6 +3552,7 @@ def test_list_ingress_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_ingress_rules(request) # Establish that the response is the type that we expect. @@ -3589,6 +3591,7 @@ def test_list_ingress_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 = appengine.ListIngressRulesResponse.to_json( appengine.ListIngressRulesResponse() ) @@ -3635,6 +3638,7 @@ def test_batch_update_ingress_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.batch_update_ingress_rules(request) @@ -3668,6 +3672,7 @@ def test_batch_update_ingress_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.batch_update_ingress_rules(request) # Establish that the response is the type that we expect. @@ -3705,6 +3710,7 @@ def test_batch_update_ingress_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 = appengine.BatchUpdateIngressRulesResponse.to_json( appengine.BatchUpdateIngressRulesResponse() ) @@ -3751,6 +3757,7 @@ def test_create_ingress_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_ingress_rule(request) @@ -3862,6 +3869,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_ingress_rule(request) # Establish that the response is the type that we expect. @@ -3903,6 +3911,7 @@ def test_create_ingress_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 = firewall.FirewallRule.to_json(firewall.FirewallRule()) req.return_value.content = return_value @@ -3947,6 +3956,7 @@ def test_get_ingress_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_ingress_rule(request) @@ -3985,6 +3995,7 @@ def test_get_ingress_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_ingress_rule(request) # Establish that the response is the type that we expect. @@ -4026,6 +4037,7 @@ def test_get_ingress_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 = firewall.FirewallRule.to_json(firewall.FirewallRule()) req.return_value.content = return_value @@ -4070,6 +4082,7 @@ def test_update_ingress_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_ingress_rule(request) @@ -4181,6 +4194,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_ingress_rule(request) # Establish that the response is the type that we expect. @@ -4222,6 +4236,7 @@ def test_update_ingress_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 = firewall.FirewallRule.to_json(firewall.FirewallRule()) req.return_value.content = return_value @@ -4266,6 +4281,7 @@ def test_delete_ingress_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_ingress_rule(request) @@ -4296,6 +4312,7 @@ def test_delete_ingress_rule_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_ingress_rule(request) # Establish that the response is the type that we expect. @@ -4330,6 +4347,7 @@ def test_delete_ingress_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"} request = appengine.DeleteIngressRuleRequest() metadata = [ diff --git a/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_instances.py b/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_instances.py index 7abe36da166f..152bd013e85f 100644 --- a/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_instances.py +++ b/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_instances.py @@ -2822,6 +2822,7 @@ def test_list_instances_rest_bad_request(request_type=appengine.ListInstancesReq response_value.status_code = 400 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) @@ -2857,6 +2858,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. @@ -2893,6 +2895,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 = appengine.ListInstancesResponse.to_json( appengine.ListInstancesResponse() ) @@ -2939,6 +2942,7 @@ def test_get_instance_rest_bad_request(request_type=appengine.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) @@ -2991,6 +2995,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. @@ -3042,6 +3047,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 = instance.Instance.to_json(instance.Instance()) req.return_value.content = return_value @@ -3086,6 +3092,7 @@ def test_delete_instance_rest_bad_request(request_type=appengine.DeleteInstanceR response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_instance(request) @@ -3118,6 +3125,7 @@ def test_delete_instance_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_instance(request) # Establish that the response is the type that we expect. @@ -3157,6 +3165,7 @@ def test_delete_instance_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -3201,6 +3210,7 @@ def test_debug_instance_rest_bad_request(request_type=appengine.DebugInstanceReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.debug_instance(request) @@ -3233,6 +3243,7 @@ def test_debug_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.debug_instance(request) # Establish that the response is the type that we expect. @@ -3270,6 +3281,7 @@ def test_debug_instance_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_services.py b/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_services.py index 6517ea9f2963..46a64bd956af 100644 --- a/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_services.py +++ b/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_services.py @@ -2740,6 +2740,7 @@ def test_list_services_rest_bad_request(request_type=appengine.ListServicesReque response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_services(request) @@ -2775,6 +2776,7 @@ def test_list_services_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_services(request) # Establish that the response is the type that we expect. @@ -2811,6 +2813,7 @@ def test_list_services_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = appengine.ListServicesResponse.to_json( appengine.ListServicesResponse() ) @@ -2855,6 +2858,7 @@ def test_get_service_rest_bad_request(request_type=appengine.GetServiceRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_service(request) @@ -2891,6 +2895,7 @@ def test_get_service_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_service(request) # Establish that the response is the type that we expect. @@ -2928,6 +2933,7 @@ def test_get_service_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = service.Service.to_json(service.Service()) req.return_value.content = return_value @@ -2970,6 +2976,7 @@ def test_update_service_rest_bad_request(request_type=appengine.UpdateServiceReq response_value.status_code = 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_service(request) @@ -3074,6 +3081,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_service(request) # Establish that the response is the type that we expect. @@ -3111,6 +3119,7 @@ def test_update_service_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -3153,6 +3162,7 @@ def test_delete_service_rest_bad_request(request_type=appengine.DeleteServiceReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_service(request) @@ -3183,6 +3193,7 @@ def test_delete_service_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_service(request) # Establish that the response is the type that we expect. @@ -3220,6 +3231,7 @@ def test_delete_service_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_versions.py b/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_versions.py index 1a379fbd916d..0fa06d1169d6 100644 --- a/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_versions.py +++ b/packages/google-cloud-appengine-admin/tests/unit/gapic/appengine_admin_v1/test_versions.py @@ -3162,6 +3162,7 @@ def test_list_versions_rest_bad_request(request_type=appengine.ListVersionsReque response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_versions(request) @@ -3197,6 +3198,7 @@ def test_list_versions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_versions(request) # Establish that the response is the type that we expect. @@ -3233,6 +3235,7 @@ def test_list_versions_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = appengine.ListVersionsResponse.to_json( appengine.ListVersionsResponse() ) @@ -3277,6 +3280,7 @@ def test_get_version_rest_bad_request(request_type=appengine.GetVersionRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_version(request) @@ -3330,6 +3334,7 @@ def test_get_version_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_version(request) # Establish that the response is the type that we expect. @@ -3386,6 +3391,7 @@ def test_get_version_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = version.Version.to_json(version.Version()) req.return_value.content = return_value @@ -3428,6 +3434,7 @@ def test_create_version_rest_bad_request(request_type=appengine.CreateVersionReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_version(request) @@ -3688,6 +3695,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_version(request) # Establish that the response is the type that we expect. @@ -3725,6 +3733,7 @@ def test_create_version_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -3767,6 +3776,7 @@ def test_update_version_rest_bad_request(request_type=appengine.UpdateVersionReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_version(request) @@ -4027,6 +4037,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_version(request) # Establish that the response is the type that we expect. @@ -4064,6 +4075,7 @@ def test_update_version_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -4106,6 +4118,7 @@ def test_delete_version_rest_bad_request(request_type=appengine.DeleteVersionReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_version(request) @@ -4136,6 +4149,7 @@ def test_delete_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.delete_version(request) # Establish that the response is the type that we expect. @@ -4173,6 +4187,7 @@ def test_delete_version_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value diff --git a/packages/google-cloud-apphub/google/cloud/apphub/gapic_version.py b/packages/google-cloud-apphub/google/cloud/apphub/gapic_version.py index 937ede8823ef..558c8aab67c5 100644 --- a/packages/google-cloud-apphub/google/cloud/apphub/gapic_version.py +++ b/packages/google-cloud-apphub/google/cloud/apphub/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.4" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-apphub/google/cloud/apphub_v1/gapic_version.py b/packages/google-cloud-apphub/google/cloud/apphub_v1/gapic_version.py index 937ede8823ef..558c8aab67c5 100644 --- a/packages/google-cloud-apphub/google/cloud/apphub_v1/gapic_version.py +++ b/packages/google-cloud-apphub/google/cloud/apphub_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.4" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-apphub/google/cloud/apphub_v1/services/app_hub/async_client.py b/packages/google-cloud-apphub/google/cloud/apphub_v1/services/app_hub/async_client.py index 2b709296d7da..d45e188c9bcb 100644 --- a/packages/google-cloud-apphub/google/cloud/apphub_v1/services/app_hub/async_client.py +++ b/packages/google-cloud-apphub/google/cloud/apphub_v1/services/app_hub/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, @@ -70,6 +71,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, AppHubTransport from .transports.grpc_asyncio import AppHubGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class AppHubAsyncClient: """The App Hub API allows you to manage App Hub resources.""" @@ -283,6 +293,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.apphub_v1.AppHubAsyncClient`.", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "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.apphub.v1.AppHub", + "credentialsType": None, + }, + ) + async def lookup_service_project_attachment( self, request: Optional[ @@ -292,7 +324,7 @@ async def lookup_service_project_attachment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apphub_service.LookupServiceProjectAttachmentResponse: r"""Lists a service project attachment for a given service project. You can call this API from any project @@ -340,8 +372,10 @@ async def sample_lookup_service_project_attachment(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apphub_v1.types.LookupServiceProjectAttachmentResponse: @@ -406,7 +440,7 @@ async def list_service_project_attachments( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListServiceProjectAttachmentsAsyncPager: r"""Lists service projects attached to the host project. @@ -453,8 +487,10 @@ async def sample_list_service_project_attachments(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apphub_v1.services.app_hub.pagers.ListServiceProjectAttachmentsAsyncPager: @@ -535,7 +571,7 @@ async def create_service_project_attachment( service_project_attachment_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"""Attaches a service project to the host project. @@ -603,8 +639,10 @@ async def sample_create_service_project_attachment(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -690,7 +728,7 @@ async def get_service_project_attachment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service_project_attachment.ServiceProjectAttachment: r"""Gets a service project attachment. @@ -735,8 +773,10 @@ async def sample_get_service_project_attachment(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apphub_v1.types.ServiceProjectAttachment: @@ -807,7 +847,7 @@ async def delete_service_project_attachment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a service project attachment. @@ -856,8 +896,10 @@ async def sample_delete_service_project_attachment(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -940,7 +982,7 @@ async def detach_service_project_attachment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apphub_service.DetachServiceProjectAttachmentResponse: r"""Detaches a service project from a host project. You can call this API from any service project without @@ -989,8 +1031,10 @@ async def sample_detach_service_project_attachment(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apphub_v1.types.DetachServiceProjectAttachmentResponse: @@ -1055,7 +1099,7 @@ async def list_discovered_services( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDiscoveredServicesAsyncPager: r"""Lists Discovered Services that can be added to an Application in a host project and location. @@ -1101,8 +1145,10 @@ async def sample_list_discovered_services(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apphub_v1.services.app_hub.pagers.ListDiscoveredServicesAsyncPager: @@ -1179,7 +1225,7 @@ async def get_discovered_service( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.DiscoveredService: r"""Gets a Discovered Service in a host project and location. @@ -1224,8 +1270,10 @@ async def sample_get_discovered_service(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apphub_v1.types.DiscoveredService: @@ -1292,7 +1340,7 @@ async def lookup_discovered_service( uri: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apphub_service.LookupDiscoveredServiceResponse: r"""Lists a Discovered Service in a host project and location, with a given resource URI. @@ -1347,8 +1395,10 @@ async def sample_lookup_discovered_service(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apphub_v1.types.LookupDiscoveredServiceResponse: @@ -1409,7 +1459,7 @@ async def list_services( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListServicesAsyncPager: r"""Lists Services in an Application. @@ -1454,8 +1504,10 @@ async def sample_list_services(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apphub_v1.services.app_hub.pagers.ListServicesAsyncPager: @@ -1532,7 +1584,7 @@ async def create_service( service_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 Service in an Application. @@ -1600,8 +1652,10 @@ async def sample_create_service(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -1678,7 +1732,7 @@ async def get_service( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.Service: r"""Gets a Service in an Application. @@ -1722,8 +1776,10 @@ async def sample_get_service(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apphub_v1.types.Service: @@ -1788,7 +1844,7 @@ async def update_service( 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 Service in an Application. @@ -1851,8 +1907,10 @@ async def sample_update_service(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -1929,7 +1987,7 @@ async def delete_service( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a Service from an Application. @@ -1977,8 +2035,10 @@ async def sample_delete_service(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -2059,7 +2119,7 @@ async def list_discovered_workloads( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDiscoveredWorkloadsAsyncPager: r"""Lists Discovered Workloads that can be added to an Application in a host project and location. @@ -2105,8 +2165,10 @@ async def sample_list_discovered_workloads(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apphub_v1.services.app_hub.pagers.ListDiscoveredWorkloadsAsyncPager: @@ -2183,7 +2245,7 @@ async def get_discovered_workload( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workload.DiscoveredWorkload: r"""Gets a Discovered Workload in a host project and location. @@ -2228,8 +2290,10 @@ async def sample_get_discovered_workload(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apphub_v1.types.DiscoveredWorkload: @@ -2298,7 +2362,7 @@ async def lookup_discovered_workload( uri: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apphub_service.LookupDiscoveredWorkloadResponse: r"""Lists a Discovered Workload in a host project and location, with a given resource URI. @@ -2353,8 +2417,10 @@ async def sample_lookup_discovered_workload(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apphub_v1.types.LookupDiscoveredWorkloadResponse: @@ -2417,7 +2483,7 @@ async def list_workloads( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListWorkloadsAsyncPager: r"""Lists Workloads in an Application. @@ -2462,8 +2528,10 @@ async def sample_list_workloads(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apphub_v1.services.app_hub.pagers.ListWorkloadsAsyncPager: @@ -2540,7 +2608,7 @@ async def create_workload( workload_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 Workload in an Application. @@ -2608,8 +2676,10 @@ async def sample_create_workload(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + 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 +2757,7 @@ async def get_workload( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workload.Workload: r"""Gets a Workload in an Application. @@ -2731,8 +2801,10 @@ async def sample_get_workload(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apphub_v1.types.Workload: @@ -2799,7 +2871,7 @@ async def update_workload( 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 Workload in an Application. @@ -2862,8 +2934,10 @@ async def sample_update_workload(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -2941,7 +3015,7 @@ async def delete_workload( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 Workload from an Application. @@ -2989,8 +3063,10 @@ async def sample_delete_workload(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -3069,7 +3145,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 host project and location. @@ -3114,8 +3190,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.apphub_v1.services.app_hub.pagers.ListApplicationsAsyncPager: @@ -3192,7 +3270,7 @@ async def create_application( application_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 Application in a host project and location. @@ -3261,8 +3339,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: @@ -3339,7 +3419,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]]] = (), ) -> application.Application: r"""Gets an Application in a host project and location. @@ -3383,8 +3463,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.apphub_v1.types.Application: @@ -3450,7 +3532,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 an Application in a host project and location. @@ -3514,8 +3596,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: @@ -3592,7 +3676,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 an Application in a host project and location. @@ -3641,8 +3725,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: @@ -3720,7 +3806,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. @@ -3731,8 +3817,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. @@ -3773,7 +3861,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. @@ -3784,8 +3872,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. @@ -3826,7 +3916,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. @@ -3842,8 +3932,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 """ @@ -3880,7 +3972,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. @@ -3895,8 +3987,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 """ @@ -3933,7 +4027,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. @@ -3946,8 +4040,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. @@ -4052,7 +4148,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. @@ -4066,8 +4162,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. @@ -4172,7 +4270,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. @@ -4187,8 +4285,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. @@ -4232,7 +4332,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. @@ -4243,8 +4343,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. @@ -4285,7 +4387,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. @@ -4296,8 +4398,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-apphub/google/cloud/apphub_v1/services/app_hub/client.py b/packages/google-cloud-apphub/google/cloud/apphub_v1/services/app_hub/client.py index 9e1aef923d80..bf107f464860 100644 --- a/packages/google-cloud-apphub/google/cloud/apphub_v1/services/app_hub/client.py +++ b/packages/google-cloud-apphub/google/cloud/apphub_v1/services/app_hub/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 @@ -713,6 +723,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( @@ -775,6 +789,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.apphub_v1.AppHubClient`.", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "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.apphub.v1.AppHub", + "credentialsType": None, + }, + ) + def lookup_service_project_attachment( self, request: Optional[ @@ -784,7 +821,7 @@ def lookup_service_project_attachment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apphub_service.LookupServiceProjectAttachmentResponse: r"""Lists a service project attachment for a given service project. You can call this API from any project @@ -832,8 +869,10 @@ def sample_lookup_service_project_attachment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apphub_v1.types.LookupServiceProjectAttachmentResponse: @@ -897,7 +936,7 @@ def list_service_project_attachments( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListServiceProjectAttachmentsPager: r"""Lists service projects attached to the host project. @@ -944,8 +983,10 @@ def sample_list_service_project_attachments(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apphub_v1.services.app_hub.pagers.ListServiceProjectAttachmentsPager: @@ -1025,7 +1066,7 @@ def create_service_project_attachment( service_project_attachment_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"""Attaches a service project to the host project. @@ -1093,8 +1134,10 @@ def sample_create_service_project_attachment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -1179,7 +1222,7 @@ def get_service_project_attachment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service_project_attachment.ServiceProjectAttachment: r"""Gets a service project attachment. @@ -1224,8 +1267,10 @@ def sample_get_service_project_attachment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apphub_v1.types.ServiceProjectAttachment: @@ -1295,7 +1340,7 @@ def delete_service_project_attachment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a service project attachment. @@ -1344,8 +1389,10 @@ def sample_delete_service_project_attachment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -1427,7 +1474,7 @@ def detach_service_project_attachment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apphub_service.DetachServiceProjectAttachmentResponse: r"""Detaches a service project from a host project. You can call this API from any service project without @@ -1476,8 +1523,10 @@ def sample_detach_service_project_attachment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apphub_v1.types.DetachServiceProjectAttachmentResponse: @@ -1541,7 +1590,7 @@ def list_discovered_services( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDiscoveredServicesPager: r"""Lists Discovered Services that can be added to an Application in a host project and location. @@ -1587,8 +1636,10 @@ def sample_list_discovered_services(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apphub_v1.services.app_hub.pagers.ListDiscoveredServicesPager: @@ -1662,7 +1713,7 @@ def get_discovered_service( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.DiscoveredService: r"""Gets a Discovered Service in a host project and location. @@ -1707,8 +1758,10 @@ def sample_get_discovered_service(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apphub_v1.types.DiscoveredService: @@ -1772,7 +1825,7 @@ def lookup_discovered_service( uri: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apphub_service.LookupDiscoveredServiceResponse: r"""Lists a Discovered Service in a host project and location, with a given resource URI. @@ -1827,8 +1880,10 @@ def sample_lookup_discovered_service(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apphub_v1.types.LookupDiscoveredServiceResponse: @@ -1888,7 +1943,7 @@ def list_services( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListServicesPager: r"""Lists Services in an Application. @@ -1933,8 +1988,10 @@ def sample_list_services(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apphub_v1.services.app_hub.pagers.ListServicesPager: @@ -2008,7 +2065,7 @@ def create_service( service_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 Service in an Application. @@ -2076,8 +2133,10 @@ def sample_create_service(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -2151,7 +2210,7 @@ def get_service( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> service.Service: r"""Gets a Service in an Application. @@ -2195,8 +2254,10 @@ def sample_get_service(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apphub_v1.types.Service: @@ -2258,7 +2319,7 @@ def update_service( 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 Service in an Application. @@ -2321,8 +2382,10 @@ def sample_update_service(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -2396,7 +2459,7 @@ def delete_service( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a Service from an Application. @@ -2444,8 +2507,10 @@ def sample_delete_service(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -2523,7 +2588,7 @@ def list_discovered_workloads( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDiscoveredWorkloadsPager: r"""Lists Discovered Workloads that can be added to an Application in a host project and location. @@ -2569,8 +2634,10 @@ def sample_list_discovered_workloads(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apphub_v1.services.app_hub.pagers.ListDiscoveredWorkloadsPager: @@ -2646,7 +2713,7 @@ def get_discovered_workload( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workload.DiscoveredWorkload: r"""Gets a Discovered Workload in a host project and location. @@ -2691,8 +2758,10 @@ def sample_get_discovered_workload(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apphub_v1.types.DiscoveredWorkload: @@ -2758,7 +2827,7 @@ def lookup_discovered_workload( uri: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apphub_service.LookupDiscoveredWorkloadResponse: r"""Lists a Discovered Workload in a host project and location, with a given resource URI. @@ -2813,8 +2882,10 @@ def sample_lookup_discovered_workload(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apphub_v1.types.LookupDiscoveredWorkloadResponse: @@ -2876,7 +2947,7 @@ def list_workloads( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListWorkloadsPager: r"""Lists Workloads in an Application. @@ -2921,8 +2992,10 @@ def sample_list_workloads(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apphub_v1.services.app_hub.pagers.ListWorkloadsPager: @@ -2996,7 +3069,7 @@ def create_workload( workload_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 Workload in an Application. @@ -3064,8 +3137,10 @@ def sample_create_workload(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -3140,7 +3215,7 @@ def get_workload( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workload.Workload: r"""Gets a Workload in an Application. @@ -3184,8 +3259,10 @@ def sample_get_workload(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.apphub_v1.types.Workload: @@ -3249,7 +3326,7 @@ def update_workload( 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 Workload in an Application. @@ -3312,8 +3389,10 @@ def sample_update_workload(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -3388,7 +3467,7 @@ def delete_workload( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 Workload from an Application. @@ -3436,8 +3515,10 @@ def sample_delete_workload(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -3513,7 +3594,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 host project and location. @@ -3558,8 +3639,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.apphub_v1.services.app_hub.pagers.ListApplicationsPager: @@ -3633,7 +3716,7 @@ def create_application( application_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 Application in a host project and location. @@ -3702,8 +3785,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: @@ -3777,7 +3862,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]]] = (), ) -> application.Application: r"""Gets an Application in a host project and location. @@ -3821,8 +3906,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.apphub_v1.types.Application: @@ -3885,7 +3972,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 an Application in a host project and location. @@ -3949,8 +4036,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: @@ -4024,7 +4113,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 an Application in a host project and location. @@ -4073,8 +4162,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: @@ -4162,7 +4253,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. @@ -4173,8 +4264,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. @@ -4215,7 +4308,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. @@ -4226,8 +4319,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. @@ -4268,7 +4363,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. @@ -4284,8 +4379,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 """ @@ -4322,7 +4419,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. @@ -4337,8 +4434,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 """ @@ -4375,7 +4474,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. @@ -4388,8 +4487,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. @@ -4494,7 +4595,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. @@ -4508,8 +4609,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. @@ -4614,7 +4717,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. @@ -4629,8 +4732,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. @@ -4672,7 +4777,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. @@ -4683,8 +4788,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. @@ -4725,7 +4832,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. @@ -4736,8 +4843,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-apphub/google/cloud/apphub_v1/services/app_hub/pagers.py b/packages/google-cloud-apphub/google/cloud/apphub_v1/services/app_hub/pagers.py index 43fd04c6ff49..80bd7cba4c67 100644 --- a/packages/google-cloud-apphub/google/cloud/apphub_v1/services/app_hub/pagers.py +++ b/packages/google-cloud-apphub/google/cloud/apphub_v1/services/app_hub/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 = apphub_service.ListServiceProjectAttachmentsRequest(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 = apphub_service.ListServiceProjectAttachmentsRequest(request) @@ -231,7 +235,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -245,8 +249,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = apphub_service.ListDiscoveredServicesRequest(request) @@ -305,7 +311,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -319,8 +325,10 @@ def __init__( retry (google.api_core.retry.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = apphub_service.ListDiscoveredServicesRequest(request) @@ -385,7 +393,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -399,8 +407,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = apphub_service.ListServicesRequest(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 = apphub_service.ListServicesRequest(request) @@ -537,7 +549,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -551,8 +563,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = apphub_service.ListDiscoveredWorkloadsRequest(request) @@ -613,7 +627,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. @@ -627,8 +641,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 = apphub_service.ListDiscoveredWorkloadsRequest(request) @@ -693,7 +709,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -707,8 +723,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = apphub_service.ListWorkloadsRequest(request) @@ -767,7 +785,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. @@ -781,8 +799,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 = apphub_service.ListWorkloadsRequest(request) @@ -845,7 +865,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -859,8 +879,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = apphub_service.ListApplicationsRequest(request) @@ -919,7 +941,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. @@ -933,8 +955,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 = apphub_service.ListApplicationsRequest(request) diff --git a/packages/google-cloud-apphub/google/cloud/apphub_v1/services/app_hub/transports/grpc.py b/packages/google-cloud-apphub/google/cloud/apphub_v1/services/app_hub/transports/grpc.py index afaff2d67194..d12b189a7d87 100644 --- a/packages/google-cloud-apphub/google/cloud/apphub_v1/services/app_hub/transports/grpc.py +++ b/packages/google-cloud-apphub/google/cloud/apphub_v1/services/app_hub/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.apphub_v1.types import ( apphub_service, @@ -36,6 +42,81 @@ from .base import DEFAULT_CLIENT_INFO, AppHubTransport +try: + from google.api_core import client_logging # 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.apphub.v1.AppHub", + "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.apphub.v1.AppHub", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AppHubGrpcTransport(AppHubTransport): """gRPC backend transport for AppHub. @@ -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 @@ -286,7 +374,7 @@ def lookup_service_project_attachment( if "lookup_service_project_attachment" not in self._stubs: self._stubs[ "lookup_service_project_attachment" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/LookupServiceProjectAttachment", request_serializer=apphub_service.LookupServiceProjectAttachmentRequest.serialize, response_deserializer=apphub_service.LookupServiceProjectAttachmentResponse.deserialize, @@ -318,7 +406,7 @@ def list_service_project_attachments( if "list_service_project_attachments" not in self._stubs: self._stubs[ "list_service_project_attachments" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/ListServiceProjectAttachments", request_serializer=apphub_service.ListServiceProjectAttachmentsRequest.serialize, response_deserializer=apphub_service.ListServiceProjectAttachmentsResponse.deserialize, @@ -349,7 +437,7 @@ def create_service_project_attachment( if "create_service_project_attachment" not in self._stubs: self._stubs[ "create_service_project_attachment" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/CreateServiceProjectAttachment", request_serializer=apphub_service.CreateServiceProjectAttachmentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -380,7 +468,7 @@ def get_service_project_attachment( if "get_service_project_attachment" not in self._stubs: self._stubs[ "get_service_project_attachment" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/GetServiceProjectAttachment", request_serializer=apphub_service.GetServiceProjectAttachmentRequest.serialize, response_deserializer=service_project_attachment.ServiceProjectAttachment.deserialize, @@ -411,7 +499,7 @@ def delete_service_project_attachment( if "delete_service_project_attachment" not in self._stubs: self._stubs[ "delete_service_project_attachment" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/DeleteServiceProjectAttachment", request_serializer=apphub_service.DeleteServiceProjectAttachmentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -446,7 +534,7 @@ def detach_service_project_attachment( if "detach_service_project_attachment" not in self._stubs: self._stubs[ "detach_service_project_attachment" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/DetachServiceProjectAttachment", request_serializer=apphub_service.DetachServiceProjectAttachmentRequest.serialize, response_deserializer=apphub_service.DetachServiceProjectAttachmentResponse.deserialize, @@ -476,7 +564,7 @@ def list_discovered_services( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_discovered_services" not in self._stubs: - self._stubs["list_discovered_services"] = self.grpc_channel.unary_unary( + self._stubs["list_discovered_services"] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/ListDiscoveredServices", request_serializer=apphub_service.ListDiscoveredServicesRequest.serialize, response_deserializer=apphub_service.ListDiscoveredServicesResponse.deserialize, @@ -505,7 +593,7 @@ def get_discovered_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_discovered_service" not in self._stubs: - self._stubs["get_discovered_service"] = self.grpc_channel.unary_unary( + self._stubs["get_discovered_service"] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/GetDiscoveredService", request_serializer=apphub_service.GetDiscoveredServiceRequest.serialize, response_deserializer=service.DiscoveredService.deserialize, @@ -535,7 +623,7 @@ def lookup_discovered_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "lookup_discovered_service" not in self._stubs: - self._stubs["lookup_discovered_service"] = self.grpc_channel.unary_unary( + self._stubs["lookup_discovered_service"] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/LookupDiscoveredService", request_serializer=apphub_service.LookupDiscoveredServiceRequest.serialize, response_deserializer=apphub_service.LookupDiscoveredServiceResponse.deserialize, @@ -563,7 +651,7 @@ def list_services( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_services" not in self._stubs: - self._stubs["list_services"] = self.grpc_channel.unary_unary( + self._stubs["list_services"] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/ListServices", request_serializer=apphub_service.ListServicesRequest.serialize, response_deserializer=apphub_service.ListServicesResponse.deserialize, @@ -589,7 +677,7 @@ def create_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_service" not in self._stubs: - self._stubs["create_service"] = self.grpc_channel.unary_unary( + self._stubs["create_service"] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/CreateService", request_serializer=apphub_service.CreateServiceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -615,7 +703,7 @@ def get_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_service" not in self._stubs: - self._stubs["get_service"] = self.grpc_channel.unary_unary( + self._stubs["get_service"] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/GetService", request_serializer=apphub_service.GetServiceRequest.serialize, response_deserializer=service.Service.deserialize, @@ -641,7 +729,7 @@ def update_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_service" not in self._stubs: - self._stubs["update_service"] = self.grpc_channel.unary_unary( + self._stubs["update_service"] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/UpdateService", request_serializer=apphub_service.UpdateServiceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -667,7 +755,7 @@ def delete_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_service" not in self._stubs: - self._stubs["delete_service"] = self.grpc_channel.unary_unary( + self._stubs["delete_service"] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/DeleteService", request_serializer=apphub_service.DeleteServiceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -697,7 +785,7 @@ def list_discovered_workloads( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_discovered_workloads" not in self._stubs: - self._stubs["list_discovered_workloads"] = self.grpc_channel.unary_unary( + self._stubs["list_discovered_workloads"] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/ListDiscoveredWorkloads", request_serializer=apphub_service.ListDiscoveredWorkloadsRequest.serialize, response_deserializer=apphub_service.ListDiscoveredWorkloadsResponse.deserialize, @@ -726,7 +814,7 @@ def get_discovered_workload( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_discovered_workload" not in self._stubs: - self._stubs["get_discovered_workload"] = self.grpc_channel.unary_unary( + self._stubs["get_discovered_workload"] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/GetDiscoveredWorkload", request_serializer=apphub_service.GetDiscoveredWorkloadRequest.serialize, response_deserializer=workload.DiscoveredWorkload.deserialize, @@ -756,7 +844,9 @@ def lookup_discovered_workload( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "lookup_discovered_workload" not in self._stubs: - self._stubs["lookup_discovered_workload"] = self.grpc_channel.unary_unary( + self._stubs[ + "lookup_discovered_workload" + ] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/LookupDiscoveredWorkload", request_serializer=apphub_service.LookupDiscoveredWorkloadRequest.serialize, response_deserializer=apphub_service.LookupDiscoveredWorkloadResponse.deserialize, @@ -784,7 +874,7 @@ def list_workloads( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workloads" not in self._stubs: - self._stubs["list_workloads"] = self.grpc_channel.unary_unary( + self._stubs["list_workloads"] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/ListWorkloads", request_serializer=apphub_service.ListWorkloadsRequest.serialize, response_deserializer=apphub_service.ListWorkloadsResponse.deserialize, @@ -810,7 +900,7 @@ def create_workload( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workload" not in self._stubs: - self._stubs["create_workload"] = self.grpc_channel.unary_unary( + self._stubs["create_workload"] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/CreateWorkload", request_serializer=apphub_service.CreateWorkloadRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -836,7 +926,7 @@ def get_workload( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workload" not in self._stubs: - self._stubs["get_workload"] = self.grpc_channel.unary_unary( + self._stubs["get_workload"] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/GetWorkload", request_serializer=apphub_service.GetWorkloadRequest.serialize, response_deserializer=workload.Workload.deserialize, @@ -862,7 +952,7 @@ def update_workload( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workload" not in self._stubs: - self._stubs["update_workload"] = self.grpc_channel.unary_unary( + self._stubs["update_workload"] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/UpdateWorkload", request_serializer=apphub_service.UpdateWorkloadRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -888,7 +978,7 @@ def delete_workload( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workload" not in self._stubs: - self._stubs["delete_workload"] = self.grpc_channel.unary_unary( + self._stubs["delete_workload"] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/DeleteWorkload", request_serializer=apphub_service.DeleteWorkloadRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -917,7 +1007,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.apphub.v1.AppHub/ListApplications", request_serializer=apphub_service.ListApplicationsRequest.serialize, response_deserializer=apphub_service.ListApplicationsResponse.deserialize, @@ -944,7 +1034,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.apphub.v1.AppHub/CreateApplication", request_serializer=apphub_service.CreateApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -970,7 +1060,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.apphub.v1.AppHub/GetApplication", request_serializer=apphub_service.GetApplicationRequest.serialize, response_deserializer=application.Application.deserialize, @@ -997,7 +1087,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.apphub.v1.AppHub/UpdateApplication", request_serializer=apphub_service.UpdateApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1024,7 +1114,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.apphub.v1.AppHub/DeleteApplication", request_serializer=apphub_service.DeleteApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1032,7 +1122,7 @@ def delete_application( return self._stubs["delete_application"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -1044,7 +1134,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, @@ -1061,7 +1151,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, @@ -1078,7 +1168,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, @@ -1097,7 +1187,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, @@ -1116,7 +1206,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, @@ -1133,7 +1223,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, @@ -1158,7 +1248,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, @@ -1184,7 +1274,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, @@ -1213,7 +1303,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-apphub/google/cloud/apphub_v1/services/app_hub/transports/grpc_asyncio.py b/packages/google-cloud-apphub/google/cloud/apphub_v1/services/app_hub/transports/grpc_asyncio.py index 16c039a26d49..a79dc1c07ab1 100644 --- a/packages/google-cloud-apphub/google/cloud/apphub_v1/services/app_hub/transports/grpc_asyncio.py +++ b/packages/google-cloud-apphub/google/cloud/apphub_v1/services/app_hub/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.apphub_v1.types import ( apphub_service, @@ -40,6 +46,82 @@ from .base import DEFAULT_CLIENT_INFO, AppHubTransport from .grpc import AppHubGrpcTransport +try: + from google.api_core import client_logging # 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.apphub.v1.AppHub", + "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.apphub.v1.AppHub", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AppHubGrpcAsyncIOTransport(AppHubTransport): """gRPC AsyncIO backend transport for AppHub. @@ -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. @@ -296,7 +381,7 @@ def lookup_service_project_attachment( if "lookup_service_project_attachment" not in self._stubs: self._stubs[ "lookup_service_project_attachment" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/LookupServiceProjectAttachment", request_serializer=apphub_service.LookupServiceProjectAttachmentRequest.serialize, response_deserializer=apphub_service.LookupServiceProjectAttachmentResponse.deserialize, @@ -328,7 +413,7 @@ def list_service_project_attachments( if "list_service_project_attachments" not in self._stubs: self._stubs[ "list_service_project_attachments" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/ListServiceProjectAttachments", request_serializer=apphub_service.ListServiceProjectAttachmentsRequest.serialize, response_deserializer=apphub_service.ListServiceProjectAttachmentsResponse.deserialize, @@ -360,7 +445,7 @@ def create_service_project_attachment( if "create_service_project_attachment" not in self._stubs: self._stubs[ "create_service_project_attachment" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/CreateServiceProjectAttachment", request_serializer=apphub_service.CreateServiceProjectAttachmentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -391,7 +476,7 @@ def get_service_project_attachment( if "get_service_project_attachment" not in self._stubs: self._stubs[ "get_service_project_attachment" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/GetServiceProjectAttachment", request_serializer=apphub_service.GetServiceProjectAttachmentRequest.serialize, response_deserializer=service_project_attachment.ServiceProjectAttachment.deserialize, @@ -423,7 +508,7 @@ def delete_service_project_attachment( if "delete_service_project_attachment" not in self._stubs: self._stubs[ "delete_service_project_attachment" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/DeleteServiceProjectAttachment", request_serializer=apphub_service.DeleteServiceProjectAttachmentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -458,7 +543,7 @@ def detach_service_project_attachment( if "detach_service_project_attachment" not in self._stubs: self._stubs[ "detach_service_project_attachment" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/DetachServiceProjectAttachment", request_serializer=apphub_service.DetachServiceProjectAttachmentRequest.serialize, response_deserializer=apphub_service.DetachServiceProjectAttachmentResponse.deserialize, @@ -488,7 +573,7 @@ def list_discovered_services( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_discovered_services" not in self._stubs: - self._stubs["list_discovered_services"] = self.grpc_channel.unary_unary( + self._stubs["list_discovered_services"] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/ListDiscoveredServices", request_serializer=apphub_service.ListDiscoveredServicesRequest.serialize, response_deserializer=apphub_service.ListDiscoveredServicesResponse.deserialize, @@ -518,7 +603,7 @@ def get_discovered_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_discovered_service" not in self._stubs: - self._stubs["get_discovered_service"] = self.grpc_channel.unary_unary( + self._stubs["get_discovered_service"] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/GetDiscoveredService", request_serializer=apphub_service.GetDiscoveredServiceRequest.serialize, response_deserializer=service.DiscoveredService.deserialize, @@ -548,7 +633,7 @@ def lookup_discovered_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "lookup_discovered_service" not in self._stubs: - self._stubs["lookup_discovered_service"] = self.grpc_channel.unary_unary( + self._stubs["lookup_discovered_service"] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/LookupDiscoveredService", request_serializer=apphub_service.LookupDiscoveredServiceRequest.serialize, response_deserializer=apphub_service.LookupDiscoveredServiceResponse.deserialize, @@ -577,7 +662,7 @@ def list_services( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_services" not in self._stubs: - self._stubs["list_services"] = self.grpc_channel.unary_unary( + self._stubs["list_services"] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/ListServices", request_serializer=apphub_service.ListServicesRequest.serialize, response_deserializer=apphub_service.ListServicesResponse.deserialize, @@ -605,7 +690,7 @@ def create_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_service" not in self._stubs: - self._stubs["create_service"] = self.grpc_channel.unary_unary( + self._stubs["create_service"] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/CreateService", request_serializer=apphub_service.CreateServiceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -631,7 +716,7 @@ def get_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_service" not in self._stubs: - self._stubs["get_service"] = self.grpc_channel.unary_unary( + self._stubs["get_service"] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/GetService", request_serializer=apphub_service.GetServiceRequest.serialize, response_deserializer=service.Service.deserialize, @@ -659,7 +744,7 @@ def update_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_service" not in self._stubs: - self._stubs["update_service"] = self.grpc_channel.unary_unary( + self._stubs["update_service"] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/UpdateService", request_serializer=apphub_service.UpdateServiceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -687,7 +772,7 @@ def delete_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_service" not in self._stubs: - self._stubs["delete_service"] = self.grpc_channel.unary_unary( + self._stubs["delete_service"] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/DeleteService", request_serializer=apphub_service.DeleteServiceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -717,7 +802,7 @@ def list_discovered_workloads( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_discovered_workloads" not in self._stubs: - self._stubs["list_discovered_workloads"] = self.grpc_channel.unary_unary( + self._stubs["list_discovered_workloads"] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/ListDiscoveredWorkloads", request_serializer=apphub_service.ListDiscoveredWorkloadsRequest.serialize, response_deserializer=apphub_service.ListDiscoveredWorkloadsResponse.deserialize, @@ -747,7 +832,7 @@ def get_discovered_workload( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_discovered_workload" not in self._stubs: - self._stubs["get_discovered_workload"] = self.grpc_channel.unary_unary( + self._stubs["get_discovered_workload"] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/GetDiscoveredWorkload", request_serializer=apphub_service.GetDiscoveredWorkloadRequest.serialize, response_deserializer=workload.DiscoveredWorkload.deserialize, @@ -777,7 +862,9 @@ def lookup_discovered_workload( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "lookup_discovered_workload" not in self._stubs: - self._stubs["lookup_discovered_workload"] = self.grpc_channel.unary_unary( + self._stubs[ + "lookup_discovered_workload" + ] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/LookupDiscoveredWorkload", request_serializer=apphub_service.LookupDiscoveredWorkloadRequest.serialize, response_deserializer=apphub_service.LookupDiscoveredWorkloadResponse.deserialize, @@ -806,7 +893,7 @@ def list_workloads( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workloads" not in self._stubs: - self._stubs["list_workloads"] = self.grpc_channel.unary_unary( + self._stubs["list_workloads"] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/ListWorkloads", request_serializer=apphub_service.ListWorkloadsRequest.serialize, response_deserializer=apphub_service.ListWorkloadsResponse.deserialize, @@ -834,7 +921,7 @@ def create_workload( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workload" not in self._stubs: - self._stubs["create_workload"] = self.grpc_channel.unary_unary( + self._stubs["create_workload"] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/CreateWorkload", request_serializer=apphub_service.CreateWorkloadRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -860,7 +947,7 @@ def get_workload( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workload" not in self._stubs: - self._stubs["get_workload"] = self.grpc_channel.unary_unary( + self._stubs["get_workload"] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/GetWorkload", request_serializer=apphub_service.GetWorkloadRequest.serialize, response_deserializer=workload.Workload.deserialize, @@ -888,7 +975,7 @@ def update_workload( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workload" not in self._stubs: - self._stubs["update_workload"] = self.grpc_channel.unary_unary( + self._stubs["update_workload"] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/UpdateWorkload", request_serializer=apphub_service.UpdateWorkloadRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -916,7 +1003,7 @@ def delete_workload( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workload" not in self._stubs: - self._stubs["delete_workload"] = self.grpc_channel.unary_unary( + self._stubs["delete_workload"] = self._logged_channel.unary_unary( "/google.cloud.apphub.v1.AppHub/DeleteWorkload", request_serializer=apphub_service.DeleteWorkloadRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -945,7 +1032,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.apphub.v1.AppHub/ListApplications", request_serializer=apphub_service.ListApplicationsRequest.serialize, response_deserializer=apphub_service.ListApplicationsResponse.deserialize, @@ -974,7 +1061,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.apphub.v1.AppHub/CreateApplication", request_serializer=apphub_service.CreateApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1002,7 +1089,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.apphub.v1.AppHub/GetApplication", request_serializer=apphub_service.GetApplicationRequest.serialize, response_deserializer=application.Application.deserialize, @@ -1031,7 +1118,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.apphub.v1.AppHub/UpdateApplication", request_serializer=apphub_service.UpdateApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1060,7 +1147,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.apphub.v1.AppHub/DeleteApplication", request_serializer=apphub_service.DeleteApplicationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1393,7 +1480,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: @@ -1409,7 +1496,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, @@ -1426,7 +1513,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, @@ -1443,7 +1530,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, @@ -1462,7 +1549,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, @@ -1481,7 +1568,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, @@ -1498,7 +1585,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, @@ -1523,7 +1610,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, @@ -1549,7 +1636,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, @@ -1578,7 +1665,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-apphub/google/cloud/apphub_v1/services/app_hub/transports/rest.py b/packages/google-cloud-apphub/google/cloud/apphub_v1/services/app_hub/transports/rest.py index 2a9a3d2c2d5a..1edd42cae957 100644 --- a/packages/google-cloud-apphub/google/cloud/apphub_v1/services/app_hub/transports/rest.py +++ b/packages/google-cloud-apphub/google/cloud/apphub_v1/services/app_hub/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, @@ -295,8 +303,10 @@ def post_update_workload(self, response): def pre_create_application( self, request: apphub_service.CreateApplicationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apphub_service.CreateApplicationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apphub_service.CreateApplicationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_application Override in a subclass to manipulate the request or metadata @@ -318,8 +328,10 @@ def post_create_application( def pre_create_service( self, request: apphub_service.CreateServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apphub_service.CreateServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apphub_service.CreateServiceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_service Override in a subclass to manipulate the request or metadata @@ -341,9 +353,10 @@ def post_create_service( def pre_create_service_project_attachment( self, request: apphub_service.CreateServiceProjectAttachmentRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - apphub_service.CreateServiceProjectAttachmentRequest, Sequence[Tuple[str, str]] + apphub_service.CreateServiceProjectAttachmentRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_service_project_attachment @@ -366,8 +379,10 @@ def post_create_service_project_attachment( def pre_create_workload( self, request: apphub_service.CreateWorkloadRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apphub_service.CreateWorkloadRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apphub_service.CreateWorkloadRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_workload Override in a subclass to manipulate the request or metadata @@ -389,8 +404,10 @@ def post_create_workload( def pre_delete_application( self, request: apphub_service.DeleteApplicationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apphub_service.DeleteApplicationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apphub_service.DeleteApplicationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_application Override in a subclass to manipulate the request or metadata @@ -412,8 +429,10 @@ def post_delete_application( def pre_delete_service( self, request: apphub_service.DeleteServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apphub_service.DeleteServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apphub_service.DeleteServiceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_service Override in a subclass to manipulate the request or metadata @@ -435,9 +454,10 @@ def post_delete_service( def pre_delete_service_project_attachment( self, request: apphub_service.DeleteServiceProjectAttachmentRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - apphub_service.DeleteServiceProjectAttachmentRequest, Sequence[Tuple[str, str]] + apphub_service.DeleteServiceProjectAttachmentRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_service_project_attachment @@ -460,8 +480,10 @@ def post_delete_service_project_attachment( def pre_delete_workload( self, request: apphub_service.DeleteWorkloadRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apphub_service.DeleteWorkloadRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apphub_service.DeleteWorkloadRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_workload Override in a subclass to manipulate the request or metadata @@ -483,9 +505,10 @@ def post_delete_workload( def pre_detach_service_project_attachment( self, request: apphub_service.DetachServiceProjectAttachmentRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - apphub_service.DetachServiceProjectAttachmentRequest, Sequence[Tuple[str, str]] + apphub_service.DetachServiceProjectAttachmentRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for detach_service_project_attachment @@ -508,8 +531,10 @@ def post_detach_service_project_attachment( def pre_get_application( self, request: apphub_service.GetApplicationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apphub_service.GetApplicationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apphub_service.GetApplicationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_application Override in a subclass to manipulate the request or metadata @@ -531,8 +556,11 @@ def post_get_application( def pre_get_discovered_service( self, request: apphub_service.GetDiscoveredServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apphub_service.GetDiscoveredServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apphub_service.GetDiscoveredServiceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_discovered_service Override in a subclass to manipulate the request or metadata @@ -554,8 +582,11 @@ def post_get_discovered_service( def pre_get_discovered_workload( self, request: apphub_service.GetDiscoveredWorkloadRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apphub_service.GetDiscoveredWorkloadRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apphub_service.GetDiscoveredWorkloadRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_discovered_workload Override in a subclass to manipulate the request or metadata @@ -577,8 +608,10 @@ def post_get_discovered_workload( def pre_get_service( self, request: apphub_service.GetServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apphub_service.GetServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apphub_service.GetServiceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_service Override in a subclass to manipulate the request or metadata @@ -598,9 +631,10 @@ def post_get_service(self, response: service.Service) -> service.Service: def pre_get_service_project_attachment( self, request: apphub_service.GetServiceProjectAttachmentRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - apphub_service.GetServiceProjectAttachmentRequest, Sequence[Tuple[str, str]] + apphub_service.GetServiceProjectAttachmentRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_service_project_attachment @@ -623,8 +657,10 @@ def post_get_service_project_attachment( def pre_get_workload( self, request: apphub_service.GetWorkloadRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apphub_service.GetWorkloadRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apphub_service.GetWorkloadRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_workload Override in a subclass to manipulate the request or metadata @@ -644,8 +680,10 @@ def post_get_workload(self, response: workload.Workload) -> workload.Workload: def pre_list_applications( self, request: apphub_service.ListApplicationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apphub_service.ListApplicationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apphub_service.ListApplicationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_applications Override in a subclass to manipulate the request or metadata @@ -667,8 +705,11 @@ def post_list_applications( def pre_list_discovered_services( self, request: apphub_service.ListDiscoveredServicesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apphub_service.ListDiscoveredServicesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apphub_service.ListDiscoveredServicesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_discovered_services Override in a subclass to manipulate the request or metadata @@ -690,9 +731,10 @@ def post_list_discovered_services( def pre_list_discovered_workloads( self, request: apphub_service.ListDiscoveredWorkloadsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - apphub_service.ListDiscoveredWorkloadsRequest, Sequence[Tuple[str, str]] + apphub_service.ListDiscoveredWorkloadsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_discovered_workloads @@ -715,9 +757,10 @@ def post_list_discovered_workloads( def pre_list_service_project_attachments( self, request: apphub_service.ListServiceProjectAttachmentsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - apphub_service.ListServiceProjectAttachmentsRequest, Sequence[Tuple[str, str]] + apphub_service.ListServiceProjectAttachmentsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_service_project_attachments @@ -740,8 +783,10 @@ def post_list_service_project_attachments( def pre_list_services( self, request: apphub_service.ListServicesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apphub_service.ListServicesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apphub_service.ListServicesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_services Override in a subclass to manipulate the request or metadata @@ -763,8 +808,10 @@ def post_list_services( def pre_list_workloads( self, request: apphub_service.ListWorkloadsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apphub_service.ListWorkloadsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apphub_service.ListWorkloadsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_workloads Override in a subclass to manipulate the request or metadata @@ -786,9 +833,10 @@ def post_list_workloads( def pre_lookup_discovered_service( self, request: apphub_service.LookupDiscoveredServiceRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - apphub_service.LookupDiscoveredServiceRequest, Sequence[Tuple[str, str]] + apphub_service.LookupDiscoveredServiceRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for lookup_discovered_service @@ -811,9 +859,10 @@ def post_lookup_discovered_service( def pre_lookup_discovered_workload( self, request: apphub_service.LookupDiscoveredWorkloadRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - apphub_service.LookupDiscoveredWorkloadRequest, Sequence[Tuple[str, str]] + apphub_service.LookupDiscoveredWorkloadRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for lookup_discovered_workload @@ -836,9 +885,10 @@ def post_lookup_discovered_workload( def pre_lookup_service_project_attachment( self, request: apphub_service.LookupServiceProjectAttachmentRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - apphub_service.LookupServiceProjectAttachmentRequest, Sequence[Tuple[str, str]] + apphub_service.LookupServiceProjectAttachmentRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for lookup_service_project_attachment @@ -861,8 +911,10 @@ def post_lookup_service_project_attachment( def pre_update_application( self, request: apphub_service.UpdateApplicationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apphub_service.UpdateApplicationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apphub_service.UpdateApplicationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_application Override in a subclass to manipulate the request or metadata @@ -884,8 +936,10 @@ def post_update_application( def pre_update_service( self, request: apphub_service.UpdateServiceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apphub_service.UpdateServiceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apphub_service.UpdateServiceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_service Override in a subclass to manipulate the request or metadata @@ -907,8 +961,10 @@ def post_update_service( def pre_update_workload( self, request: apphub_service.UpdateWorkloadRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apphub_service.UpdateWorkloadRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apphub_service.UpdateWorkloadRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_workload Override in a subclass to manipulate the request or metadata @@ -930,8 +986,10 @@ def post_update_workload( 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 @@ -953,8 +1011,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 @@ -976,8 +1036,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 @@ -997,8 +1059,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 @@ -1018,8 +1082,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 @@ -1041,8 +1108,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 @@ -1062,8 +1131,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 @@ -1083,8 +1154,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 @@ -1106,8 +1179,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 @@ -1302,7 +1377,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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. @@ -1312,8 +1387,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1326,6 +1403,7 @@ def __call__( http_options = ( _BaseAppHubRestTransport._BaseCreateApplication._get_http_options() ) + request, metadata = self._interceptor.pre_create_application( request, metadata ) @@ -1348,6 +1426,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apphub_v1.AppHubClient.CreateApplication", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "CreateApplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppHubRestTransport._CreateApplication._get_response( self._host, @@ -1367,7 +1472,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.apphub_v1.AppHubClient.create_application", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "CreateApplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateService(_BaseAppHubRestTransport._BaseCreateService, AppHubRestStub): @@ -1403,7 +1530,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create service method over HTTP. @@ -1413,8 +1540,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1427,6 +1556,7 @@ def __call__( http_options = ( _BaseAppHubRestTransport._BaseCreateService._get_http_options() ) + request, metadata = self._interceptor.pre_create_service(request, metadata) transcoded_request = ( _BaseAppHubRestTransport._BaseCreateService._get_transcoded_request( @@ -1445,6 +1575,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apphub_v1.AppHubClient.CreateService", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "CreateService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppHubRestTransport._CreateService._get_response( self._host, @@ -1464,7 +1621,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_service(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apphub_v1.AppHubClient.create_service", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "CreateService", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateServiceProjectAttachment( @@ -1502,7 +1681,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create service project attachment method over HTTP. @@ -1514,8 +1693,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1528,6 +1709,7 @@ def __call__( http_options = ( _BaseAppHubRestTransport._BaseCreateServiceProjectAttachment._get_http_options() ) + request, metadata = self._interceptor.pre_create_service_project_attachment( request, metadata ) @@ -1544,6 +1726,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apphub_v1.AppHubClient.CreateServiceProjectAttachment", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "CreateServiceProjectAttachment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppHubRestTransport._CreateServiceProjectAttachment._get_response( @@ -1565,7 +1774,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_service_project_attachment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apphub_v1.AppHubClient.create_service_project_attachment", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "CreateServiceProjectAttachment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateWorkload(_BaseAppHubRestTransport._BaseCreateWorkload, AppHubRestStub): @@ -1601,7 +1832,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 workload method over HTTP. @@ -1611,8 +1842,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1625,6 +1858,7 @@ def __call__( http_options = ( _BaseAppHubRestTransport._BaseCreateWorkload._get_http_options() ) + request, metadata = self._interceptor.pre_create_workload(request, metadata) transcoded_request = ( _BaseAppHubRestTransport._BaseCreateWorkload._get_transcoded_request( @@ -1643,6 +1877,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apphub_v1.AppHubClient.CreateWorkload", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "CreateWorkload", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppHubRestTransport._CreateWorkload._get_response( self._host, @@ -1662,7 +1923,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_workload(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apphub_v1.AppHubClient.create_workload", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "CreateWorkload", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteApplication( @@ -1699,7 +1982,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete application method over HTTP. @@ -1709,8 +1992,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1723,6 +2008,7 @@ def __call__( http_options = ( _BaseAppHubRestTransport._BaseDeleteApplication._get_http_options() ) + request, metadata = self._interceptor.pre_delete_application( request, metadata ) @@ -1739,6 +2025,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apphub_v1.AppHubClient.DeleteApplication", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "DeleteApplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppHubRestTransport._DeleteApplication._get_response( self._host, @@ -1757,7 +2070,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.apphub_v1.AppHubClient.delete_application", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "DeleteApplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteService(_BaseAppHubRestTransport._BaseDeleteService, AppHubRestStub): @@ -1792,7 +2127,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete service method over HTTP. @@ -1802,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: ~.operations_pb2.Operation: @@ -1816,6 +2153,7 @@ def __call__( http_options = ( _BaseAppHubRestTransport._BaseDeleteService._get_http_options() ) + request, metadata = self._interceptor.pre_delete_service(request, metadata) transcoded_request = ( _BaseAppHubRestTransport._BaseDeleteService._get_transcoded_request( @@ -1830,6 +2168,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apphub_v1.AppHubClient.DeleteService", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "DeleteService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppHubRestTransport._DeleteService._get_response( self._host, @@ -1848,7 +2213,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_service(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apphub_v1.AppHubClient.delete_service", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "DeleteService", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteServiceProjectAttachment( @@ -1885,7 +2272,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete service project attachment method over HTTP. @@ -1897,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: ~.operations_pb2.Operation: @@ -1911,6 +2300,7 @@ def __call__( http_options = ( _BaseAppHubRestTransport._BaseDeleteServiceProjectAttachment._get_http_options() ) + request, metadata = self._interceptor.pre_delete_service_project_attachment( request, metadata ) @@ -1923,6 +2313,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apphub_v1.AppHubClient.DeleteServiceProjectAttachment", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "DeleteServiceProjectAttachment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppHubRestTransport._DeleteServiceProjectAttachment._get_response( @@ -1943,7 +2360,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_service_project_attachment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apphub_v1.AppHubClient.delete_service_project_attachment", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "DeleteServiceProjectAttachment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteWorkload(_BaseAppHubRestTransport._BaseDeleteWorkload, AppHubRestStub): @@ -1978,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete workload method over HTTP. @@ -1988,8 +2427,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2002,6 +2443,7 @@ def __call__( http_options = ( _BaseAppHubRestTransport._BaseDeleteWorkload._get_http_options() ) + request, metadata = self._interceptor.pre_delete_workload(request, metadata) transcoded_request = ( _BaseAppHubRestTransport._BaseDeleteWorkload._get_transcoded_request( @@ -2016,6 +2458,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apphub_v1.AppHubClient.DeleteWorkload", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "DeleteWorkload", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppHubRestTransport._DeleteWorkload._get_response( self._host, @@ -2034,7 +2503,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_workload(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apphub_v1.AppHubClient.delete_workload", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "DeleteWorkload", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DetachServiceProjectAttachment( @@ -2072,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]]] = (), ) -> apphub_service.DetachServiceProjectAttachmentResponse: r"""Call the detach service project attachment method over HTTP. @@ -2084,8 +2575,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.apphub_service.DetachServiceProjectAttachmentResponse: @@ -2097,6 +2590,7 @@ def __call__( http_options = ( _BaseAppHubRestTransport._BaseDetachServiceProjectAttachment._get_http_options() ) + request, metadata = self._interceptor.pre_detach_service_project_attachment( request, metadata ) @@ -2113,6 +2607,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apphub_v1.AppHubClient.DetachServiceProjectAttachment", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "DetachServiceProjectAttachment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppHubRestTransport._DetachServiceProjectAttachment._get_response( @@ -2136,7 +2657,33 @@ def __call__( pb_resp = apphub_service.DetachServiceProjectAttachmentResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_detach_service_project_attachment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + apphub_service.DetachServiceProjectAttachmentResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apphub_v1.AppHubClient.detach_service_project_attachment", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "DetachServiceProjectAttachment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetApplication(_BaseAppHubRestTransport._BaseGetApplication, AppHubRestStub): @@ -2171,7 +2718,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> application.Application: r"""Call the get application method over HTTP. @@ -2181,8 +2728,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.application.Application: @@ -2198,6 +2747,7 @@ def __call__( http_options = ( _BaseAppHubRestTransport._BaseGetApplication._get_http_options() ) + request, metadata = self._interceptor.pre_get_application(request, metadata) transcoded_request = ( _BaseAppHubRestTransport._BaseGetApplication._get_transcoded_request( @@ -2212,6 +2762,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apphub_v1.AppHubClient.GetApplication", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "GetApplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppHubRestTransport._GetApplication._get_response( self._host, @@ -2232,7 +2809,29 @@ def __call__( pb_resp = application.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 = application.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.apphub_v1.AppHubClient.get_application", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "GetApplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDiscoveredService( @@ -2269,7 +2868,7 @@ 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.DiscoveredService: r"""Call the get discovered service method over HTTP. @@ -2279,8 +2878,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.DiscoveredService: @@ -2295,6 +2896,7 @@ def __call__( http_options = ( _BaseAppHubRestTransport._BaseGetDiscoveredService._get_http_options() ) + request, metadata = self._interceptor.pre_get_discovered_service( request, metadata ) @@ -2307,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 = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apphub_v1.AppHubClient.GetDiscoveredService", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "GetDiscoveredService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppHubRestTransport._GetDiscoveredService._get_response( self._host, @@ -2327,7 +2956,29 @@ def __call__( pb_resp = service.DiscoveredService.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_discovered_service(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.DiscoveredService.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apphub_v1.AppHubClient.get_discovered_service", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "GetDiscoveredService", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDiscoveredWorkload( @@ -2364,7 +3015,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workload.DiscoveredWorkload: r"""Call the get discovered workload method over HTTP. @@ -2374,8 +3025,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.workload.DiscoveredWorkload: @@ -2392,6 +3045,7 @@ def __call__( http_options = ( _BaseAppHubRestTransport._BaseGetDiscoveredWorkload._get_http_options() ) + request, metadata = self._interceptor.pre_get_discovered_workload( request, metadata ) @@ -2404,6 +3058,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apphub_v1.AppHubClient.GetDiscoveredWorkload", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "GetDiscoveredWorkload", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppHubRestTransport._GetDiscoveredWorkload._get_response( self._host, @@ -2424,7 +3105,29 @@ def __call__( pb_resp = workload.DiscoveredWorkload.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_discovered_workload(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = workload.DiscoveredWorkload.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apphub_v1.AppHubClient.get_discovered_workload", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "GetDiscoveredWorkload", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetService(_BaseAppHubRestTransport._BaseGetService, AppHubRestStub): @@ -2459,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]]] = (), ) -> service.Service: r"""Call the get service method over HTTP. @@ -2469,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: ~.service.Service: @@ -2483,6 +3188,7 @@ def __call__( """ http_options = _BaseAppHubRestTransport._BaseGetService._get_http_options() + request, metadata = self._interceptor.pre_get_service(request, metadata) transcoded_request = ( _BaseAppHubRestTransport._BaseGetService._get_transcoded_request( @@ -2497,6 +3203,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apphub_v1.AppHubClient.GetService", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "GetService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppHubRestTransport._GetService._get_response( self._host, @@ -2517,7 +3250,29 @@ def __call__( pb_resp = service.Service.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_service(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.Service.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apphub_v1.AppHubClient.get_service", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "GetService", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetServiceProjectAttachment( @@ -2554,7 +3309,7 @@ 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_project_attachment.ServiceProjectAttachment: r"""Call the get service project attachment method over HTTP. @@ -2566,8 +3321,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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_project_attachment.ServiceProjectAttachment: @@ -2587,6 +3344,7 @@ def __call__( http_options = ( _BaseAppHubRestTransport._BaseGetServiceProjectAttachment._get_http_options() ) + request, metadata = self._interceptor.pre_get_service_project_attachment( request, metadata ) @@ -2599,6 +3357,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apphub_v1.AppHubClient.GetServiceProjectAttachment", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "GetServiceProjectAttachment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppHubRestTransport._GetServiceProjectAttachment._get_response( self._host, @@ -2619,7 +3404,33 @@ def __call__( pb_resp = service_project_attachment.ServiceProjectAttachment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_service_project_attachment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + service_project_attachment.ServiceProjectAttachment.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apphub_v1.AppHubClient.get_service_project_attachment", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "GetServiceProjectAttachment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetWorkload(_BaseAppHubRestTransport._BaseGetWorkload, AppHubRestStub): @@ -2654,7 +3465,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> workload.Workload: r"""Call the get workload method over HTTP. @@ -2664,8 +3475,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.workload.Workload: @@ -2680,6 +3493,7 @@ def __call__( """ http_options = _BaseAppHubRestTransport._BaseGetWorkload._get_http_options() + request, metadata = self._interceptor.pre_get_workload(request, metadata) transcoded_request = ( _BaseAppHubRestTransport._BaseGetWorkload._get_transcoded_request( @@ -2694,6 +3508,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apphub_v1.AppHubClient.GetWorkload", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "GetWorkload", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppHubRestTransport._GetWorkload._get_response( self._host, @@ -2714,7 +3555,29 @@ def __call__( pb_resp = workload.Workload.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_workload(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = workload.Workload.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apphub_v1.AppHubClient.get_workload", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "GetWorkload", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListApplications( @@ -2751,7 +3614,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apphub_service.ListApplicationsResponse: r"""Call the list applications method over HTTP. @@ -2761,8 +3624,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.apphub_service.ListApplicationsResponse: @@ -2772,6 +3637,7 @@ def __call__( http_options = ( _BaseAppHubRestTransport._BaseListApplications._get_http_options() ) + request, metadata = self._interceptor.pre_list_applications( request, metadata ) @@ -2788,6 +3654,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apphub_v1.AppHubClient.ListApplications", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "ListApplications", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppHubRestTransport._ListApplications._get_response( self._host, @@ -2808,7 +3701,31 @@ def __call__( pb_resp = apphub_service.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 = apphub_service.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.apphub_v1.AppHubClient.list_applications", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "ListApplications", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDiscoveredServices( @@ -2845,7 +3762,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apphub_service.ListDiscoveredServicesResponse: r"""Call the list discovered services method over HTTP. @@ -2855,8 +3772,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.apphub_service.ListDiscoveredServicesResponse: @@ -2866,6 +3785,7 @@ def __call__( http_options = ( _BaseAppHubRestTransport._BaseListDiscoveredServices._get_http_options() ) + request, metadata = self._interceptor.pre_list_discovered_services( request, metadata ) @@ -2878,6 +3798,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apphub_v1.AppHubClient.ListDiscoveredServices", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "ListDiscoveredServices", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppHubRestTransport._ListDiscoveredServices._get_response( self._host, @@ -2898,7 +3845,31 @@ def __call__( pb_resp = apphub_service.ListDiscoveredServicesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_discovered_services(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + apphub_service.ListDiscoveredServicesResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apphub_v1.AppHubClient.list_discovered_services", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "ListDiscoveredServices", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDiscoveredWorkloads( @@ -2935,7 +3906,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apphub_service.ListDiscoveredWorkloadsResponse: r"""Call the list discovered workloads method over HTTP. @@ -2945,8 +3916,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.apphub_service.ListDiscoveredWorkloadsResponse: @@ -2956,6 +3929,7 @@ def __call__( http_options = ( _BaseAppHubRestTransport._BaseListDiscoveredWorkloads._get_http_options() ) + request, metadata = self._interceptor.pre_list_discovered_workloads( request, metadata ) @@ -2968,6 +3942,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apphub_v1.AppHubClient.ListDiscoveredWorkloads", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "ListDiscoveredWorkloads", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppHubRestTransport._ListDiscoveredWorkloads._get_response( self._host, @@ -2988,7 +3989,31 @@ def __call__( pb_resp = apphub_service.ListDiscoveredWorkloadsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_discovered_workloads(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + apphub_service.ListDiscoveredWorkloadsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apphub_v1.AppHubClient.list_discovered_workloads", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "ListDiscoveredWorkloads", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListServiceProjectAttachments( @@ -3025,7 +4050,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apphub_service.ListServiceProjectAttachmentsResponse: r"""Call the list service project attachments method over HTTP. @@ -3037,8 +4062,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.apphub_service.ListServiceProjectAttachmentsResponse: @@ -3050,6 +4077,7 @@ def __call__( http_options = ( _BaseAppHubRestTransport._BaseListServiceProjectAttachments._get_http_options() ) + request, metadata = self._interceptor.pre_list_service_project_attachments( request, metadata ) @@ -3062,6 +4090,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apphub_v1.AppHubClient.ListServiceProjectAttachments", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "ListServiceProjectAttachments", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppHubRestTransport._ListServiceProjectAttachments._get_response( self._host, @@ -3082,7 +4137,33 @@ def __call__( pb_resp = apphub_service.ListServiceProjectAttachmentsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_service_project_attachments(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + apphub_service.ListServiceProjectAttachmentsResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apphub_v1.AppHubClient.list_service_project_attachments", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "ListServiceProjectAttachments", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListServices(_BaseAppHubRestTransport._BaseListServices, AppHubRestStub): @@ -3117,7 +4198,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apphub_service.ListServicesResponse: r"""Call the list services method over HTTP. @@ -3127,8 +4208,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.apphub_service.ListServicesResponse: @@ -3138,6 +4221,7 @@ def __call__( http_options = ( _BaseAppHubRestTransport._BaseListServices._get_http_options() ) + request, metadata = self._interceptor.pre_list_services(request, metadata) transcoded_request = ( _BaseAppHubRestTransport._BaseListServices._get_transcoded_request( @@ -3152,6 +4236,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apphub_v1.AppHubClient.ListServices", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "ListServices", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppHubRestTransport._ListServices._get_response( self._host, @@ -3172,7 +4283,31 @@ def __call__( pb_resp = apphub_service.ListServicesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_services(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = apphub_service.ListServicesResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apphub_v1.AppHubClient.list_services", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "ListServices", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListWorkloads(_BaseAppHubRestTransport._BaseListWorkloads, AppHubRestStub): @@ -3207,7 +4342,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apphub_service.ListWorkloadsResponse: r"""Call the list workloads method over HTTP. @@ -3217,8 +4352,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.apphub_service.ListWorkloadsResponse: @@ -3228,6 +4365,7 @@ def __call__( http_options = ( _BaseAppHubRestTransport._BaseListWorkloads._get_http_options() ) + request, metadata = self._interceptor.pre_list_workloads(request, metadata) transcoded_request = ( _BaseAppHubRestTransport._BaseListWorkloads._get_transcoded_request( @@ -3242,6 +4380,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apphub_v1.AppHubClient.ListWorkloads", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "ListWorkloads", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppHubRestTransport._ListWorkloads._get_response( self._host, @@ -3262,7 +4427,31 @@ def __call__( pb_resp = apphub_service.ListWorkloadsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_workloads(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = apphub_service.ListWorkloadsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apphub_v1.AppHubClient.list_workloads", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "ListWorkloads", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _LookupDiscoveredService( @@ -3299,7 +4488,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apphub_service.LookupDiscoveredServiceResponse: r"""Call the lookup discovered service method over HTTP. @@ -3309,8 +4498,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.apphub_service.LookupDiscoveredServiceResponse: @@ -3320,6 +4511,7 @@ def __call__( http_options = ( _BaseAppHubRestTransport._BaseLookupDiscoveredService._get_http_options() ) + request, metadata = self._interceptor.pre_lookup_discovered_service( request, metadata ) @@ -3332,6 +4524,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apphub_v1.AppHubClient.LookupDiscoveredService", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "LookupDiscoveredService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppHubRestTransport._LookupDiscoveredService._get_response( self._host, @@ -3352,7 +4571,31 @@ def __call__( pb_resp = apphub_service.LookupDiscoveredServiceResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_lookup_discovered_service(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + apphub_service.LookupDiscoveredServiceResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apphub_v1.AppHubClient.lookup_discovered_service", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "LookupDiscoveredService", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _LookupDiscoveredWorkload( @@ -3389,7 +4632,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apphub_service.LookupDiscoveredWorkloadResponse: r"""Call the lookup discovered workload method over HTTP. @@ -3400,8 +4643,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.apphub_service.LookupDiscoveredWorkloadResponse: @@ -3413,6 +4658,7 @@ def __call__( http_options = ( _BaseAppHubRestTransport._BaseLookupDiscoveredWorkload._get_http_options() ) + request, metadata = self._interceptor.pre_lookup_discovered_workload( request, metadata ) @@ -3425,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 = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apphub_v1.AppHubClient.LookupDiscoveredWorkload", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "LookupDiscoveredWorkload", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppHubRestTransport._LookupDiscoveredWorkload._get_response( self._host, @@ -3445,7 +4718,33 @@ def __call__( pb_resp = apphub_service.LookupDiscoveredWorkloadResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_lookup_discovered_workload(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + apphub_service.LookupDiscoveredWorkloadResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apphub_v1.AppHubClient.lookup_discovered_workload", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "LookupDiscoveredWorkload", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _LookupServiceProjectAttachment( @@ -3482,7 +4781,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> apphub_service.LookupServiceProjectAttachmentResponse: r"""Call the lookup service project attachment method over HTTP. @@ -3494,8 +4793,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.apphub_service.LookupServiceProjectAttachmentResponse: @@ -3507,6 +4808,7 @@ def __call__( http_options = ( _BaseAppHubRestTransport._BaseLookupServiceProjectAttachment._get_http_options() ) + request, metadata = self._interceptor.pre_lookup_service_project_attachment( request, metadata ) @@ -3519,6 +4821,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apphub_v1.AppHubClient.LookupServiceProjectAttachment", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "LookupServiceProjectAttachment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppHubRestTransport._LookupServiceProjectAttachment._get_response( @@ -3541,7 +4870,33 @@ def __call__( pb_resp = apphub_service.LookupServiceProjectAttachmentResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_lookup_service_project_attachment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + apphub_service.LookupServiceProjectAttachmentResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apphub_v1.AppHubClient.lookup_service_project_attachment", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "LookupServiceProjectAttachment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateApplication( @@ -3579,7 +4934,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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. @@ -3589,8 +4944,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3603,6 +4960,7 @@ def __call__( http_options = ( _BaseAppHubRestTransport._BaseUpdateApplication._get_http_options() ) + request, metadata = self._interceptor.pre_update_application( request, metadata ) @@ -3625,6 +4983,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apphub_v1.AppHubClient.UpdateApplication", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "UpdateApplication", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppHubRestTransport._UpdateApplication._get_response( self._host, @@ -3644,7 +5029,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.apphub_v1.AppHubClient.update_application", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "UpdateApplication", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateService(_BaseAppHubRestTransport._BaseUpdateService, AppHubRestStub): @@ -3680,7 +5087,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 service method over HTTP. @@ -3690,8 +5097,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3704,6 +5113,7 @@ def __call__( http_options = ( _BaseAppHubRestTransport._BaseUpdateService._get_http_options() ) + request, metadata = self._interceptor.pre_update_service(request, metadata) transcoded_request = ( _BaseAppHubRestTransport._BaseUpdateService._get_transcoded_request( @@ -3722,6 +5132,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apphub_v1.AppHubClient.UpdateService", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "UpdateService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppHubRestTransport._UpdateService._get_response( self._host, @@ -3741,7 +5178,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_service(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apphub_v1.AppHubClient.update_service", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "UpdateService", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateWorkload(_BaseAppHubRestTransport._BaseUpdateWorkload, AppHubRestStub): @@ -3777,7 +5236,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 workload method over HTTP. @@ -3787,8 +5246,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3801,6 +5262,7 @@ def __call__( http_options = ( _BaseAppHubRestTransport._BaseUpdateWorkload._get_http_options() ) + request, metadata = self._interceptor.pre_update_workload(request, metadata) transcoded_request = ( _BaseAppHubRestTransport._BaseUpdateWorkload._get_transcoded_request( @@ -3819,6 +5281,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apphub_v1.AppHubClient.UpdateWorkload", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "UpdateWorkload", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppHubRestTransport._UpdateWorkload._get_response( self._host, @@ -3838,7 +5327,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_workload(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.apphub_v1.AppHubClient.update_workload", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "UpdateWorkload", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -4132,7 +5643,7 @@ 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. @@ -4142,14 +5653,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 = _BaseAppHubRestTransport._BaseGetLocation._get_http_options() + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseAppHubRestTransport._BaseGetLocation._get_transcoded_request( @@ -4164,6 +5678,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apphub_v1.AppHubClient.GetLocation", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppHubRestTransport._GetLocation._get_response( self._host, @@ -4183,6 +5724,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.apphub_v1.AppHubAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4221,7 +5783,7 @@ 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. @@ -4231,8 +5793,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -4241,6 +5805,7 @@ def __call__( http_options = ( _BaseAppHubRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = ( _BaseAppHubRestTransport._BaseListLocations._get_transcoded_request( @@ -4255,6 +5820,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apphub_v1.AppHubClient.ListLocations", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppHubRestTransport._ListLocations._get_response( self._host, @@ -4274,6 +5866,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.apphub_v1.AppHubAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4312,7 +5925,7 @@ 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. @@ -4322,8 +5935,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -4332,6 +5947,7 @@ def __call__( http_options = ( _BaseAppHubRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = ( _BaseAppHubRestTransport._BaseGetIamPolicy._get_transcoded_request( @@ -4346,6 +5962,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apphub_v1.AppHubClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppHubRestTransport._GetIamPolicy._get_response( self._host, @@ -4365,6 +6008,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.apphub_v1.AppHubAsyncClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "GetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4404,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]]] = (), ) -> policy_pb2.Policy: r"""Call the set iam policy method over HTTP. @@ -4414,8 +6078,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -4424,6 +6090,7 @@ def __call__( http_options = ( _BaseAppHubRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = ( _BaseAppHubRestTransport._BaseSetIamPolicy._get_transcoded_request( @@ -4442,6 +6109,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apphub_v1.AppHubClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppHubRestTransport._SetIamPolicy._get_response( self._host, @@ -4462,6 +6156,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.apphub_v1.AppHubAsyncClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "SetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4503,7 +6218,7 @@ 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. @@ -4513,8 +6228,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -4523,6 +6240,7 @@ def __call__( http_options = ( _BaseAppHubRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -4543,6 +6261,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apphub_v1.AppHubClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppHubRestTransport._TestIamPermissions._get_response( self._host, @@ -4563,6 +6308,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.apphub_v1.AppHubAsyncClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "TestIamPermissions", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4604,7 +6370,7 @@ 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. @@ -4614,13 +6380,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 = ( _BaseAppHubRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -4641,6 +6410,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apphub_v1.AppHubClient.CancelOperation", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppHubRestTransport._CancelOperation._get_response( self._host, @@ -4697,7 +6493,7 @@ 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. @@ -4707,13 +6503,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 = ( _BaseAppHubRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -4730,6 +6529,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apphub_v1.AppHubClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppHubRestTransport._DeleteOperation._get_response( self._host, @@ -4783,7 +6609,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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. @@ -4793,8 +6619,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -4803,6 +6631,7 @@ def __call__( http_options = ( _BaseAppHubRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseAppHubRestTransport._BaseGetOperation._get_transcoded_request( @@ -4817,6 +6646,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apphub_v1.AppHubClient.GetOperation", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppHubRestTransport._GetOperation._get_response( self._host, @@ -4836,6 +6692,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.apphub_v1.AppHubAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4874,7 +6751,7 @@ def __call__( *, 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. @@ -4884,8 +6761,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must 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. @@ -4894,6 +6773,7 @@ def __call__( http_options = ( _BaseAppHubRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = ( _BaseAppHubRestTransport._BaseListOperations._get_transcoded_request( @@ -4908,6 +6788,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.apphub_v1.AppHubClient.ListOperations", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppHubRestTransport._ListOperations._get_response( self._host, @@ -4927,6 +6834,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.apphub_v1.AppHubAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.apphub.v1.AppHub", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-apphub/samples/generated_samples/snippet_metadata_google.cloud.apphub.v1.json b/packages/google-cloud-apphub/samples/generated_samples/snippet_metadata_google.cloud.apphub.v1.json index 7f54a8e2552a..161a57517820 100644 --- a/packages/google-cloud-apphub/samples/generated_samples/snippet_metadata_google.cloud.apphub.v1.json +++ b/packages/google-cloud-apphub/samples/generated_samples/snippet_metadata_google.cloud.apphub.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-apphub", - "version": "0.1.4" + "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", @@ -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", @@ -835,7 +835,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -916,7 +916,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -996,7 +996,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1077,7 +1077,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", @@ -1238,7 +1238,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1318,7 +1318,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1399,7 +1399,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apphub_v1.types.DetachServiceProjectAttachmentResponse", @@ -1479,7 +1479,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apphub_v1.types.DetachServiceProjectAttachmentResponse", @@ -1560,7 +1560,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apphub_v1.types.Application", @@ -1640,7 +1640,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apphub_v1.types.Application", @@ -1721,7 +1721,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apphub_v1.types.DiscoveredService", @@ -1801,7 +1801,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apphub_v1.types.DiscoveredService", @@ -1882,7 +1882,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apphub_v1.types.DiscoveredWorkload", @@ -1962,7 +1962,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apphub_v1.types.DiscoveredWorkload", @@ -2043,7 +2043,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apphub_v1.types.ServiceProjectAttachment", @@ -2123,7 +2123,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apphub_v1.types.ServiceProjectAttachment", @@ -2204,7 +2204,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apphub_v1.types.Service", @@ -2284,7 +2284,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apphub_v1.types.Service", @@ -2365,7 +2365,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apphub_v1.types.Workload", @@ -2445,7 +2445,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apphub_v1.types.Workload", @@ -2526,7 +2526,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apphub_v1.services.app_hub.pagers.ListApplicationsAsyncPager", @@ -2606,7 +2606,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apphub_v1.services.app_hub.pagers.ListApplicationsPager", @@ -2687,7 +2687,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apphub_v1.services.app_hub.pagers.ListDiscoveredServicesAsyncPager", @@ -2767,7 +2767,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apphub_v1.services.app_hub.pagers.ListDiscoveredServicesPager", @@ -2848,7 +2848,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apphub_v1.services.app_hub.pagers.ListDiscoveredWorkloadsAsyncPager", @@ -2928,7 +2928,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apphub_v1.services.app_hub.pagers.ListDiscoveredWorkloadsPager", @@ -3009,7 +3009,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apphub_v1.services.app_hub.pagers.ListServiceProjectAttachmentsAsyncPager", @@ -3089,7 +3089,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apphub_v1.services.app_hub.pagers.ListServiceProjectAttachmentsPager", @@ -3170,7 +3170,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apphub_v1.services.app_hub.pagers.ListServicesAsyncPager", @@ -3250,7 +3250,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apphub_v1.services.app_hub.pagers.ListServicesPager", @@ -3331,7 +3331,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apphub_v1.services.app_hub.pagers.ListWorkloadsAsyncPager", @@ -3411,7 +3411,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apphub_v1.services.app_hub.pagers.ListWorkloadsPager", @@ -3496,7 +3496,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apphub_v1.types.LookupDiscoveredServiceResponse", @@ -3580,7 +3580,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apphub_v1.types.LookupDiscoveredServiceResponse", @@ -3665,7 +3665,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apphub_v1.types.LookupDiscoveredWorkloadResponse", @@ -3749,7 +3749,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apphub_v1.types.LookupDiscoveredWorkloadResponse", @@ -3830,7 +3830,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apphub_v1.types.LookupServiceProjectAttachmentResponse", @@ -3910,7 +3910,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.apphub_v1.types.LookupServiceProjectAttachmentResponse", @@ -3995,7 +3995,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4079,7 +4079,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4164,7 +4164,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4248,7 +4248,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4333,7 +4333,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4417,7 +4417,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-apphub/tests/unit/gapic/apphub_v1/test_app_hub.py b/packages/google-cloud-apphub/tests/unit/gapic/apphub_v1/test_app_hub.py index cca807929893..650272d23554 100644 --- a/packages/google-cloud-apphub/tests/unit/gapic/apphub_v1/test_app_hub.py +++ b/packages/google-cloud-apphub/tests/unit/gapic/apphub_v1/test_app_hub.py @@ -11687,6 +11687,7 @@ def test_lookup_service_project_attachment_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.lookup_service_project_attachment(request) @@ -11736,6 +11737,7 @@ def test_lookup_service_project_attachment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.lookup_service_project_attachment(**mock_args) @@ -11885,6 +11887,7 @@ def test_list_service_project_attachments_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_service_project_attachments(request) @@ -11944,6 +11947,7 @@ def test_list_service_project_attachments_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_service_project_attachments(**mock_args) @@ -12173,6 +12177,7 @@ def test_create_service_project_attachment_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_service_project_attachment(request) @@ -12242,6 +12247,7 @@ def test_create_service_project_attachment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_service_project_attachment(**mock_args) @@ -12386,6 +12392,7 @@ def test_get_service_project_attachment_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_service_project_attachment(request) @@ -12437,6 +12444,7 @@ def test_get_service_project_attachment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_service_project_attachment(**mock_args) @@ -12576,6 +12584,7 @@ def test_delete_service_project_attachment_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_service_project_attachment(request) @@ -12623,6 +12632,7 @@ def test_delete_service_project_attachment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_service_project_attachment(**mock_args) @@ -12764,6 +12774,7 @@ def test_detach_service_project_attachment_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.detach_service_project_attachment(request) @@ -12813,6 +12824,7 @@ def test_detach_service_project_attachment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.detach_service_project_attachment(**mock_args) @@ -12962,6 +12974,7 @@ def test_list_discovered_services_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_discovered_services(request) @@ -13017,6 +13030,7 @@ def test_list_discovered_services_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_discovered_services(**mock_args) @@ -13216,6 +13230,7 @@ def test_get_discovered_service_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_discovered_service(request) @@ -13263,6 +13278,7 @@ def test_get_discovered_service_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_discovered_service(**mock_args) @@ -13410,6 +13426,7 @@ def test_lookup_discovered_service_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.lookup_discovered_service(request) @@ -13470,6 +13487,7 @@ def test_lookup_discovered_service_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.lookup_discovered_service(**mock_args) @@ -13611,6 +13629,7 @@ def test_list_services_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_services(request) @@ -13668,6 +13687,7 @@ def test_list_services_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_services(**mock_args) @@ -13880,6 +13900,7 @@ def test_create_service_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_service(request) @@ -13947,6 +13968,7 @@ def test_create_service_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_service(**mock_args) @@ -14080,6 +14102,7 @@ def test_get_service_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_service(request) @@ -14127,6 +14150,7 @@ def test_get_service_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_service(**mock_args) @@ -14262,6 +14286,7 @@ def test_update_service_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_service(request) @@ -14323,6 +14348,7 @@ def test_update_service_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_service(**mock_args) @@ -14458,6 +14484,7 @@ def test_delete_service_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_service(request) @@ -14503,6 +14530,7 @@ def test_delete_service_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_service(**mock_args) @@ -14650,6 +14678,7 @@ def test_list_discovered_workloads_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_discovered_workloads(request) @@ -14705,6 +14734,7 @@ def test_list_discovered_workloads_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_discovered_workloads(**mock_args) @@ -14904,6 +14934,7 @@ def test_get_discovered_workload_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_discovered_workload(request) @@ -14951,6 +14982,7 @@ def test_get_discovered_workload_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_discovered_workload(**mock_args) @@ -15098,6 +15130,7 @@ def test_lookup_discovered_workload_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.lookup_discovered_workload(request) @@ -15158,6 +15191,7 @@ def test_lookup_discovered_workload_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.lookup_discovered_workload(**mock_args) @@ -15299,6 +15333,7 @@ def test_list_workloads_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_workloads(request) @@ -15356,6 +15391,7 @@ def test_list_workloads_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_workloads(**mock_args) @@ -15568,6 +15604,7 @@ def test_create_workload_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_workload(request) @@ -15635,6 +15672,7 @@ def test_create_workload_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_workload(**mock_args) @@ -15768,6 +15806,7 @@ def test_get_workload_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_workload(request) @@ -15815,6 +15854,7 @@ def test_get_workload_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_workload(**mock_args) @@ -15950,6 +15990,7 @@ def test_update_workload_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_workload(request) @@ -16011,6 +16052,7 @@ def test_update_workload_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_workload(**mock_args) @@ -16146,6 +16188,7 @@ def test_delete_workload_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_workload(request) @@ -16191,6 +16234,7 @@ def test_delete_workload_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_workload(**mock_args) @@ -16333,6 +16377,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) @@ -16388,6 +16433,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) @@ -16602,6 +16648,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) @@ -16667,6 +16714,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) @@ -16800,6 +16848,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) @@ -16847,6 +16896,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) @@ -16986,6 +17036,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) @@ -17047,6 +17098,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) @@ -17186,6 +17238,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) @@ -17231,6 +17284,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) @@ -18761,6 +18815,7 @@ def test_lookup_service_project_attachment_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.lookup_service_project_attachment(request) @@ -18796,6 +18851,7 @@ def test_lookup_service_project_attachment_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.lookup_service_project_attachment(request) # Establish that the response is the type that we expect. @@ -18833,6 +18889,7 @@ def test_lookup_service_project_attachment_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = apphub_service.LookupServiceProjectAttachmentResponse.to_json( apphub_service.LookupServiceProjectAttachmentResponse() ) @@ -18879,6 +18936,7 @@ def test_list_service_project_attachments_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_service_project_attachments(request) @@ -18917,6 +18975,7 @@ def test_list_service_project_attachments_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_service_project_attachments(request) # Establish that the response is the type that we expect. @@ -18956,6 +19015,7 @@ def test_list_service_project_attachments_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = apphub_service.ListServiceProjectAttachmentsResponse.to_json( apphub_service.ListServiceProjectAttachmentsResponse() ) @@ -19002,6 +19062,7 @@ def test_create_service_project_attachment_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_service_project_attachment(request) @@ -19112,6 +19173,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_service_project_attachment(request) # Establish that the response is the type that we expect. @@ -19151,6 +19213,7 @@ def test_create_service_project_attachment_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -19197,6 +19260,7 @@ def test_get_service_project_attachment_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_service_project_attachment(request) @@ -19239,6 +19303,7 @@ def test_get_service_project_attachment_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_service_project_attachment(request) # Establish that the response is the type that we expect. @@ -19283,6 +19348,7 @@ def test_get_service_project_attachment_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = service_project_attachment.ServiceProjectAttachment.to_json( service_project_attachment.ServiceProjectAttachment() ) @@ -19331,6 +19397,7 @@ def test_delete_service_project_attachment_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_service_project_attachment(request) @@ -19363,6 +19430,7 @@ def test_delete_service_project_attachment_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_service_project_attachment(request) # Establish that the response is the type that we expect. @@ -19402,6 +19470,7 @@ def test_delete_service_project_attachment_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -19446,6 +19515,7 @@ def test_detach_service_project_attachment_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.detach_service_project_attachment(request) @@ -19481,6 +19551,7 @@ def test_detach_service_project_attachment_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.detach_service_project_attachment(request) # Establish that the response is the type that we expect. @@ -19518,6 +19589,7 @@ def test_detach_service_project_attachment_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = apphub_service.DetachServiceProjectAttachmentResponse.to_json( apphub_service.DetachServiceProjectAttachmentResponse() ) @@ -19564,6 +19636,7 @@ def test_list_discovered_services_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_discovered_services(request) @@ -19600,6 +19673,7 @@ def test_list_discovered_services_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_discovered_services(request) # Establish that the response is the type that we expect. @@ -19639,6 +19713,7 @@ def test_list_discovered_services_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = apphub_service.ListDiscoveredServicesResponse.to_json( apphub_service.ListDiscoveredServicesResponse() ) @@ -19687,6 +19762,7 @@ def test_get_discovered_service_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_discovered_service(request) @@ -19724,6 +19800,7 @@ def test_get_discovered_service_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_discovered_service(request) # Establish that the response is the type that we expect. @@ -19762,6 +19839,7 @@ def test_get_discovered_service_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = service.DiscoveredService.to_json(service.DiscoveredService()) req.return_value.content = return_value @@ -19806,6 +19884,7 @@ def test_lookup_discovered_service_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.lookup_discovered_service(request) @@ -19839,6 +19918,7 @@ def test_lookup_discovered_service_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.lookup_discovered_service(request) # Establish that the response is the type that we expect. @@ -19876,6 +19956,7 @@ def test_lookup_discovered_service_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = apphub_service.LookupDiscoveredServiceResponse.to_json( apphub_service.LookupDiscoveredServiceResponse() ) @@ -19922,6 +20003,7 @@ def test_list_services_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_services(request) @@ -19958,6 +20040,7 @@ def test_list_services_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_services(request) # Establish that the response is the type that we expect. @@ -19997,6 +20080,7 @@ def test_list_services_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = apphub_service.ListServicesResponse.to_json( apphub_service.ListServicesResponse() ) @@ -20043,6 +20127,7 @@ def test_create_service_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_service(request) @@ -20165,6 +20250,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_service(request) # Establish that the response is the type that we expect. @@ -20204,6 +20290,7 @@ def test_create_service_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -20248,6 +20335,7 @@ def test_get_service_rest_bad_request(request_type=apphub_service.GetServiceRequ response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_service(request) @@ -20290,6 +20378,7 @@ def test_get_service_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_service(request) # Establish that the response is the type that we expect. @@ -20333,6 +20422,7 @@ def test_get_service_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = service.Service.to_json(service.Service()) req.return_value.content = return_value @@ -20381,6 +20471,7 @@ def test_update_service_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_service(request) @@ -20507,6 +20598,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_service(request) # Establish that the response is the type that we expect. @@ -20546,6 +20638,7 @@ def test_update_service_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -20592,6 +20685,7 @@ def test_delete_service_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_service(request) @@ -20624,6 +20718,7 @@ def test_delete_service_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_service(request) # Establish that the response is the type that we expect. @@ -20663,6 +20758,7 @@ def test_delete_service_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -20707,6 +20803,7 @@ def test_list_discovered_workloads_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_discovered_workloads(request) @@ -20743,6 +20840,7 @@ def test_list_discovered_workloads_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_discovered_workloads(request) # Establish that the response is the type that we expect. @@ -20782,6 +20880,7 @@ def test_list_discovered_workloads_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = apphub_service.ListDiscoveredWorkloadsResponse.to_json( apphub_service.ListDiscoveredWorkloadsResponse() ) @@ -20830,6 +20929,7 @@ def test_get_discovered_workload_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_discovered_workload(request) @@ -20867,6 +20967,7 @@ def test_get_discovered_workload_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_discovered_workload(request) # Establish that the response is the type that we expect. @@ -20905,6 +21006,7 @@ def test_get_discovered_workload_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = workload.DiscoveredWorkload.to_json( workload.DiscoveredWorkload() ) @@ -20951,6 +21053,7 @@ def test_lookup_discovered_workload_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.lookup_discovered_workload(request) @@ -20984,6 +21087,7 @@ def test_lookup_discovered_workload_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.lookup_discovered_workload(request) # Establish that the response is the type that we expect. @@ -21021,6 +21125,7 @@ def test_lookup_discovered_workload_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = apphub_service.LookupDiscoveredWorkloadResponse.to_json( apphub_service.LookupDiscoveredWorkloadResponse() ) @@ -21067,6 +21172,7 @@ def test_list_workloads_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_workloads(request) @@ -21103,6 +21209,7 @@ def test_list_workloads_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_workloads(request) # Establish that the response is the type that we expect. @@ -21142,6 +21249,7 @@ def test_list_workloads_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = apphub_service.ListWorkloadsResponse.to_json( apphub_service.ListWorkloadsResponse() ) @@ -21188,6 +21296,7 @@ def test_create_workload_rest_bad_request( response_value.status_code = 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_workload(request) @@ -21310,6 +21419,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_workload(request) # Establish that the response is the type that we expect. @@ -21349,6 +21459,7 @@ def test_create_workload_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -21393,6 +21504,7 @@ def test_get_workload_rest_bad_request(request_type=apphub_service.GetWorkloadRe response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_workload(request) @@ -21435,6 +21547,7 @@ def test_get_workload_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_workload(request) # Establish that the response is the type that we expect. @@ -21478,6 +21591,7 @@ def test_get_workload_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = workload.Workload.to_json(workload.Workload()) req.return_value.content = return_value @@ -21526,6 +21640,7 @@ def test_update_workload_rest_bad_request( response_value.status_code = 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_workload(request) @@ -21652,6 +21767,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_workload(request) # Establish that the response is the type that we expect. @@ -21691,6 +21807,7 @@ def test_update_workload_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -21737,6 +21854,7 @@ def test_delete_workload_rest_bad_request( response_value.status_code = 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_workload(request) @@ -21769,6 +21887,7 @@ def test_delete_workload_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_workload(request) # Establish that the response is the type that we expect. @@ -21808,6 +21927,7 @@ def test_delete_workload_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -21852,6 +21972,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) @@ -21888,6 +22009,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. @@ -21927,6 +22049,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 = apphub_service.ListApplicationsResponse.to_json( apphub_service.ListApplicationsResponse() ) @@ -21973,6 +22096,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) @@ -22089,6 +22213,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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. @@ -22128,6 +22253,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 @@ -22172,6 +22298,7 @@ def test_get_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.get_application(request) @@ -22211,6 +22338,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. @@ -22253,6 +22381,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 = application.Application.to_json(application.Application()) req.return_value.content = return_value @@ -22301,6 +22430,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) @@ -22421,6 +22551,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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. @@ -22460,6 +22591,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 @@ -22504,6 +22636,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) @@ -22534,6 +22667,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. @@ -22573,6 +22707,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 @@ -22617,6 +22752,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) @@ -22647,6 +22783,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) @@ -22675,6 +22812,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) @@ -22705,6 +22843,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) @@ -22735,6 +22874,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) @@ -22767,6 +22907,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) @@ -22797,6 +22938,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) @@ -22829,6 +22971,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) @@ -22859,6 +23002,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) @@ -22891,6 +23035,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) @@ -22921,6 +23066,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) @@ -22951,6 +23097,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) @@ -22981,6 +23128,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) @@ -23011,6 +23159,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) @@ -23041,6 +23190,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) @@ -23071,6 +23221,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) @@ -23101,6 +23252,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) @@ -23131,6 +23283,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-artifact-registry/google/cloud/artifactregistry/gapic_version.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry/gapic_version.py index 0b9427f4e8a5..558c8aab67c5 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry/gapic_version.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry/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-artifact-registry/google/cloud/artifactregistry_v1/gapic_version.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/gapic_version.py index 0b9427f4e8a5..558c8aab67c5 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/gapic_version.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_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-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/async_client.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/async_client.py index 08f7cb81309b..c8a241cd6f7a 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/async_client.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/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, @@ -79,6 +80,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ArtifactRegistryTransport from .transports.grpc_asyncio import ArtifactRegistryGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class ArtifactRegistryAsyncClient: """The Artifact Registry API service. @@ -345,6 +355,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.artifactregistry_v1.ArtifactRegistryAsyncClient`.", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "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.artifactregistry.v1.ArtifactRegistry", + "credentialsType": None, + }, + ) + async def list_docker_images( self, request: Optional[Union[artifact.ListDockerImagesRequest, dict]] = None, @@ -352,7 +384,7 @@ async def list_docker_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.ListDockerImagesAsyncPager: r"""Lists docker images. @@ -397,8 +429,10 @@ async def sample_list_docker_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.artifactregistry_v1.services.artifact_registry.pagers.ListDockerImagesAsyncPager: @@ -473,7 +507,7 @@ async def get_docker_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]]] = (), ) -> artifact.DockerImage: r"""Gets a docker image. @@ -516,8 +550,10 @@ async def sample_get_docker_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.artifactregistry_v1.types.DockerImage: @@ -581,7 +617,7 @@ async def list_maven_artifacts( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListMavenArtifactsAsyncPager: r"""Lists maven artifacts. @@ -626,8 +662,10 @@ async def sample_list_maven_artifacts(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListMavenArtifactsAsyncPager: @@ -702,7 +740,7 @@ async def get_maven_artifact( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> artifact.MavenArtifact: r"""Gets a maven artifact. @@ -745,8 +783,10 @@ async def sample_get_maven_artifact(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.types.MavenArtifact: @@ -807,7 +847,7 @@ async def list_npm_packages( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListNpmPackagesAsyncPager: r"""Lists npm packages. @@ -852,8 +892,10 @@ async def sample_list_npm_packages(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListNpmPackagesAsyncPager: @@ -928,7 +970,7 @@ async def get_npm_package( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> artifact.NpmPackage: r"""Gets a npm package. @@ -971,8 +1013,10 @@ async def sample_get_npm_package(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.types.NpmPackage: @@ -1033,7 +1077,7 @@ async def list_python_packages( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPythonPackagesAsyncPager: r"""Lists python packages. @@ -1078,8 +1122,10 @@ async def sample_list_python_packages(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListPythonPackagesAsyncPager: @@ -1154,7 +1200,7 @@ async def get_python_package( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> artifact.PythonPackage: r"""Gets a python package. @@ -1197,8 +1243,10 @@ async def sample_get_python_package(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.types.PythonPackage: @@ -1258,7 +1306,7 @@ async def import_apt_artifacts( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 Apt artifacts. The returned Operation will complete once the resources are imported. Package, @@ -1302,8 +1350,10 @@ async def sample_import_apt_artifacts(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -1360,7 +1410,7 @@ async def import_yum_artifacts( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 Yum (RPM) artifacts. The returned Operation will complete once the resources are imported. Package, @@ -1404,8 +1454,10 @@ async def sample_import_yum_artifacts(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -1463,7 +1515,7 @@ async def list_repositories( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListRepositoriesAsyncPager: r"""Lists repositories. @@ -1508,8 +1560,10 @@ async def sample_list_repositories(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListRepositoriesAsyncPager: @@ -1584,7 +1638,7 @@ async def get_repository( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> repository.Repository: r"""Gets a repository. @@ -1627,8 +1681,10 @@ async def sample_get_repository(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.types.Repository: @@ -1691,7 +1747,7 @@ async def create_repository( repository_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 repository. The returned Operation will finish once the repository has been created. Its @@ -1757,8 +1813,10 @@ async def sample_create_repository(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -1836,7 +1894,7 @@ async def update_repository( 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]]] = (), ) -> gda_repository.Repository: r"""Updates a repository. @@ -1886,8 +1944,10 @@ async def sample_update_repository(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.types.Repository: @@ -1952,7 +2012,7 @@ async def delete_repository( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 repository and all of its contents. The returned Operation will finish once the repository has @@ -2002,8 +2062,10 @@ async def sample_delete_repository(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -2082,7 +2144,7 @@ async def list_packages( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPackagesAsyncPager: r"""Lists packages. @@ -2126,8 +2188,10 @@ async def sample_list_packages(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListPackagesAsyncPager: @@ -2202,7 +2266,7 @@ async def get_package( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> package.Package: r"""Gets a package. @@ -2245,8 +2309,10 @@ async def sample_get_package(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.types.Package: @@ -2307,7 +2373,7 @@ async def delete_package( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 package and all of its versions and tags. The returned operation will complete once the package @@ -2356,8 +2422,10 @@ async def sample_delete_package(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -2436,7 +2504,7 @@ async def list_versions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListVersionsAsyncPager: r"""Lists versions. @@ -2479,8 +2547,10 @@ async def sample_list_versions(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListVersionsAsyncPager: @@ -2555,7 +2625,7 @@ async def get_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> version.Version: r"""Gets a version @@ -2595,8 +2665,10 @@ async def sample_get_version(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.types.Version: @@ -2660,7 +2732,7 @@ async def delete_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a version and all of its content. The returned operation will complete once the version has @@ -2706,8 +2778,10 @@ async def sample_delete_version(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -2787,7 +2861,7 @@ async def batch_delete_versions( names: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes multiple versions across a repository. The returned operation will complete once the versions have @@ -2845,8 +2919,10 @@ async def sample_batch_delete_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.api_core.operation_async.AsyncOperation: @@ -2928,7 +3004,7 @@ async def update_version( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gda_version.Version: r"""Updates a version. @@ -2978,8 +3054,10 @@ async def sample_update_version(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.types.Version: @@ -3047,7 +3125,7 @@ async def list_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.ListFilesAsyncPager: r"""Lists files. @@ -3092,8 +3170,10 @@ async def sample_list_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.artifactregistry_v1.services.artifact_registry.pagers.ListFilesAsyncPager: @@ -3168,7 +3248,7 @@ async def get_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]]] = (), ) -> file.File: r"""Gets a file. @@ -3211,8 +3291,10 @@ async def sample_get_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.artifactregistry_v1.types.File: @@ -3272,7 +3354,7 @@ async def delete_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]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a file and all of its content. It is only allowed on generic repositories. The returned operation @@ -3321,8 +3403,10 @@ async def sample_delete_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.api_core.operation_async.AsyncOperation: @@ -3402,7 +3486,7 @@ async def update_file( 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]]] = (), ) -> gda_file.File: r"""Updates a file. @@ -3452,8 +3536,10 @@ async def sample_update_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.artifactregistry_v1.types.File: @@ -3519,7 +3605,7 @@ async def list_tags( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTagsAsyncPager: r"""Lists tags. @@ -3563,8 +3649,10 @@ async def sample_list_tags(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListTagsAsyncPager: @@ -3639,7 +3727,7 @@ async def get_tag( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tag.Tag: r"""Gets a tag. @@ -3679,8 +3767,10 @@ async def sample_get_tag(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.types.Tag: @@ -3742,7 +3832,7 @@ async def create_tag( tag_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]]] = (), ) -> gda_tag.Tag: r"""Creates a tag. @@ -3796,8 +3886,10 @@ async def sample_create_tag(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.types.Tag: @@ -3864,7 +3956,7 @@ async def update_tag( 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]]] = (), ) -> gda_tag.Tag: r"""Updates a tag. @@ -3915,8 +4007,10 @@ async def sample_update_tag(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.types.Tag: @@ -3980,7 +4074,7 @@ async def delete_tag( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 tag. @@ -4017,8 +4111,10 @@ async def sample_delete_tag(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -4072,7 +4168,7 @@ async def create_rule( 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]]] = (), ) -> gda_rule.Rule: r"""Creates a rule. @@ -4127,8 +4223,10 @@ async def sample_create_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.artifactregistry_v1.types.Rule: @@ -4197,7 +4295,7 @@ async def list_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.ListRulesAsyncPager: r"""Lists rules. @@ -4242,8 +4340,10 @@ async def sample_list_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.artifactregistry_v1.services.artifact_registry.pagers.ListRulesAsyncPager: @@ -4318,7 +4418,7 @@ async def get_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]]] = (), ) -> rule.Rule: r"""Gets a rule. @@ -4361,8 +4461,10 @@ async def sample_get_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.artifactregistry_v1.types.Rule: @@ -4426,7 +4528,7 @@ async def update_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]]] = (), ) -> gda_rule.Rule: r"""Updates a rule. @@ -4476,8 +4578,10 @@ async def sample_update_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.artifactregistry_v1.types.Rule: @@ -4546,7 +4650,7 @@ async def delete_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]]] = (), ) -> None: r"""Deletes a rule. @@ -4586,8 +4690,10 @@ async def sample_delete_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -4638,7 +4744,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"""Updates the IAM policy for a given resource. @@ -4675,8 +4781,10 @@ async def sample_set_iam_policy(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.iam.v1.policy_pb2.Policy: @@ -4752,7 +4860,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 policy for a given resource. @@ -4789,8 +4897,10 @@ async def sample_get_iam_policy(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.iam.v1.policy_pb2.Policy: @@ -4866,7 +4976,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 if the caller has a list of permissions on a resource. @@ -4905,8 +5015,10 @@ async def sample_test_iam_permissions(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -4953,7 +5065,7 @@ async def get_project_settings( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> settings.ProjectSettings: r"""Retrieves the Settings for the Project. @@ -4997,8 +5109,10 @@ async def sample_get_project_settings(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.types.ProjectSettings: @@ -5060,7 +5174,7 @@ async def update_project_settings( 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]]] = (), ) -> settings.ProjectSettings: r"""Updates the Settings for the Project. @@ -5107,8 +5221,10 @@ async def sample_update_project_settings(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.types.ProjectSettings: @@ -5173,7 +5289,7 @@ async def get_vpcsc_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]]] = (), ) -> vpcsc_config.VPCSCConfig: r"""Retrieves the VPCSC Config for the Project. @@ -5216,8 +5332,10 @@ async def sample_get_vpcsc_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.artifactregistry_v1.types.VPCSCConfig: @@ -5281,7 +5399,7 @@ async def update_vpcsc_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]]] = (), ) -> gda_vpcsc_config.VPCSCConfig: r"""Updates the VPCSC Config for the Project. @@ -5328,8 +5446,10 @@ async def sample_update_vpcsc_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.artifactregistry_v1.types.VPCSCConfig: @@ -5395,7 +5515,7 @@ async def update_package( 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]]] = (), ) -> gda_package.Package: r"""Updates a package. @@ -5445,8 +5565,10 @@ async def sample_update_package(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.types.Package: @@ -5511,7 +5633,7 @@ async def list_attachments( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAttachmentsAsyncPager: r"""Lists attachments. @@ -5556,8 +5678,10 @@ async def sample_list_attachments(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListAttachmentsAsyncPager: @@ -5632,7 +5756,7 @@ async def get_attachment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> attachment.Attachment: r"""Gets an attachment. @@ -5676,8 +5800,10 @@ async def sample_get_attachment(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.types.Attachment: @@ -5743,7 +5869,7 @@ async def create_attachment( attachment_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 attachment. The returned Operation will finish once the attachment has been created. Its @@ -5814,8 +5940,10 @@ async def sample_create_attachment(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -5891,7 +6019,7 @@ async def delete_attachment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes an attachment. The returned Operation will finish once the attachments has been deleted. It will not have any Operation @@ -5940,8 +6068,10 @@ async def sample_delete_attachment(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -6019,7 +6149,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. @@ -6030,8 +6160,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. @@ -6072,7 +6204,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. @@ -6083,8 +6215,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. @@ -6125,7 +6259,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. @@ -6136,8 +6270,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-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/client.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/client.py index fd86532583e5..e4bdc840f07d 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/client.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/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 @@ -973,6 +983,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( @@ -1039,6 +1053,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.artifactregistry_v1.ArtifactRegistryClient`.", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "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.artifactregistry.v1.ArtifactRegistry", + "credentialsType": None, + }, + ) + def list_docker_images( self, request: Optional[Union[artifact.ListDockerImagesRequest, dict]] = None, @@ -1046,7 +1083,7 @@ def list_docker_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.ListDockerImagesPager: r"""Lists docker images. @@ -1091,8 +1128,10 @@ def sample_list_docker_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.artifactregistry_v1.services.artifact_registry.pagers.ListDockerImagesPager: @@ -1164,7 +1203,7 @@ def get_docker_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]]] = (), ) -> artifact.DockerImage: r"""Gets a docker image. @@ -1207,8 +1246,10 @@ def sample_get_docker_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.artifactregistry_v1.types.DockerImage: @@ -1269,7 +1310,7 @@ def list_maven_artifacts( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListMavenArtifactsPager: r"""Lists maven artifacts. @@ -1314,8 +1355,10 @@ def sample_list_maven_artifacts(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListMavenArtifactsPager: @@ -1387,7 +1430,7 @@ def get_maven_artifact( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> artifact.MavenArtifact: r"""Gets a maven artifact. @@ -1430,8 +1473,10 @@ def sample_get_maven_artifact(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.types.MavenArtifact: @@ -1489,7 +1534,7 @@ def list_npm_packages( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListNpmPackagesPager: r"""Lists npm packages. @@ -1534,8 +1579,10 @@ def sample_list_npm_packages(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListNpmPackagesPager: @@ -1607,7 +1654,7 @@ def get_npm_package( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> artifact.NpmPackage: r"""Gets a npm package. @@ -1650,8 +1697,10 @@ def sample_get_npm_package(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.types.NpmPackage: @@ -1709,7 +1758,7 @@ def list_python_packages( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPythonPackagesPager: r"""Lists python packages. @@ -1754,8 +1803,10 @@ def sample_list_python_packages(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListPythonPackagesPager: @@ -1827,7 +1878,7 @@ def get_python_package( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> artifact.PythonPackage: r"""Gets a python package. @@ -1870,8 +1921,10 @@ def sample_get_python_package(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.types.PythonPackage: @@ -1928,7 +1981,7 @@ def import_apt_artifacts( *, retry: OptionalRetry = gapic_v1.method.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 Apt artifacts. The returned Operation will complete once the resources are imported. Package, @@ -1972,8 +2025,10 @@ def sample_import_apt_artifacts(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -2028,7 +2083,7 @@ def import_yum_artifacts( *, retry: OptionalRetry = gapic_v1.method.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 Yum (RPM) artifacts. The returned Operation will complete once the resources are imported. Package, @@ -2072,8 +2127,10 @@ def sample_import_yum_artifacts(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -2129,7 +2186,7 @@ def list_repositories( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListRepositoriesPager: r"""Lists repositories. @@ -2174,8 +2231,10 @@ def sample_list_repositories(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListRepositoriesPager: @@ -2247,7 +2306,7 @@ def get_repository( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> repository.Repository: r"""Gets a repository. @@ -2290,8 +2349,10 @@ def sample_get_repository(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.types.Repository: @@ -2351,7 +2412,7 @@ def create_repository( repository_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 repository. The returned Operation will finish once the repository has been created. Its @@ -2417,8 +2478,10 @@ def sample_create_repository(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -2493,7 +2556,7 @@ def update_repository( 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]]] = (), ) -> gda_repository.Repository: r"""Updates a repository. @@ -2543,8 +2606,10 @@ def sample_update_repository(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.types.Repository: @@ -2606,7 +2671,7 @@ def delete_repository( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 repository and all of its contents. The returned Operation will finish once the repository has @@ -2656,8 +2721,10 @@ def sample_delete_repository(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -2733,7 +2800,7 @@ def list_packages( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPackagesPager: r"""Lists packages. @@ -2777,8 +2844,10 @@ def sample_list_packages(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListPackagesPager: @@ -2850,7 +2919,7 @@ def get_package( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> package.Package: r"""Gets a package. @@ -2893,8 +2962,10 @@ def sample_get_package(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.types.Package: @@ -2952,7 +3023,7 @@ def delete_package( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 package and all of its versions and tags. The returned operation will complete once the package @@ -3001,8 +3072,10 @@ def sample_delete_package(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -3078,7 +3151,7 @@ def list_versions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListVersionsPager: r"""Lists versions. @@ -3121,8 +3194,10 @@ def sample_list_versions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListVersionsPager: @@ -3194,7 +3269,7 @@ def get_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> version.Version: r"""Gets a version @@ -3234,8 +3309,10 @@ def sample_get_version(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.types.Version: @@ -3296,7 +3373,7 @@ def delete_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a version and all of its content. The returned operation will complete once the version has @@ -3342,8 +3419,10 @@ def sample_delete_version(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -3420,7 +3499,7 @@ def batch_delete_versions( names: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes multiple versions across a repository. The returned operation will complete once the versions have @@ -3478,8 +3557,10 @@ def sample_batch_delete_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.api_core.operation.Operation: @@ -3558,7 +3639,7 @@ def update_version( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gda_version.Version: r"""Updates a version. @@ -3608,8 +3689,10 @@ def sample_update_version(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.types.Version: @@ -3674,7 +3757,7 @@ def list_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.ListFilesPager: r"""Lists files. @@ -3719,8 +3802,10 @@ def sample_list_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.artifactregistry_v1.services.artifact_registry.pagers.ListFilesPager: @@ -3792,7 +3877,7 @@ def get_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]]] = (), ) -> file.File: r"""Gets a file. @@ -3835,8 +3920,10 @@ def sample_get_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.artifactregistry_v1.types.File: @@ -3895,7 +3982,7 @@ def delete_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]]] = (), ) -> operation.Operation: r"""Deletes a file and all of its content. It is only allowed on generic repositories. The returned operation @@ -3944,8 +4031,10 @@ def sample_delete_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.api_core.operation.Operation: @@ -4022,7 +4111,7 @@ def update_file( 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]]] = (), ) -> gda_file.File: r"""Updates a file. @@ -4072,8 +4161,10 @@ def sample_update_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.artifactregistry_v1.types.File: @@ -4136,7 +4227,7 @@ def list_tags( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTagsPager: r"""Lists tags. @@ -4180,8 +4271,10 @@ def sample_list_tags(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListTagsPager: @@ -4253,7 +4346,7 @@ def get_tag( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tag.Tag: r"""Gets a tag. @@ -4293,8 +4386,10 @@ def sample_get_tag(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.types.Tag: @@ -4355,7 +4450,7 @@ def create_tag( tag_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]]] = (), ) -> gda_tag.Tag: r"""Creates a tag. @@ -4409,8 +4504,10 @@ def sample_create_tag(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.types.Tag: @@ -4474,7 +4571,7 @@ def update_tag( 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]]] = (), ) -> gda_tag.Tag: r"""Updates a tag. @@ -4525,8 +4622,10 @@ def sample_update_tag(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.types.Tag: @@ -4587,7 +4686,7 @@ def delete_tag( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 tag. @@ -4624,8 +4723,10 @@ def sample_delete_tag(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -4676,7 +4777,7 @@ def create_rule( 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]]] = (), ) -> gda_rule.Rule: r"""Creates a rule. @@ -4731,8 +4832,10 @@ def sample_create_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.artifactregistry_v1.types.Rule: @@ -4798,7 +4901,7 @@ def list_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.ListRulesPager: r"""Lists rules. @@ -4843,8 +4946,10 @@ def sample_list_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.artifactregistry_v1.services.artifact_registry.pagers.ListRulesPager: @@ -4916,7 +5021,7 @@ def get_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]]] = (), ) -> rule.Rule: r"""Gets a rule. @@ -4959,8 +5064,10 @@ def sample_get_rule(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.types.Rule: @@ -5023,7 +5130,7 @@ def update_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]]] = (), ) -> gda_rule.Rule: r"""Updates a rule. @@ -5073,8 +5180,10 @@ def sample_update_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.artifactregistry_v1.types.Rule: @@ -5140,7 +5249,7 @@ def delete_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]]] = (), ) -> None: r"""Deletes a rule. @@ -5180,8 +5289,10 @@ def sample_delete_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -5229,7 +5340,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"""Updates the IAM policy for a given resource. @@ -5266,8 +5377,10 @@ def sample_set_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.iam.v1.policy_pb2.Policy: @@ -5342,7 +5455,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 policy for a given resource. @@ -5379,8 +5492,10 @@ def sample_get_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.iam.v1.policy_pb2.Policy: @@ -5455,7 +5570,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 if the caller has a list of permissions on a resource. @@ -5494,8 +5609,10 @@ def sample_test_iam_permissions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -5541,7 +5658,7 @@ def get_project_settings( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> settings.ProjectSettings: r"""Retrieves the Settings for the Project. @@ -5585,8 +5702,10 @@ def sample_get_project_settings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.types.ProjectSettings: @@ -5645,7 +5764,7 @@ def update_project_settings( 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]]] = (), ) -> settings.ProjectSettings: r"""Updates the Settings for the Project. @@ -5692,8 +5811,10 @@ def sample_update_project_settings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.types.ProjectSettings: @@ -5755,7 +5876,7 @@ def get_vpcsc_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]]] = (), ) -> vpcsc_config.VPCSCConfig: r"""Retrieves the VPCSC Config for the Project. @@ -5798,8 +5919,10 @@ def sample_get_vpcsc_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.artifactregistry_v1.types.VPCSCConfig: @@ -5860,7 +5983,7 @@ def update_vpcsc_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]]] = (), ) -> gda_vpcsc_config.VPCSCConfig: r"""Updates the VPCSC Config for the Project. @@ -5907,8 +6030,10 @@ def sample_update_vpcsc_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.artifactregistry_v1.types.VPCSCConfig: @@ -5971,7 +6096,7 @@ def update_package( 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]]] = (), ) -> gda_package.Package: r"""Updates a package. @@ -6021,8 +6146,10 @@ def sample_update_package(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.types.Package: @@ -6084,7 +6211,7 @@ def list_attachments( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAttachmentsPager: r"""Lists attachments. @@ -6129,8 +6256,10 @@ def sample_list_attachments(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListAttachmentsPager: @@ -6202,7 +6331,7 @@ def get_attachment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> attachment.Attachment: r"""Gets an attachment. @@ -6246,8 +6375,10 @@ def sample_get_attachment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1.types.Attachment: @@ -6310,7 +6441,7 @@ def create_attachment( attachment_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 attachment. The returned Operation will finish once the attachment has been created. Its @@ -6381,8 +6512,10 @@ def sample_create_attachment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -6455,7 +6588,7 @@ def delete_attachment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes an attachment. The returned Operation will finish once the attachments has been deleted. It will not have any Operation @@ -6504,8 +6637,10 @@ def sample_delete_attachment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -6593,7 +6728,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. @@ -6604,8 +6739,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. @@ -6646,7 +6783,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. @@ -6657,8 +6794,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. @@ -6699,7 +6838,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. @@ -6710,8 +6849,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-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/pagers.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/pagers.py index 72859ed617b5..29c1bd37a632 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/pagers.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/pagers.py @@ -76,7 +76,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -90,8 +90,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = artifact.ListDockerImagesRequest(request) @@ -150,7 +152,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. @@ -164,8 +166,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 = artifact.ListDockerImagesRequest(request) @@ -228,7 +232,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -242,8 +246,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = artifact.ListMavenArtifactsRequest(request) @@ -302,7 +308,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. @@ -316,8 +322,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 = artifact.ListMavenArtifactsRequest(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 = artifact.ListNpmPackagesRequest(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 = artifact.ListNpmPackagesRequest(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 = artifact.ListPythonPackagesRequest(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 = artifact.ListPythonPackagesRequest(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 = repository.ListRepositoriesRequest(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 = repository.ListRepositoriesRequest(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 = package.ListPackagesRequest(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 = package.ListPackagesRequest(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 = version.ListVersionsRequest(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 = version.ListVersionsRequest(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 = file.ListFilesRequest(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 = file.ListFilesRequest(request) @@ -1292,7 +1324,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1306,8 +1338,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = tag.ListTagsRequest(request) @@ -1366,7 +1400,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. @@ -1380,8 +1414,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 = tag.ListTagsRequest(request) @@ -1444,7 +1480,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1458,8 +1494,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = rule.ListRulesRequest(request) @@ -1518,7 +1556,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. @@ -1532,8 +1570,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 = rule.ListRulesRequest(request) @@ -1596,7 +1636,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1610,8 +1650,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = attachment.ListAttachmentsRequest(request) @@ -1670,7 +1712,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. @@ -1684,8 +1726,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 = attachment.ListAttachmentsRequest(request) diff --git a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/transports/grpc.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/transports/grpc.py index eed5d0fde726..ba3ac26c2fc3 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/transports/grpc.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/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.artifactregistry_v1.types import vpcsc_config as gda_vpcsc_config from google.cloud.artifactregistry_v1.types import apt_artifact, artifact @@ -49,6 +55,81 @@ from .base import DEFAULT_CLIENT_INFO, ArtifactRegistryTransport +try: + from google.api_core import client_logging # 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.artifactregistry.v1.ArtifactRegistry", + "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.artifactregistry.v1.ArtifactRegistry", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ArtifactRegistryGrpcTransport(ArtifactRegistryTransport): """gRPC backend transport for ArtifactRegistry. @@ -215,7 +296,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientInterceptor() + self._logged_channel = grpc.intercept_channel( + self._grpc_channel, self._interceptor + ) + + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @classmethod @@ -279,7 +365,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 @@ -305,7 +393,7 @@ def list_docker_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_docker_images" not in self._stubs: - self._stubs["list_docker_images"] = self.grpc_channel.unary_unary( + self._stubs["list_docker_images"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/ListDockerImages", request_serializer=artifact.ListDockerImagesRequest.serialize, response_deserializer=artifact.ListDockerImagesResponse.deserialize, @@ -331,7 +419,7 @@ def get_docker_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_docker_image" not in self._stubs: - self._stubs["get_docker_image"] = self.grpc_channel.unary_unary( + self._stubs["get_docker_image"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetDockerImage", request_serializer=artifact.GetDockerImageRequest.serialize, response_deserializer=artifact.DockerImage.deserialize, @@ -359,7 +447,7 @@ def list_maven_artifacts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_maven_artifacts" not in self._stubs: - self._stubs["list_maven_artifacts"] = self.grpc_channel.unary_unary( + self._stubs["list_maven_artifacts"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/ListMavenArtifacts", request_serializer=artifact.ListMavenArtifactsRequest.serialize, response_deserializer=artifact.ListMavenArtifactsResponse.deserialize, @@ -385,7 +473,7 @@ def get_maven_artifact( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_maven_artifact" not in self._stubs: - self._stubs["get_maven_artifact"] = self.grpc_channel.unary_unary( + self._stubs["get_maven_artifact"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetMavenArtifact", request_serializer=artifact.GetMavenArtifactRequest.serialize, response_deserializer=artifact.MavenArtifact.deserialize, @@ -411,7 +499,7 @@ def list_npm_packages( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_npm_packages" not in self._stubs: - self._stubs["list_npm_packages"] = self.grpc_channel.unary_unary( + self._stubs["list_npm_packages"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/ListNpmPackages", request_serializer=artifact.ListNpmPackagesRequest.serialize, response_deserializer=artifact.ListNpmPackagesResponse.deserialize, @@ -437,7 +525,7 @@ def get_npm_package( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_npm_package" not in self._stubs: - self._stubs["get_npm_package"] = self.grpc_channel.unary_unary( + self._stubs["get_npm_package"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetNpmPackage", request_serializer=artifact.GetNpmPackageRequest.serialize, response_deserializer=artifact.NpmPackage.deserialize, @@ -465,7 +553,7 @@ def list_python_packages( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_python_packages" not in self._stubs: - self._stubs["list_python_packages"] = self.grpc_channel.unary_unary( + self._stubs["list_python_packages"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/ListPythonPackages", request_serializer=artifact.ListPythonPackagesRequest.serialize, response_deserializer=artifact.ListPythonPackagesResponse.deserialize, @@ -491,7 +579,7 @@ def get_python_package( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_python_package" not in self._stubs: - self._stubs["get_python_package"] = self.grpc_channel.unary_unary( + self._stubs["get_python_package"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetPythonPackage", request_serializer=artifact.GetPythonPackageRequest.serialize, response_deserializer=artifact.PythonPackage.deserialize, @@ -521,7 +609,7 @@ def import_apt_artifacts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_apt_artifacts" not in self._stubs: - self._stubs["import_apt_artifacts"] = self.grpc_channel.unary_unary( + self._stubs["import_apt_artifacts"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/ImportAptArtifacts", request_serializer=apt_artifact.ImportAptArtifactsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -551,7 +639,7 @@ def import_yum_artifacts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_yum_artifacts" not in self._stubs: - self._stubs["import_yum_artifacts"] = self.grpc_channel.unary_unary( + self._stubs["import_yum_artifacts"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/ImportYumArtifacts", request_serializer=yum_artifact.ImportYumArtifactsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -579,7 +667,7 @@ def list_repositories( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_repositories" not in self._stubs: - self._stubs["list_repositories"] = self.grpc_channel.unary_unary( + self._stubs["list_repositories"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/ListRepositories", request_serializer=repository.ListRepositoriesRequest.serialize, response_deserializer=repository.ListRepositoriesResponse.deserialize, @@ -605,7 +693,7 @@ def get_repository( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_repository" not in self._stubs: - self._stubs["get_repository"] = self.grpc_channel.unary_unary( + self._stubs["get_repository"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetRepository", request_serializer=repository.GetRepositoryRequest.serialize, response_deserializer=repository.Repository.deserialize, @@ -633,7 +721,7 @@ def create_repository( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_repository" not in self._stubs: - self._stubs["create_repository"] = self.grpc_channel.unary_unary( + self._stubs["create_repository"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/CreateRepository", request_serializer=gda_repository.CreateRepositoryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -659,7 +747,7 @@ def update_repository( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_repository" not in self._stubs: - self._stubs["update_repository"] = self.grpc_channel.unary_unary( + self._stubs["update_repository"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdateRepository", request_serializer=gda_repository.UpdateRepositoryRequest.serialize, response_deserializer=gda_repository.Repository.deserialize, @@ -688,7 +776,7 @@ def delete_repository( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_repository" not in self._stubs: - self._stubs["delete_repository"] = self.grpc_channel.unary_unary( + self._stubs["delete_repository"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/DeleteRepository", request_serializer=repository.DeleteRepositoryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -714,7 +802,7 @@ def list_packages( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_packages" not in self._stubs: - self._stubs["list_packages"] = self.grpc_channel.unary_unary( + self._stubs["list_packages"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/ListPackages", request_serializer=package.ListPackagesRequest.serialize, response_deserializer=package.ListPackagesResponse.deserialize, @@ -738,7 +826,7 @@ def get_package(self) -> Callable[[package.GetPackageRequest], package.Package]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_package" not in self._stubs: - self._stubs["get_package"] = self.grpc_channel.unary_unary( + self._stubs["get_package"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetPackage", request_serializer=package.GetPackageRequest.serialize, response_deserializer=package.Package.deserialize, @@ -766,7 +854,7 @@ def delete_package( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_package" not in self._stubs: - self._stubs["delete_package"] = self.grpc_channel.unary_unary( + self._stubs["delete_package"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/DeletePackage", request_serializer=package.DeletePackageRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -792,7 +880,7 @@ def list_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_versions" not in self._stubs: - self._stubs["list_versions"] = self.grpc_channel.unary_unary( + self._stubs["list_versions"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/ListVersions", request_serializer=version.ListVersionsRequest.serialize, response_deserializer=version.ListVersionsResponse.deserialize, @@ -816,7 +904,7 @@ def get_version(self) -> Callable[[version.GetVersionRequest], version.Version]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_version" not in self._stubs: - self._stubs["get_version"] = self.grpc_channel.unary_unary( + self._stubs["get_version"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetVersion", request_serializer=version.GetVersionRequest.serialize, response_deserializer=version.Version.deserialize, @@ -844,7 +932,7 @@ def delete_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_version" not in self._stubs: - self._stubs["delete_version"] = self.grpc_channel.unary_unary( + self._stubs["delete_version"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/DeleteVersion", request_serializer=version.DeleteVersionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -872,7 +960,7 @@ def batch_delete_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_delete_versions" not in self._stubs: - self._stubs["batch_delete_versions"] = self.grpc_channel.unary_unary( + self._stubs["batch_delete_versions"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/BatchDeleteVersions", request_serializer=version.BatchDeleteVersionsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -898,7 +986,7 @@ def update_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_version" not in self._stubs: - self._stubs["update_version"] = self.grpc_channel.unary_unary( + self._stubs["update_version"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdateVersion", request_serializer=gda_version.UpdateVersionRequest.serialize, response_deserializer=gda_version.Version.deserialize, @@ -922,7 +1010,7 @@ def list_files(self) -> Callable[[file.ListFilesRequest], file.ListFilesResponse # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_files" not in self._stubs: - self._stubs["list_files"] = self.grpc_channel.unary_unary( + self._stubs["list_files"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/ListFiles", request_serializer=file.ListFilesRequest.serialize, response_deserializer=file.ListFilesResponse.deserialize, @@ -946,7 +1034,7 @@ def get_file(self) -> Callable[[file.GetFileRequest], file.File]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_file" not in self._stubs: - self._stubs["get_file"] = self.grpc_channel.unary_unary( + self._stubs["get_file"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetFile", request_serializer=file.GetFileRequest.serialize, response_deserializer=file.File.deserialize, @@ -974,7 +1062,7 @@ def delete_file( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_file" not in self._stubs: - self._stubs["delete_file"] = self.grpc_channel.unary_unary( + self._stubs["delete_file"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/DeleteFile", request_serializer=file.DeleteFileRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -998,7 +1086,7 @@ def update_file(self) -> Callable[[gda_file.UpdateFileRequest], gda_file.File]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_file" not in self._stubs: - self._stubs["update_file"] = self.grpc_channel.unary_unary( + self._stubs["update_file"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdateFile", request_serializer=gda_file.UpdateFileRequest.serialize, response_deserializer=gda_file.File.deserialize, @@ -1022,7 +1110,7 @@ def list_tags(self) -> Callable[[tag.ListTagsRequest], tag.ListTagsResponse]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_tags" not in self._stubs: - self._stubs["list_tags"] = self.grpc_channel.unary_unary( + self._stubs["list_tags"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/ListTags", request_serializer=tag.ListTagsRequest.serialize, response_deserializer=tag.ListTagsResponse.deserialize, @@ -1046,7 +1134,7 @@ def get_tag(self) -> Callable[[tag.GetTagRequest], tag.Tag]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_tag" not in self._stubs: - self._stubs["get_tag"] = self.grpc_channel.unary_unary( + self._stubs["get_tag"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetTag", request_serializer=tag.GetTagRequest.serialize, response_deserializer=tag.Tag.deserialize, @@ -1070,7 +1158,7 @@ def create_tag(self) -> Callable[[gda_tag.CreateTagRequest], gda_tag.Tag]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_tag" not in self._stubs: - self._stubs["create_tag"] = self.grpc_channel.unary_unary( + self._stubs["create_tag"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/CreateTag", request_serializer=gda_tag.CreateTagRequest.serialize, response_deserializer=gda_tag.Tag.deserialize, @@ -1094,7 +1182,7 @@ def update_tag(self) -> Callable[[gda_tag.UpdateTagRequest], gda_tag.Tag]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_tag" not in self._stubs: - self._stubs["update_tag"] = self.grpc_channel.unary_unary( + self._stubs["update_tag"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdateTag", request_serializer=gda_tag.UpdateTagRequest.serialize, response_deserializer=gda_tag.Tag.deserialize, @@ -1118,7 +1206,7 @@ def delete_tag(self) -> Callable[[tag.DeleteTagRequest], empty_pb2.Empty]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_tag" not in self._stubs: - self._stubs["delete_tag"] = self.grpc_channel.unary_unary( + self._stubs["delete_tag"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/DeleteTag", request_serializer=tag.DeleteTagRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1142,7 +1230,7 @@ def create_rule(self) -> Callable[[gda_rule.CreateRuleRequest], gda_rule.Rule]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_rule" not in self._stubs: - self._stubs["create_rule"] = self.grpc_channel.unary_unary( + self._stubs["create_rule"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/CreateRule", request_serializer=gda_rule.CreateRuleRequest.serialize, response_deserializer=gda_rule.Rule.deserialize, @@ -1166,7 +1254,7 @@ def list_rules(self) -> Callable[[rule.ListRulesRequest], rule.ListRulesResponse # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_rules" not in self._stubs: - self._stubs["list_rules"] = self.grpc_channel.unary_unary( + self._stubs["list_rules"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/ListRules", request_serializer=rule.ListRulesRequest.serialize, response_deserializer=rule.ListRulesResponse.deserialize, @@ -1190,7 +1278,7 @@ def get_rule(self) -> Callable[[rule.GetRuleRequest], rule.Rule]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_rule" not in self._stubs: - self._stubs["get_rule"] = self.grpc_channel.unary_unary( + self._stubs["get_rule"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetRule", request_serializer=rule.GetRuleRequest.serialize, response_deserializer=rule.Rule.deserialize, @@ -1214,7 +1302,7 @@ def update_rule(self) -> Callable[[gda_rule.UpdateRuleRequest], gda_rule.Rule]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_rule" not in self._stubs: - self._stubs["update_rule"] = self.grpc_channel.unary_unary( + self._stubs["update_rule"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdateRule", request_serializer=gda_rule.UpdateRuleRequest.serialize, response_deserializer=gda_rule.Rule.deserialize, @@ -1238,7 +1326,7 @@ def delete_rule(self) -> Callable[[rule.DeleteRuleRequest], empty_pb2.Empty]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_rule" not in self._stubs: - self._stubs["delete_rule"] = self.grpc_channel.unary_unary( + self._stubs["delete_rule"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/DeleteRule", request_serializer=rule.DeleteRuleRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1264,7 +1352,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.devtools.artifactregistry.v1.ArtifactRegistry/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -1290,7 +1378,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.devtools.artifactregistry.v1.ArtifactRegistry/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -1320,7 +1408,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.devtools.artifactregistry.v1.ArtifactRegistry/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -1346,7 +1434,7 @@ def get_project_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_project_settings" not in self._stubs: - self._stubs["get_project_settings"] = self.grpc_channel.unary_unary( + self._stubs["get_project_settings"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetProjectSettings", request_serializer=settings.GetProjectSettingsRequest.serialize, response_deserializer=settings.ProjectSettings.deserialize, @@ -1372,7 +1460,7 @@ def update_project_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_project_settings" not in self._stubs: - self._stubs["update_project_settings"] = self.grpc_channel.unary_unary( + self._stubs["update_project_settings"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdateProjectSettings", request_serializer=settings.UpdateProjectSettingsRequest.serialize, response_deserializer=settings.ProjectSettings.deserialize, @@ -1398,7 +1486,7 @@ def get_vpcsc_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_vpcsc_config" not in self._stubs: - self._stubs["get_vpcsc_config"] = self.grpc_channel.unary_unary( + self._stubs["get_vpcsc_config"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetVPCSCConfig", request_serializer=vpcsc_config.GetVPCSCConfigRequest.serialize, response_deserializer=vpcsc_config.VPCSCConfig.deserialize, @@ -1426,7 +1514,7 @@ def update_vpcsc_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_vpcsc_config" not in self._stubs: - self._stubs["update_vpcsc_config"] = self.grpc_channel.unary_unary( + self._stubs["update_vpcsc_config"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdateVPCSCConfig", request_serializer=gda_vpcsc_config.UpdateVPCSCConfigRequest.serialize, response_deserializer=gda_vpcsc_config.VPCSCConfig.deserialize, @@ -1452,7 +1540,7 @@ def update_package( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_package" not in self._stubs: - self._stubs["update_package"] = self.grpc_channel.unary_unary( + self._stubs["update_package"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdatePackage", request_serializer=gda_package.UpdatePackageRequest.serialize, response_deserializer=gda_package.Package.deserialize, @@ -1480,7 +1568,7 @@ def list_attachments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_attachments" not in self._stubs: - self._stubs["list_attachments"] = self.grpc_channel.unary_unary( + self._stubs["list_attachments"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/ListAttachments", request_serializer=attachment.ListAttachmentsRequest.serialize, response_deserializer=attachment.ListAttachmentsResponse.deserialize, @@ -1506,7 +1594,7 @@ def get_attachment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_attachment" not in self._stubs: - self._stubs["get_attachment"] = self.grpc_channel.unary_unary( + self._stubs["get_attachment"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetAttachment", request_serializer=attachment.GetAttachmentRequest.serialize, response_deserializer=attachment.Attachment.deserialize, @@ -1534,7 +1622,7 @@ def create_attachment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_attachment" not in self._stubs: - self._stubs["create_attachment"] = self.grpc_channel.unary_unary( + self._stubs["create_attachment"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/CreateAttachment", request_serializer=gda_attachment.CreateAttachmentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1562,7 +1650,7 @@ def delete_attachment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_attachment" not in self._stubs: - self._stubs["delete_attachment"] = self.grpc_channel.unary_unary( + self._stubs["delete_attachment"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/DeleteAttachment", request_serializer=attachment.DeleteAttachmentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1570,7 +1658,7 @@ def delete_attachment( return self._stubs["delete_attachment"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -1582,7 +1670,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, @@ -1601,7 +1689,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 +1706,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-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/transports/grpc_asyncio.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/transports/grpc_asyncio.py index 0cb0f05886c1..230dcd98a081 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/transports/grpc_asyncio.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/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.artifactregistry_v1.types import vpcsc_config as gda_vpcsc_config from google.cloud.artifactregistry_v1.types import apt_artifact, artifact @@ -53,6 +59,82 @@ from .base import DEFAULT_CLIENT_INFO, ArtifactRegistryTransport from .grpc import ArtifactRegistryGrpcTransport +try: + from google.api_core import client_logging # 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.artifactregistry.v1.ArtifactRegistry", + "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.artifactregistry.v1.ArtifactRegistry", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ArtifactRegistryGrpcAsyncIOTransport(ArtifactRegistryTransport): """gRPC AsyncIO backend transport for ArtifactRegistry. @@ -262,10 +344,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientAIOInterceptor() + self._grpc_channel._unary_unary_interceptors.append(self._interceptor) + self._logged_channel = self._grpc_channel self._wrap_with_kind = ( "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters ) + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @property @@ -288,7 +373,7 @@ def 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. @@ -315,7 +400,7 @@ def list_docker_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_docker_images" not in self._stubs: - self._stubs["list_docker_images"] = self.grpc_channel.unary_unary( + self._stubs["list_docker_images"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/ListDockerImages", request_serializer=artifact.ListDockerImagesRequest.serialize, response_deserializer=artifact.ListDockerImagesResponse.deserialize, @@ -341,7 +426,7 @@ def get_docker_image( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_docker_image" not in self._stubs: - self._stubs["get_docker_image"] = self.grpc_channel.unary_unary( + self._stubs["get_docker_image"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetDockerImage", request_serializer=artifact.GetDockerImageRequest.serialize, response_deserializer=artifact.DockerImage.deserialize, @@ -370,7 +455,7 @@ def list_maven_artifacts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_maven_artifacts" not in self._stubs: - self._stubs["list_maven_artifacts"] = self.grpc_channel.unary_unary( + self._stubs["list_maven_artifacts"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/ListMavenArtifacts", request_serializer=artifact.ListMavenArtifactsRequest.serialize, response_deserializer=artifact.ListMavenArtifactsResponse.deserialize, @@ -398,7 +483,7 @@ def get_maven_artifact( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_maven_artifact" not in self._stubs: - self._stubs["get_maven_artifact"] = self.grpc_channel.unary_unary( + self._stubs["get_maven_artifact"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetMavenArtifact", request_serializer=artifact.GetMavenArtifactRequest.serialize, response_deserializer=artifact.MavenArtifact.deserialize, @@ -426,7 +511,7 @@ def list_npm_packages( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_npm_packages" not in self._stubs: - self._stubs["list_npm_packages"] = self.grpc_channel.unary_unary( + self._stubs["list_npm_packages"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/ListNpmPackages", request_serializer=artifact.ListNpmPackagesRequest.serialize, response_deserializer=artifact.ListNpmPackagesResponse.deserialize, @@ -452,7 +537,7 @@ def get_npm_package( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_npm_package" not in self._stubs: - self._stubs["get_npm_package"] = self.grpc_channel.unary_unary( + self._stubs["get_npm_package"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetNpmPackage", request_serializer=artifact.GetNpmPackageRequest.serialize, response_deserializer=artifact.NpmPackage.deserialize, @@ -481,7 +566,7 @@ def list_python_packages( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_python_packages" not in self._stubs: - self._stubs["list_python_packages"] = self.grpc_channel.unary_unary( + self._stubs["list_python_packages"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/ListPythonPackages", request_serializer=artifact.ListPythonPackagesRequest.serialize, response_deserializer=artifact.ListPythonPackagesResponse.deserialize, @@ -509,7 +594,7 @@ def get_python_package( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_python_package" not in self._stubs: - self._stubs["get_python_package"] = self.grpc_channel.unary_unary( + self._stubs["get_python_package"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetPythonPackage", request_serializer=artifact.GetPythonPackageRequest.serialize, response_deserializer=artifact.PythonPackage.deserialize, @@ -541,7 +626,7 @@ def import_apt_artifacts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_apt_artifacts" not in self._stubs: - self._stubs["import_apt_artifacts"] = self.grpc_channel.unary_unary( + self._stubs["import_apt_artifacts"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/ImportAptArtifacts", request_serializer=apt_artifact.ImportAptArtifactsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -573,7 +658,7 @@ def import_yum_artifacts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_yum_artifacts" not in self._stubs: - self._stubs["import_yum_artifacts"] = self.grpc_channel.unary_unary( + self._stubs["import_yum_artifacts"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/ImportYumArtifacts", request_serializer=yum_artifact.ImportYumArtifactsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -602,7 +687,7 @@ def list_repositories( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_repositories" not in self._stubs: - self._stubs["list_repositories"] = self.grpc_channel.unary_unary( + self._stubs["list_repositories"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/ListRepositories", request_serializer=repository.ListRepositoriesRequest.serialize, response_deserializer=repository.ListRepositoriesResponse.deserialize, @@ -628,7 +713,7 @@ def get_repository( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_repository" not in self._stubs: - self._stubs["get_repository"] = self.grpc_channel.unary_unary( + self._stubs["get_repository"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetRepository", request_serializer=repository.GetRepositoryRequest.serialize, response_deserializer=repository.Repository.deserialize, @@ -658,7 +743,7 @@ def create_repository( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_repository" not in self._stubs: - self._stubs["create_repository"] = self.grpc_channel.unary_unary( + self._stubs["create_repository"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/CreateRepository", request_serializer=gda_repository.CreateRepositoryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -686,7 +771,7 @@ def update_repository( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_repository" not in self._stubs: - self._stubs["update_repository"] = self.grpc_channel.unary_unary( + self._stubs["update_repository"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdateRepository", request_serializer=gda_repository.UpdateRepositoryRequest.serialize, response_deserializer=gda_repository.Repository.deserialize, @@ -717,7 +802,7 @@ def delete_repository( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_repository" not in self._stubs: - self._stubs["delete_repository"] = self.grpc_channel.unary_unary( + self._stubs["delete_repository"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/DeleteRepository", request_serializer=repository.DeleteRepositoryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -745,7 +830,7 @@ def list_packages( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_packages" not in self._stubs: - self._stubs["list_packages"] = self.grpc_channel.unary_unary( + self._stubs["list_packages"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/ListPackages", request_serializer=package.ListPackagesRequest.serialize, response_deserializer=package.ListPackagesResponse.deserialize, @@ -771,7 +856,7 @@ def get_package( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_package" not in self._stubs: - self._stubs["get_package"] = self.grpc_channel.unary_unary( + self._stubs["get_package"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetPackage", request_serializer=package.GetPackageRequest.serialize, response_deserializer=package.Package.deserialize, @@ -799,7 +884,7 @@ def delete_package( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_package" not in self._stubs: - self._stubs["delete_package"] = self.grpc_channel.unary_unary( + self._stubs["delete_package"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/DeletePackage", request_serializer=package.DeletePackageRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -827,7 +912,7 @@ def list_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_versions" not in self._stubs: - self._stubs["list_versions"] = self.grpc_channel.unary_unary( + self._stubs["list_versions"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/ListVersions", request_serializer=version.ListVersionsRequest.serialize, response_deserializer=version.ListVersionsResponse.deserialize, @@ -853,7 +938,7 @@ def get_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_version" not in self._stubs: - self._stubs["get_version"] = self.grpc_channel.unary_unary( + self._stubs["get_version"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetVersion", request_serializer=version.GetVersionRequest.serialize, response_deserializer=version.Version.deserialize, @@ -881,7 +966,7 @@ def delete_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_version" not in self._stubs: - self._stubs["delete_version"] = self.grpc_channel.unary_unary( + self._stubs["delete_version"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/DeleteVersion", request_serializer=version.DeleteVersionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -911,7 +996,7 @@ def batch_delete_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_delete_versions" not in self._stubs: - self._stubs["batch_delete_versions"] = self.grpc_channel.unary_unary( + self._stubs["batch_delete_versions"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/BatchDeleteVersions", request_serializer=version.BatchDeleteVersionsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -937,7 +1022,7 @@ def update_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_version" not in self._stubs: - self._stubs["update_version"] = self.grpc_channel.unary_unary( + self._stubs["update_version"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdateVersion", request_serializer=gda_version.UpdateVersionRequest.serialize, response_deserializer=gda_version.Version.deserialize, @@ -963,7 +1048,7 @@ def list_files( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_files" not in self._stubs: - self._stubs["list_files"] = self.grpc_channel.unary_unary( + self._stubs["list_files"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/ListFiles", request_serializer=file.ListFilesRequest.serialize, response_deserializer=file.ListFilesResponse.deserialize, @@ -987,7 +1072,7 @@ def get_file(self) -> Callable[[file.GetFileRequest], Awaitable[file.File]]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_file" not in self._stubs: - self._stubs["get_file"] = self.grpc_channel.unary_unary( + self._stubs["get_file"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetFile", request_serializer=file.GetFileRequest.serialize, response_deserializer=file.File.deserialize, @@ -1015,7 +1100,7 @@ def delete_file( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_file" not in self._stubs: - self._stubs["delete_file"] = self.grpc_channel.unary_unary( + self._stubs["delete_file"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/DeleteFile", request_serializer=file.DeleteFileRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1041,7 +1126,7 @@ def update_file( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_file" not in self._stubs: - self._stubs["update_file"] = self.grpc_channel.unary_unary( + self._stubs["update_file"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdateFile", request_serializer=gda_file.UpdateFileRequest.serialize, response_deserializer=gda_file.File.deserialize, @@ -1067,7 +1152,7 @@ def list_tags( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_tags" not in self._stubs: - self._stubs["list_tags"] = self.grpc_channel.unary_unary( + self._stubs["list_tags"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/ListTags", request_serializer=tag.ListTagsRequest.serialize, response_deserializer=tag.ListTagsResponse.deserialize, @@ -1091,7 +1176,7 @@ def get_tag(self) -> Callable[[tag.GetTagRequest], Awaitable[tag.Tag]]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_tag" not in self._stubs: - self._stubs["get_tag"] = self.grpc_channel.unary_unary( + self._stubs["get_tag"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetTag", request_serializer=tag.GetTagRequest.serialize, response_deserializer=tag.Tag.deserialize, @@ -1117,7 +1202,7 @@ def create_tag( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_tag" not in self._stubs: - self._stubs["create_tag"] = self.grpc_channel.unary_unary( + self._stubs["create_tag"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/CreateTag", request_serializer=gda_tag.CreateTagRequest.serialize, response_deserializer=gda_tag.Tag.deserialize, @@ -1143,7 +1228,7 @@ def update_tag( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_tag" not in self._stubs: - self._stubs["update_tag"] = self.grpc_channel.unary_unary( + self._stubs["update_tag"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdateTag", request_serializer=gda_tag.UpdateTagRequest.serialize, response_deserializer=gda_tag.Tag.deserialize, @@ -1169,7 +1254,7 @@ def delete_tag( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_tag" not in self._stubs: - self._stubs["delete_tag"] = self.grpc_channel.unary_unary( + self._stubs["delete_tag"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/DeleteTag", request_serializer=tag.DeleteTagRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1195,7 +1280,7 @@ def create_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_rule" not in self._stubs: - self._stubs["create_rule"] = self.grpc_channel.unary_unary( + self._stubs["create_rule"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/CreateRule", request_serializer=gda_rule.CreateRuleRequest.serialize, response_deserializer=gda_rule.Rule.deserialize, @@ -1221,7 +1306,7 @@ def list_rules( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_rules" not in self._stubs: - self._stubs["list_rules"] = self.grpc_channel.unary_unary( + self._stubs["list_rules"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/ListRules", request_serializer=rule.ListRulesRequest.serialize, response_deserializer=rule.ListRulesResponse.deserialize, @@ -1245,7 +1330,7 @@ def get_rule(self) -> Callable[[rule.GetRuleRequest], Awaitable[rule.Rule]]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_rule" not in self._stubs: - self._stubs["get_rule"] = self.grpc_channel.unary_unary( + self._stubs["get_rule"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetRule", request_serializer=rule.GetRuleRequest.serialize, response_deserializer=rule.Rule.deserialize, @@ -1271,7 +1356,7 @@ def update_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_rule" not in self._stubs: - self._stubs["update_rule"] = self.grpc_channel.unary_unary( + self._stubs["update_rule"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdateRule", request_serializer=gda_rule.UpdateRuleRequest.serialize, response_deserializer=gda_rule.Rule.deserialize, @@ -1297,7 +1382,7 @@ def delete_rule( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_rule" not in self._stubs: - self._stubs["delete_rule"] = self.grpc_channel.unary_unary( + self._stubs["delete_rule"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/DeleteRule", request_serializer=rule.DeleteRuleRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1323,7 +1408,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.devtools.artifactregistry.v1.ArtifactRegistry/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -1349,7 +1434,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.devtools.artifactregistry.v1.ArtifactRegistry/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -1379,7 +1464,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.devtools.artifactregistry.v1.ArtifactRegistry/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -1407,7 +1492,7 @@ def get_project_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_project_settings" not in self._stubs: - self._stubs["get_project_settings"] = self.grpc_channel.unary_unary( + self._stubs["get_project_settings"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetProjectSettings", request_serializer=settings.GetProjectSettingsRequest.serialize, response_deserializer=settings.ProjectSettings.deserialize, @@ -1435,7 +1520,7 @@ def update_project_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_project_settings" not in self._stubs: - self._stubs["update_project_settings"] = self.grpc_channel.unary_unary( + self._stubs["update_project_settings"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdateProjectSettings", request_serializer=settings.UpdateProjectSettingsRequest.serialize, response_deserializer=settings.ProjectSettings.deserialize, @@ -1463,7 +1548,7 @@ def get_vpcsc_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_vpcsc_config" not in self._stubs: - self._stubs["get_vpcsc_config"] = self.grpc_channel.unary_unary( + self._stubs["get_vpcsc_config"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetVPCSCConfig", request_serializer=vpcsc_config.GetVPCSCConfigRequest.serialize, response_deserializer=vpcsc_config.VPCSCConfig.deserialize, @@ -1492,7 +1577,7 @@ def update_vpcsc_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_vpcsc_config" not in self._stubs: - self._stubs["update_vpcsc_config"] = self.grpc_channel.unary_unary( + self._stubs["update_vpcsc_config"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdateVPCSCConfig", request_serializer=gda_vpcsc_config.UpdateVPCSCConfigRequest.serialize, response_deserializer=gda_vpcsc_config.VPCSCConfig.deserialize, @@ -1518,7 +1603,7 @@ def update_package( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_package" not in self._stubs: - self._stubs["update_package"] = self.grpc_channel.unary_unary( + self._stubs["update_package"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/UpdatePackage", request_serializer=gda_package.UpdatePackageRequest.serialize, response_deserializer=gda_package.Package.deserialize, @@ -1547,7 +1632,7 @@ def list_attachments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_attachments" not in self._stubs: - self._stubs["list_attachments"] = self.grpc_channel.unary_unary( + self._stubs["list_attachments"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/ListAttachments", request_serializer=attachment.ListAttachmentsRequest.serialize, response_deserializer=attachment.ListAttachmentsResponse.deserialize, @@ -1573,7 +1658,7 @@ def get_attachment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_attachment" not in self._stubs: - self._stubs["get_attachment"] = self.grpc_channel.unary_unary( + self._stubs["get_attachment"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/GetAttachment", request_serializer=attachment.GetAttachmentRequest.serialize, response_deserializer=attachment.Attachment.deserialize, @@ -1603,7 +1688,7 @@ def create_attachment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_attachment" not in self._stubs: - self._stubs["create_attachment"] = self.grpc_channel.unary_unary( + self._stubs["create_attachment"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/CreateAttachment", request_serializer=gda_attachment.CreateAttachmentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1633,7 +1718,7 @@ def delete_attachment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_attachment" not in self._stubs: - self._stubs["delete_attachment"] = self.grpc_channel.unary_unary( + self._stubs["delete_attachment"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1.ArtifactRegistry/DeleteAttachment", request_serializer=attachment.DeleteAttachmentRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1911,7 +1996,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: @@ -1927,7 +2012,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, @@ -1946,7 +2031,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, @@ -1963,7 +2048,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-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/transports/rest.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/transports/rest.py index b7b5058680eb..c6f825e20696 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/transports/rest.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1/services/artifact_registry/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 @@ -60,6 +60,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, @@ -476,8 +484,10 @@ def post_update_vpcsc_config(self, response): def pre_batch_delete_versions( self, request: version.BatchDeleteVersionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[version.BatchDeleteVersionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + version.BatchDeleteVersionsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for batch_delete_versions Override in a subclass to manipulate the request or metadata @@ -499,8 +509,10 @@ def post_batch_delete_versions( def pre_create_attachment( self, request: gda_attachment.CreateAttachmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gda_attachment.CreateAttachmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gda_attachment.CreateAttachmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_attachment Override in a subclass to manipulate the request or metadata @@ -522,8 +534,10 @@ def post_create_attachment( def pre_create_repository( self, request: gda_repository.CreateRepositoryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gda_repository.CreateRepositoryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gda_repository.CreateRepositoryRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_repository Override in a subclass to manipulate the request or metadata @@ -543,8 +557,10 @@ def post_create_repository( return response def pre_create_rule( - self, request: gda_rule.CreateRuleRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[gda_rule.CreateRuleRequest, Sequence[Tuple[str, str]]]: + self, + request: gda_rule.CreateRuleRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[gda_rule.CreateRuleRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_rule Override in a subclass to manipulate the request or metadata @@ -562,8 +578,10 @@ def post_create_rule(self, response: gda_rule.Rule) -> gda_rule.Rule: return response def pre_create_tag( - self, request: gda_tag.CreateTagRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[gda_tag.CreateTagRequest, Sequence[Tuple[str, str]]]: + self, + request: gda_tag.CreateTagRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[gda_tag.CreateTagRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_tag Override in a subclass to manipulate the request or metadata @@ -583,8 +601,10 @@ def post_create_tag(self, response: gda_tag.Tag) -> gda_tag.Tag: def pre_delete_attachment( self, request: attachment.DeleteAttachmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[attachment.DeleteAttachmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + attachment.DeleteAttachmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_attachment Override in a subclass to manipulate the request or metadata @@ -604,8 +624,10 @@ def post_delete_attachment( return response def pre_delete_file( - self, request: file.DeleteFileRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[file.DeleteFileRequest, Sequence[Tuple[str, str]]]: + self, + request: file.DeleteFileRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[file.DeleteFileRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_file Override in a subclass to manipulate the request or metadata @@ -625,8 +647,10 @@ def post_delete_file( return response def pre_delete_package( - self, request: package.DeletePackageRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[package.DeletePackageRequest, Sequence[Tuple[str, str]]]: + self, + request: package.DeletePackageRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[package.DeletePackageRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_package Override in a subclass to manipulate the request or metadata @@ -648,8 +672,10 @@ def post_delete_package( def pre_delete_repository( self, request: repository.DeleteRepositoryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[repository.DeleteRepositoryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + repository.DeleteRepositoryRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_repository Override in a subclass to manipulate the request or metadata @@ -669,8 +695,10 @@ def post_delete_repository( return response def pre_delete_rule( - self, request: rule.DeleteRuleRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[rule.DeleteRuleRequest, Sequence[Tuple[str, str]]]: + self, + request: rule.DeleteRuleRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[rule.DeleteRuleRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_rule Override in a subclass to manipulate the request or metadata @@ -679,8 +707,10 @@ def pre_delete_rule( return request, metadata def pre_delete_tag( - self, request: tag.DeleteTagRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[tag.DeleteTagRequest, Sequence[Tuple[str, str]]]: + self, + request: tag.DeleteTagRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[tag.DeleteTagRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_tag Override in a subclass to manipulate the request or metadata @@ -689,8 +719,10 @@ def pre_delete_tag( return request, metadata def pre_delete_version( - self, request: version.DeleteVersionRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[version.DeleteVersionRequest, Sequence[Tuple[str, str]]]: + self, + request: version.DeleteVersionRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[version.DeleteVersionRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_version Override in a subclass to manipulate the request or metadata @@ -712,8 +744,10 @@ def post_delete_version( def pre_get_attachment( self, request: attachment.GetAttachmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[attachment.GetAttachmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + attachment.GetAttachmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_attachment Override in a subclass to manipulate the request or metadata @@ -735,8 +769,8 @@ def post_get_attachment( def pre_get_docker_image( self, request: artifact.GetDockerImageRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[artifact.GetDockerImageRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[artifact.GetDockerImageRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_docker_image Override in a subclass to manipulate the request or metadata @@ -756,8 +790,10 @@ def post_get_docker_image( return response def pre_get_file( - self, request: file.GetFileRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[file.GetFileRequest, Sequence[Tuple[str, str]]]: + self, + request: file.GetFileRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[file.GetFileRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_file Override in a subclass to manipulate the request or metadata @@ -777,8 +813,10 @@ def post_get_file(self, response: file.File) -> file.File: 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 @@ -798,8 +836,10 @@ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_get_maven_artifact( self, request: artifact.GetMavenArtifactRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[artifact.GetMavenArtifactRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + artifact.GetMavenArtifactRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_maven_artifact Override in a subclass to manipulate the request or metadata @@ -821,8 +861,8 @@ def post_get_maven_artifact( def pre_get_npm_package( self, request: artifact.GetNpmPackageRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[artifact.GetNpmPackageRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[artifact.GetNpmPackageRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_npm_package Override in a subclass to manipulate the request or metadata @@ -842,8 +882,10 @@ def post_get_npm_package( return response def pre_get_package( - self, request: package.GetPackageRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[package.GetPackageRequest, Sequence[Tuple[str, str]]]: + self, + request: package.GetPackageRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[package.GetPackageRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_package Override in a subclass to manipulate the request or metadata @@ -863,8 +905,10 @@ def post_get_package(self, response: package.Package) -> package.Package: def pre_get_project_settings( self, request: settings.GetProjectSettingsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[settings.GetProjectSettingsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + settings.GetProjectSettingsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_project_settings Override in a subclass to manipulate the request or metadata @@ -886,8 +930,10 @@ def post_get_project_settings( def pre_get_python_package( self, request: artifact.GetPythonPackageRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[artifact.GetPythonPackageRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + artifact.GetPythonPackageRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_python_package Override in a subclass to manipulate the request or metadata @@ -909,8 +955,10 @@ def post_get_python_package( def pre_get_repository( self, request: repository.GetRepositoryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[repository.GetRepositoryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + repository.GetRepositoryRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_repository Override in a subclass to manipulate the request or metadata @@ -930,8 +978,10 @@ def post_get_repository( return response def pre_get_rule( - self, request: rule.GetRuleRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[rule.GetRuleRequest, Sequence[Tuple[str, str]]]: + self, + request: rule.GetRuleRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[rule.GetRuleRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_rule Override in a subclass to manipulate the request or metadata @@ -949,8 +999,10 @@ def post_get_rule(self, response: rule.Rule) -> rule.Rule: return response def pre_get_tag( - self, request: tag.GetTagRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[tag.GetTagRequest, Sequence[Tuple[str, str]]]: + self, + request: tag.GetTagRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[tag.GetTagRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_tag Override in a subclass to manipulate the request or metadata @@ -968,8 +1020,10 @@ def post_get_tag(self, response: tag.Tag) -> tag.Tag: return response def pre_get_version( - self, request: version.GetVersionRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[version.GetVersionRequest, Sequence[Tuple[str, str]]]: + self, + request: version.GetVersionRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[version.GetVersionRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_version Override in a subclass to manipulate the request or metadata @@ -989,8 +1043,10 @@ def post_get_version(self, response: version.Version) -> version.Version: def pre_get_vpcsc_config( self, request: vpcsc_config.GetVPCSCConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[vpcsc_config.GetVPCSCConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + vpcsc_config.GetVPCSCConfigRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_vpcsc_config Override in a subclass to manipulate the request or metadata @@ -1012,8 +1068,10 @@ def post_get_vpcsc_config( def pre_import_apt_artifacts( self, request: apt_artifact.ImportAptArtifactsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apt_artifact.ImportAptArtifactsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apt_artifact.ImportAptArtifactsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for import_apt_artifacts Override in a subclass to manipulate the request or metadata @@ -1035,8 +1093,10 @@ def post_import_apt_artifacts( def pre_import_yum_artifacts( self, request: yum_artifact.ImportYumArtifactsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[yum_artifact.ImportYumArtifactsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + yum_artifact.ImportYumArtifactsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for import_yum_artifacts Override in a subclass to manipulate the request or metadata @@ -1058,8 +1118,10 @@ def post_import_yum_artifacts( def pre_list_attachments( self, request: attachment.ListAttachmentsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[attachment.ListAttachmentsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + attachment.ListAttachmentsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_attachments Override in a subclass to manipulate the request or metadata @@ -1081,8 +1143,10 @@ def post_list_attachments( def pre_list_docker_images( self, request: artifact.ListDockerImagesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[artifact.ListDockerImagesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + artifact.ListDockerImagesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_docker_images Override in a subclass to manipulate the request or metadata @@ -1102,8 +1166,10 @@ def post_list_docker_images( return response def pre_list_files( - self, request: file.ListFilesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[file.ListFilesRequest, Sequence[Tuple[str, str]]]: + self, + request: file.ListFilesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[file.ListFilesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_files Override in a subclass to manipulate the request or metadata @@ -1125,8 +1191,10 @@ def post_list_files( def pre_list_maven_artifacts( self, request: artifact.ListMavenArtifactsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[artifact.ListMavenArtifactsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + artifact.ListMavenArtifactsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_maven_artifacts Override in a subclass to manipulate the request or metadata @@ -1148,8 +1216,10 @@ def post_list_maven_artifacts( def pre_list_npm_packages( self, request: artifact.ListNpmPackagesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[artifact.ListNpmPackagesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + artifact.ListNpmPackagesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_npm_packages Override in a subclass to manipulate the request or metadata @@ -1169,8 +1239,10 @@ def post_list_npm_packages( return response def pre_list_packages( - self, request: package.ListPackagesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[package.ListPackagesRequest, Sequence[Tuple[str, str]]]: + self, + request: package.ListPackagesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[package.ListPackagesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_packages Override in a subclass to manipulate the request or metadata @@ -1192,8 +1264,10 @@ def post_list_packages( def pre_list_python_packages( self, request: artifact.ListPythonPackagesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[artifact.ListPythonPackagesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + artifact.ListPythonPackagesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_python_packages Override in a subclass to manipulate the request or metadata @@ -1215,8 +1289,10 @@ def post_list_python_packages( def pre_list_repositories( self, request: repository.ListRepositoriesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[repository.ListRepositoriesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + repository.ListRepositoriesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_repositories Override in a subclass to manipulate the request or metadata @@ -1236,8 +1312,10 @@ def post_list_repositories( return response def pre_list_rules( - self, request: rule.ListRulesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[rule.ListRulesRequest, Sequence[Tuple[str, str]]]: + self, + request: rule.ListRulesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[rule.ListRulesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_rules Override in a subclass to manipulate the request or metadata @@ -1257,8 +1335,10 @@ def post_list_rules( return response def pre_list_tags( - self, request: tag.ListTagsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[tag.ListTagsRequest, Sequence[Tuple[str, str]]]: + self, + request: tag.ListTagsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[tag.ListTagsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_tags Override in a subclass to manipulate the request or metadata @@ -1276,8 +1356,10 @@ def post_list_tags(self, response: tag.ListTagsResponse) -> tag.ListTagsResponse return response def pre_list_versions( - self, request: version.ListVersionsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[version.ListVersionsRequest, Sequence[Tuple[str, str]]]: + self, + request: version.ListVersionsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[version.ListVersionsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_versions Override in a subclass to manipulate the request or metadata @@ -1299,8 +1381,10 @@ def post_list_versions( 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 @@ -1320,8 +1404,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 @@ -1341,8 +1428,10 @@ def post_test_iam_permissions( return response def pre_update_file( - self, request: gda_file.UpdateFileRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[gda_file.UpdateFileRequest, Sequence[Tuple[str, str]]]: + self, + request: gda_file.UpdateFileRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[gda_file.UpdateFileRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_file Override in a subclass to manipulate the request or metadata @@ -1362,8 +1451,10 @@ def post_update_file(self, response: gda_file.File) -> gda_file.File: def pre_update_package( self, request: gda_package.UpdatePackageRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gda_package.UpdatePackageRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gda_package.UpdatePackageRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_package Override in a subclass to manipulate the request or metadata @@ -1383,8 +1474,10 @@ def post_update_package(self, response: gda_package.Package) -> gda_package.Pack def pre_update_project_settings( self, request: settings.UpdateProjectSettingsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[settings.UpdateProjectSettingsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + settings.UpdateProjectSettingsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_project_settings Override in a subclass to manipulate the request or metadata @@ -1406,8 +1499,10 @@ def post_update_project_settings( def pre_update_repository( self, request: gda_repository.UpdateRepositoryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gda_repository.UpdateRepositoryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gda_repository.UpdateRepositoryRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_repository Override in a subclass to manipulate the request or metadata @@ -1427,8 +1522,10 @@ def post_update_repository( return response def pre_update_rule( - self, request: gda_rule.UpdateRuleRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[gda_rule.UpdateRuleRequest, Sequence[Tuple[str, str]]]: + self, + request: gda_rule.UpdateRuleRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[gda_rule.UpdateRuleRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_rule Override in a subclass to manipulate the request or metadata @@ -1446,8 +1543,10 @@ def post_update_rule(self, response: gda_rule.Rule) -> gda_rule.Rule: return response def pre_update_tag( - self, request: gda_tag.UpdateTagRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[gda_tag.UpdateTagRequest, Sequence[Tuple[str, str]]]: + self, + request: gda_tag.UpdateTagRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[gda_tag.UpdateTagRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_tag Override in a subclass to manipulate the request or metadata @@ -1467,8 +1566,10 @@ def post_update_tag(self, response: gda_tag.Tag) -> gda_tag.Tag: def pre_update_version( self, request: gda_version.UpdateVersionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gda_version.UpdateVersionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gda_version.UpdateVersionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_version Override in a subclass to manipulate the request or metadata @@ -1488,8 +1589,11 @@ def post_update_version(self, response: gda_version.Version) -> gda_version.Vers def pre_update_vpcsc_config( self, request: gda_vpcsc_config.UpdateVPCSCConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gda_vpcsc_config.UpdateVPCSCConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gda_vpcsc_config.UpdateVPCSCConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_vpcsc_config Override in a subclass to manipulate the request or metadata @@ -1511,8 +1615,10 @@ def post_update_vpcsc_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 @@ -1534,8 +1640,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 @@ -1557,8 +1665,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 @@ -1747,7 +1857,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the batch delete versions method over HTTP. @@ -1758,8 +1868,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1772,6 +1884,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseBatchDeleteVersions._get_http_options() ) + request, metadata = self._interceptor.pre_batch_delete_versions( request, metadata ) @@ -1788,6 +1901,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.artifactregistry_v1.ArtifactRegistryClient.BatchDeleteVersions", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "BatchDeleteVersions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._BatchDeleteVersions._get_response( self._host, @@ -1807,7 +1947,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_delete_versions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.devtools.artifactregistry_v1.ArtifactRegistryClient.batch_delete_versions", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "BatchDeleteVersions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateAttachment( @@ -1846,7 +2008,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 attachment method over HTTP. @@ -1857,8 +2019,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1871,6 +2035,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseCreateAttachment._get_http_options() ) + request, metadata = self._interceptor.pre_create_attachment( request, metadata ) @@ -1887,6 +2052,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.devtools.artifactregistry_v1.ArtifactRegistryClient.CreateAttachment", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "CreateAttachment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._CreateAttachment._get_response( self._host, @@ -1906,7 +2098,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_attachment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.devtools.artifactregistry_v1.ArtifactRegistryClient.create_attachment", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "CreateAttachment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateRepository( @@ -1945,7 +2159,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create repository method over HTTP. @@ -1956,8 +2170,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1970,6 +2186,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseCreateRepository._get_http_options() ) + request, metadata = self._interceptor.pre_create_repository( request, metadata ) @@ -1986,6 +2203,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.artifactregistry_v1.ArtifactRegistryClient.CreateRepository", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "CreateRepository", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._CreateRepository._get_response( self._host, @@ -2005,7 +2249,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_repository(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.devtools.artifactregistry_v1.ArtifactRegistryClient.create_repository", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "CreateRepository", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateRule( @@ -2043,7 +2309,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gda_rule.Rule: r"""Call the create rule method over HTTP. @@ -2053,8 +2319,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gda_rule.Rule: @@ -2070,6 +2338,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseCreateRule._get_http_options() ) + request, metadata = self._interceptor.pre_create_rule(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseCreateRule._get_transcoded_request( http_options, request @@ -2084,6 +2353,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.devtools.artifactregistry_v1.ArtifactRegistryClient.CreateRule", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "CreateRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._CreateRule._get_response( self._host, @@ -2105,7 +2401,29 @@ def __call__( pb_resp = gda_rule.Rule.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gda_rule.Rule.to_json(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.artifactregistry_v1.ArtifactRegistryClient.create_rule", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "CreateRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateTag( @@ -2143,7 +2461,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gda_tag.Tag: r"""Call the create tag method over HTTP. @@ -2153,8 +2471,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gda_tag.Tag: @@ -2167,6 +2487,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseCreateTag._get_http_options() ) + request, metadata = self._interceptor.pre_create_tag(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseCreateTag._get_transcoded_request( http_options, request @@ -2181,6 +2502,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1.ArtifactRegistryClient.CreateTag", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "CreateTag", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._CreateTag._get_response( self._host, @@ -2202,7 +2550,29 @@ def __call__( pb_resp = gda_tag.Tag.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_tag(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gda_tag.Tag.to_json(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.artifactregistry_v1.ArtifactRegistryClient.create_tag", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "CreateTag", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteAttachment( @@ -2240,7 +2610,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete attachment method over HTTP. @@ -2250,8 +2620,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2264,6 +2636,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseDeleteAttachment._get_http_options() ) + request, metadata = self._interceptor.pre_delete_attachment( request, metadata ) @@ -2276,6 +2649,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.artifactregistry_v1.ArtifactRegistryClient.DeleteAttachment", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "DeleteAttachment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._DeleteAttachment._get_response( self._host, @@ -2294,7 +2694,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_attachment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.devtools.artifactregistry_v1.ArtifactRegistryClient.delete_attachment", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "DeleteAttachment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteFile( @@ -2331,7 +2753,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete file method over HTTP. @@ -2341,8 +2763,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2355,6 +2779,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseDeleteFile._get_http_options() ) + request, metadata = self._interceptor.pre_delete_file(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseDeleteFile._get_transcoded_request( http_options, request @@ -2365,6 +2790,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.artifactregistry_v1.ArtifactRegistryClient.DeleteFile", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "DeleteFile", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._DeleteFile._get_response( self._host, @@ -2383,7 +2835,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_file(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.devtools.artifactregistry_v1.ArtifactRegistryClient.delete_file", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "DeleteFile", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeletePackage( @@ -2420,7 +2894,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 package method over HTTP. @@ -2430,8 +2904,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2444,6 +2920,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseDeletePackage._get_http_options() ) + request, metadata = self._interceptor.pre_delete_package(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseDeletePackage._get_transcoded_request( http_options, request @@ -2454,6 +2931,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.artifactregistry_v1.ArtifactRegistryClient.DeletePackage", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "DeletePackage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._DeletePackage._get_response( self._host, @@ -2472,7 +2976,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_package(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.devtools.artifactregistry_v1.ArtifactRegistryClient.delete_package", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "DeletePackage", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteRepository( @@ -2510,7 +3036,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete repository method over HTTP. @@ -2520,8 +3046,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2534,6 +3062,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseDeleteRepository._get_http_options() ) + request, metadata = self._interceptor.pre_delete_repository( request, metadata ) @@ -2546,6 +3075,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.artifactregistry_v1.ArtifactRegistryClient.DeleteRepository", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "DeleteRepository", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._DeleteRepository._get_response( self._host, @@ -2564,7 +3120,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_repository(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.devtools.artifactregistry_v1.ArtifactRegistryClient.delete_repository", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "DeleteRepository", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteRule( @@ -2601,7 +3179,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete rule method over HTTP. @@ -2611,13 +3189,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 = ( _BaseArtifactRegistryRestTransport._BaseDeleteRule._get_http_options() ) + request, metadata = self._interceptor.pre_delete_rule(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseDeleteRule._get_transcoded_request( http_options, request @@ -2628,6 +3209,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.artifactregistry_v1.ArtifactRegistryClient.DeleteRule", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "DeleteRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._DeleteRule._get_response( self._host, @@ -2677,7 +3285,7 @@ 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 tag method over HTTP. @@ -2687,13 +3295,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 = ( _BaseArtifactRegistryRestTransport._BaseDeleteTag._get_http_options() ) + request, metadata = self._interceptor.pre_delete_tag(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseDeleteTag._get_transcoded_request( http_options, request @@ -2704,6 +3315,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.artifactregistry_v1.ArtifactRegistryClient.DeleteTag", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "DeleteTag", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._DeleteTag._get_response( self._host, @@ -2753,7 +3391,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 version method over HTTP. @@ -2763,8 +3401,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2777,6 +3417,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseDeleteVersion._get_http_options() ) + request, metadata = self._interceptor.pre_delete_version(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseDeleteVersion._get_transcoded_request( http_options, request @@ -2787,6 +3428,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.artifactregistry_v1.ArtifactRegistryClient.DeleteVersion", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "DeleteVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._DeleteVersion._get_response( self._host, @@ -2805,7 +3473,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_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.devtools.artifactregistry_v1.ArtifactRegistryClient.delete_version", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "DeleteVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAttachment( @@ -2842,7 +3532,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> attachment.Attachment: r"""Call the get attachment method over HTTP. @@ -2853,8 +3543,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.attachment.Attachment: @@ -2869,6 +3561,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseGetAttachment._get_http_options() ) + request, metadata = self._interceptor.pre_get_attachment(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetAttachment._get_transcoded_request( http_options, request @@ -2879,6 +3572,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.devtools.artifactregistry_v1.ArtifactRegistryClient.GetAttachment", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "GetAttachment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._GetAttachment._get_response( self._host, @@ -2899,7 +3619,29 @@ def __call__( pb_resp = attachment.Attachment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_attachment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = attachment.Attachment.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.devtools.artifactregistry_v1.ArtifactRegistryClient.get_attachment", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "GetAttachment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDockerImage( @@ -2936,7 +3678,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> artifact.DockerImage: r"""Call the get docker image method over HTTP. @@ -2946,8 +3688,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.artifact.DockerImage: @@ -2965,6 +3709,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseGetDockerImage._get_http_options() ) + request, metadata = self._interceptor.pre_get_docker_image( request, metadata ) @@ -2977,6 +3722,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1.ArtifactRegistryClient.GetDockerImage", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "GetDockerImage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._GetDockerImage._get_response( self._host, @@ -2997,7 +3769,29 @@ def __call__( pb_resp = artifact.DockerImage.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_docker_image(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = artifact.DockerImage.to_json(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.artifactregistry_v1.ArtifactRegistryClient.get_docker_image", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "GetDockerImage", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetFile( @@ -3034,7 +3828,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> file.File: r"""Call the get file method over HTTP. @@ -3044,8 +3838,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.file.File: @@ -3058,6 +3854,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseGetFile._get_http_options() ) + request, metadata = self._interceptor.pre_get_file(request, metadata) transcoded_request = ( _BaseArtifactRegistryRestTransport._BaseGetFile._get_transcoded_request( @@ -3072,6 +3869,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1.ArtifactRegistryClient.GetFile", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "GetFile", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._GetFile._get_response( self._host, @@ -3092,7 +3916,29 @@ def __call__( pb_resp = file.File.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_file(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = file.File.to_json(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.artifactregistry_v1.ArtifactRegistryClient.get_file", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "GetFile", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy( @@ -3129,7 +3975,7 @@ 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. @@ -3139,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: ~.policy_pb2.Policy: @@ -3225,6 +4073,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -3235,6 +4084,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.artifactregistry_v1.ArtifactRegistryClient.GetIamPolicy", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._GetIamPolicy._get_response( self._host, @@ -3255,7 +4131,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_iam_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.devtools.artifactregistry_v1.ArtifactRegistryClient.get_iam_policy", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetMavenArtifact( @@ -3293,7 +4191,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> artifact.MavenArtifact: r"""Call the get maven artifact method over HTTP. @@ -3303,8 +4201,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.artifact.MavenArtifact: @@ -3316,6 +4216,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseGetMavenArtifact._get_http_options() ) + request, metadata = self._interceptor.pre_get_maven_artifact( request, metadata ) @@ -3328,6 +4229,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1.ArtifactRegistryClient.GetMavenArtifact", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "GetMavenArtifact", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._GetMavenArtifact._get_response( self._host, @@ -3348,7 +4276,29 @@ def __call__( pb_resp = artifact.MavenArtifact.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_maven_artifact(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = artifact.MavenArtifact.to_json(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.artifactregistry_v1.ArtifactRegistryClient.get_maven_artifact", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "GetMavenArtifact", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetNpmPackage( @@ -3385,7 +4335,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> artifact.NpmPackage: r"""Call the get npm package method over HTTP. @@ -3395,8 +4345,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.artifact.NpmPackage: @@ -3408,6 +4360,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseGetNpmPackage._get_http_options() ) + request, metadata = self._interceptor.pre_get_npm_package(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetNpmPackage._get_transcoded_request( http_options, request @@ -3418,6 +4371,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1.ArtifactRegistryClient.GetNpmPackage", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "GetNpmPackage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._GetNpmPackage._get_response( self._host, @@ -3438,7 +4418,29 @@ def __call__( pb_resp = artifact.NpmPackage.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_npm_package(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = artifact.NpmPackage.to_json(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.artifactregistry_v1.ArtifactRegistryClient.get_npm_package", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "GetNpmPackage", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetPackage( @@ -3475,7 +4477,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> package.Package: r"""Call the get package method over HTTP. @@ -3485,8 +4487,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.package.Package: @@ -3498,6 +4502,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseGetPackage._get_http_options() ) + request, metadata = self._interceptor.pre_get_package(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetPackage._get_transcoded_request( http_options, request @@ -3508,6 +4513,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1.ArtifactRegistryClient.GetPackage", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "GetPackage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._GetPackage._get_response( self._host, @@ -3528,7 +4560,29 @@ def __call__( pb_resp = package.Package.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_package(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = package.Package.to_json(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.artifactregistry_v1.ArtifactRegistryClient.get_package", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "GetPackage", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetProjectSettings( @@ -3566,7 +4620,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> settings.ProjectSettings: r"""Call the get project settings method over HTTP. @@ -3577,8 +4631,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.settings.ProjectSettings: @@ -3590,6 +4646,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseGetProjectSettings._get_http_options() ) + request, metadata = self._interceptor.pre_get_project_settings( request, metadata ) @@ -3602,6 +4659,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1.ArtifactRegistryClient.GetProjectSettings", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "GetProjectSettings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._GetProjectSettings._get_response( self._host, @@ -3622,7 +4706,29 @@ def __call__( pb_resp = settings.ProjectSettings.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_project_settings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = settings.ProjectSettings.to_json(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.artifactregistry_v1.ArtifactRegistryClient.get_project_settings", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "GetProjectSettings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetPythonPackage( @@ -3660,7 +4766,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> artifact.PythonPackage: r"""Call the get python package method over HTTP. @@ -3670,8 +4776,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.artifact.PythonPackage: @@ -3683,6 +4791,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseGetPythonPackage._get_http_options() ) + request, metadata = self._interceptor.pre_get_python_package( request, metadata ) @@ -3695,6 +4804,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1.ArtifactRegistryClient.GetPythonPackage", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "GetPythonPackage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._GetPythonPackage._get_response( self._host, @@ -3715,7 +4851,29 @@ def __call__( pb_resp = artifact.PythonPackage.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_python_package(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = artifact.PythonPackage.to_json(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.artifactregistry_v1.ArtifactRegistryClient.get_python_package", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "GetPythonPackage", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetRepository( @@ -3752,7 +4910,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> repository.Repository: r"""Call the get repository method over HTTP. @@ -3762,8 +4920,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.repository.Repository: @@ -3775,6 +4935,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseGetRepository._get_http_options() ) + request, metadata = self._interceptor.pre_get_repository(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetRepository._get_transcoded_request( http_options, request @@ -3785,6 +4946,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1.ArtifactRegistryClient.GetRepository", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "GetRepository", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._GetRepository._get_response( self._host, @@ -3805,7 +4993,29 @@ def __call__( pb_resp = repository.Repository.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_repository(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = repository.Repository.to_json(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.artifactregistry_v1.ArtifactRegistryClient.get_repository", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "GetRepository", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetRule( @@ -3842,7 +5052,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> rule.Rule: r"""Call the get rule method over HTTP. @@ -3852,8 +5062,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.rule.Rule: @@ -3869,6 +5081,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseGetRule._get_http_options() ) + request, metadata = self._interceptor.pre_get_rule(request, metadata) transcoded_request = ( _BaseArtifactRegistryRestTransport._BaseGetRule._get_transcoded_request( @@ -3883,6 +5096,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1.ArtifactRegistryClient.GetRule", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "GetRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._GetRule._get_response( self._host, @@ -3903,7 +5143,29 @@ def __call__( pb_resp = rule.Rule.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = rule.Rule.to_json(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.artifactregistry_v1.ArtifactRegistryClient.get_rule", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "GetRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetTag( @@ -3940,7 +5202,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tag.Tag: r"""Call the get tag method over HTTP. @@ -3950,8 +5212,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.tag.Tag: @@ -3964,6 +5228,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseGetTag._get_http_options() ) + request, metadata = self._interceptor.pre_get_tag(request, metadata) transcoded_request = ( _BaseArtifactRegistryRestTransport._BaseGetTag._get_transcoded_request( @@ -3978,6 +5243,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1.ArtifactRegistryClient.GetTag", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "GetTag", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._GetTag._get_response( self._host, @@ -3998,7 +5290,29 @@ def __call__( pb_resp = tag.Tag.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_tag(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = tag.Tag.to_json(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.artifactregistry_v1.ArtifactRegistryClient.get_tag", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "GetTag", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetVersion( @@ -4035,7 +5349,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> version.Version: r"""Call the get version method over HTTP. @@ -4045,8 +5359,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.version.Version: @@ -4061,6 +5377,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseGetVersion._get_http_options() ) + request, metadata = self._interceptor.pre_get_version(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetVersion._get_transcoded_request( http_options, request @@ -4071,6 +5388,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1.ArtifactRegistryClient.GetVersion", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "GetVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._GetVersion._get_response( self._host, @@ -4091,7 +5435,29 @@ def __call__( pb_resp = version.Version.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = version.Version.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.devtools.artifactregistry_v1.ArtifactRegistryClient.get_version", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "GetVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetVPCSCConfig( @@ -4128,7 +5494,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> vpcsc_config.VPCSCConfig: r"""Call the get vpcsc config method over HTTP. @@ -4138,8 +5504,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.vpcsc_config.VPCSCConfig: @@ -4151,6 +5519,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseGetVPCSCConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_vpcsc_config( request, metadata ) @@ -4163,6 +5532,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1.ArtifactRegistryClient.GetVPCSCConfig", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "GetVPCSCConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._GetVPCSCConfig._get_response( self._host, @@ -4183,7 +5579,29 @@ def __call__( pb_resp = vpcsc_config.VPCSCConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_vpcsc_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = vpcsc_config.VPCSCConfig.to_json(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.artifactregistry_v1.ArtifactRegistryClient.get_vpcsc_config", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "GetVPCSCConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportAptArtifacts( @@ -4222,7 +5640,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 apt artifacts method over HTTP. @@ -4233,8 +5651,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -4247,6 +5667,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseImportAptArtifacts._get_http_options() ) + request, metadata = self._interceptor.pre_import_apt_artifacts( request, metadata ) @@ -4263,6 +5684,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.artifactregistry_v1.ArtifactRegistryClient.ImportAptArtifacts", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "ImportAptArtifacts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._ImportAptArtifacts._get_response( self._host, @@ -4282,7 +5730,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_apt_artifacts(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.devtools.artifactregistry_v1.ArtifactRegistryClient.import_apt_artifacts", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "ImportAptArtifacts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportYumArtifacts( @@ -4321,7 +5791,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 yum artifacts method over HTTP. @@ -4332,8 +5802,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -4346,6 +5818,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseImportYumArtifacts._get_http_options() ) + request, metadata = self._interceptor.pre_import_yum_artifacts( request, metadata ) @@ -4362,6 +5835,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.artifactregistry_v1.ArtifactRegistryClient.ImportYumArtifacts", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "ImportYumArtifacts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._ImportYumArtifacts._get_response( self._host, @@ -4381,7 +5881,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_yum_artifacts(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.devtools.artifactregistry_v1.ArtifactRegistryClient.import_yum_artifacts", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "ImportYumArtifacts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAttachments( @@ -4419,7 +5941,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> attachment.ListAttachmentsResponse: r"""Call the list attachments method over HTTP. @@ -4429,8 +5951,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.attachment.ListAttachmentsResponse: @@ -4442,6 +5966,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseListAttachments._get_http_options() ) + request, metadata = self._interceptor.pre_list_attachments( request, metadata ) @@ -4454,6 +5979,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1.ArtifactRegistryClient.ListAttachments", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "ListAttachments", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._ListAttachments._get_response( self._host, @@ -4474,7 +6026,31 @@ def __call__( pb_resp = attachment.ListAttachmentsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_attachments(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = attachment.ListAttachmentsResponse.to_json( + 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.artifactregistry_v1.ArtifactRegistryClient.list_attachments", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "ListAttachments", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDockerImages( @@ -4512,7 +6088,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> artifact.ListDockerImagesResponse: r"""Call the list docker images method over HTTP. @@ -4522,8 +6098,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.artifact.ListDockerImagesResponse: @@ -4535,6 +6113,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseListDockerImages._get_http_options() ) + request, metadata = self._interceptor.pre_list_docker_images( request, metadata ) @@ -4547,6 +6126,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1.ArtifactRegistryClient.ListDockerImages", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "ListDockerImages", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._ListDockerImages._get_response( self._host, @@ -4567,7 +6173,31 @@ def __call__( pb_resp = artifact.ListDockerImagesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_docker_images(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = artifact.ListDockerImagesResponse.to_json( + 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.artifactregistry_v1.ArtifactRegistryClient.list_docker_images", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "ListDockerImages", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListFiles( @@ -4604,7 +6234,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> file.ListFilesResponse: r"""Call the list files method over HTTP. @@ -4614,8 +6244,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.file.ListFilesResponse: @@ -4625,6 +6257,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseListFiles._get_http_options() ) + request, metadata = self._interceptor.pre_list_files(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseListFiles._get_transcoded_request( http_options, request @@ -4635,6 +6268,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1.ArtifactRegistryClient.ListFiles", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "ListFiles", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._ListFiles._get_response( self._host, @@ -4655,7 +6315,29 @@ def __call__( pb_resp = file.ListFilesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_files(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = file.ListFilesResponse.to_json(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.artifactregistry_v1.ArtifactRegistryClient.list_files", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "ListFiles", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListMavenArtifacts( @@ -4693,7 +6375,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> artifact.ListMavenArtifactsResponse: r"""Call the list maven artifacts method over HTTP. @@ -4703,8 +6385,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.artifact.ListMavenArtifactsResponse: @@ -4716,6 +6400,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseListMavenArtifacts._get_http_options() ) + request, metadata = self._interceptor.pre_list_maven_artifacts( request, metadata ) @@ -4728,6 +6413,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1.ArtifactRegistryClient.ListMavenArtifacts", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "ListMavenArtifacts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._ListMavenArtifacts._get_response( self._host, @@ -4748,7 +6460,31 @@ def __call__( pb_resp = artifact.ListMavenArtifactsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_maven_artifacts(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = artifact.ListMavenArtifactsResponse.to_json( + 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.artifactregistry_v1.ArtifactRegistryClient.list_maven_artifacts", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "ListMavenArtifacts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListNpmPackages( @@ -4786,7 +6522,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> artifact.ListNpmPackagesResponse: r"""Call the list npm packages method over HTTP. @@ -4796,8 +6532,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.artifact.ListNpmPackagesResponse: @@ -4809,6 +6547,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseListNpmPackages._get_http_options() ) + request, metadata = self._interceptor.pre_list_npm_packages( request, metadata ) @@ -4821,6 +6560,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1.ArtifactRegistryClient.ListNpmPackages", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "ListNpmPackages", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._ListNpmPackages._get_response( self._host, @@ -4841,7 +6607,31 @@ def __call__( pb_resp = artifact.ListNpmPackagesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_npm_packages(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = artifact.ListNpmPackagesResponse.to_json( + 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.artifactregistry_v1.ArtifactRegistryClient.list_npm_packages", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "ListNpmPackages", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListPackages( @@ -4878,7 +6668,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> package.ListPackagesResponse: r"""Call the list packages method over HTTP. @@ -4888,8 +6678,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.package.ListPackagesResponse: @@ -4899,6 +6691,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseListPackages._get_http_options() ) + request, metadata = self._interceptor.pre_list_packages(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseListPackages._get_transcoded_request( http_options, request @@ -4909,6 +6702,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1.ArtifactRegistryClient.ListPackages", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "ListPackages", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._ListPackages._get_response( self._host, @@ -4929,7 +6749,29 @@ def __call__( pb_resp = package.ListPackagesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_packages(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = package.ListPackagesResponse.to_json(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.artifactregistry_v1.ArtifactRegistryClient.list_packages", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "ListPackages", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListPythonPackages( @@ -4967,7 +6809,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> artifact.ListPythonPackagesResponse: r"""Call the list python packages method over HTTP. @@ -4977,8 +6819,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.artifact.ListPythonPackagesResponse: @@ -4990,6 +6834,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseListPythonPackages._get_http_options() ) + request, metadata = self._interceptor.pre_list_python_packages( request, metadata ) @@ -5002,6 +6847,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1.ArtifactRegistryClient.ListPythonPackages", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "ListPythonPackages", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._ListPythonPackages._get_response( self._host, @@ -5022,7 +6894,31 @@ def __call__( pb_resp = artifact.ListPythonPackagesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_python_packages(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = artifact.ListPythonPackagesResponse.to_json( + 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.artifactregistry_v1.ArtifactRegistryClient.list_python_packages", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "ListPythonPackages", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListRepositories( @@ -5060,7 +6956,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> repository.ListRepositoriesResponse: r"""Call the list repositories method over HTTP. @@ -5070,8 +6966,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.repository.ListRepositoriesResponse: @@ -5083,6 +6981,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseListRepositories._get_http_options() ) + request, metadata = self._interceptor.pre_list_repositories( request, metadata ) @@ -5095,6 +6994,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1.ArtifactRegistryClient.ListRepositories", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "ListRepositories", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._ListRepositories._get_response( self._host, @@ -5115,7 +7041,31 @@ def __call__( pb_resp = repository.ListRepositoriesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_repositories(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = repository.ListRepositoriesResponse.to_json( + 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.artifactregistry_v1.ArtifactRegistryClient.list_repositories", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "ListRepositories", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListRules( @@ -5152,7 +7102,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> rule.ListRulesResponse: r"""Call the list rules method over HTTP. @@ -5162,8 +7112,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.rule.ListRulesResponse: @@ -5173,6 +7125,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseListRules._get_http_options() ) + request, metadata = self._interceptor.pre_list_rules(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseListRules._get_transcoded_request( http_options, request @@ -5183,6 +7136,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1.ArtifactRegistryClient.ListRules", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "ListRules", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._ListRules._get_response( self._host, @@ -5203,7 +7183,29 @@ def __call__( pb_resp = rule.ListRulesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_rules(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = rule.ListRulesResponse.to_json(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.artifactregistry_v1.ArtifactRegistryClient.list_rules", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "ListRules", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTags( @@ -5240,7 +7242,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tag.ListTagsResponse: r"""Call the list tags method over HTTP. @@ -5250,8 +7252,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.tag.ListTagsResponse: @@ -5261,6 +7265,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseListTags._get_http_options() ) + request, metadata = self._interceptor.pre_list_tags(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseListTags._get_transcoded_request( http_options, request @@ -5273,6 +7278,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1.ArtifactRegistryClient.ListTags", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "ListTags", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._ListTags._get_response( self._host, @@ -5293,7 +7325,29 @@ def __call__( pb_resp = tag.ListTagsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_tags(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = tag.ListTagsResponse.to_json(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.artifactregistry_v1.ArtifactRegistryClient.list_tags", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "ListTags", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListVersions( @@ -5330,7 +7384,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> version.ListVersionsResponse: r"""Call the list versions method over HTTP. @@ -5340,8 +7394,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.version.ListVersionsResponse: @@ -5351,6 +7407,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseListVersions._get_http_options() ) + request, metadata = self._interceptor.pre_list_versions(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseListVersions._get_transcoded_request( http_options, request @@ -5361,6 +7418,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1.ArtifactRegistryClient.ListVersions", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "ListVersions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._ListVersions._get_response( self._host, @@ -5381,7 +7465,29 @@ def __call__( pb_resp = version.ListVersionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_versions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = version.ListVersionsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.devtools.artifactregistry_v1.ArtifactRegistryClient.list_versions", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "ListVersions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -5419,7 +7525,7 @@ 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. @@ -5429,8 +7535,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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: @@ -5515,6 +7623,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -5529,6 +7638,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.artifactregistry_v1.ArtifactRegistryClient.SetIamPolicy", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._SetIamPolicy._get_response( self._host, @@ -5550,7 +7686,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_iam_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.devtools.artifactregistry_v1.ArtifactRegistryClient.set_iam_policy", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -5589,7 +7747,7 @@ 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. @@ -5599,8 +7757,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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: @@ -5610,6 +7770,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -5626,6 +7787,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.artifactregistry_v1.ArtifactRegistryClient.TestIamPermissions", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._TestIamPermissions._get_response( self._host, @@ -5647,7 +7835,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_test_iam_permissions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.devtools.artifactregistry_v1.ArtifactRegistryClient.test_iam_permissions", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateFile( @@ -5685,7 +7895,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gda_file.File: r"""Call the update file method over HTTP. @@ -5695,8 +7905,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gda_file.File: @@ -5709,6 +7921,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseUpdateFile._get_http_options() ) + request, metadata = self._interceptor.pre_update_file(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseUpdateFile._get_transcoded_request( http_options, request @@ -5723,6 +7936,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1.ArtifactRegistryClient.UpdateFile", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "UpdateFile", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._UpdateFile._get_response( self._host, @@ -5744,7 +7984,29 @@ def __call__( pb_resp = gda_file.File.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_file(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gda_file.File.to_json(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.artifactregistry_v1.ArtifactRegistryClient.update_file", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "UpdateFile", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdatePackage( @@ -5782,7 +8044,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gda_package.Package: r"""Call the update package method over HTTP. @@ -5792,8 +8054,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gda_package.Package: @@ -5805,6 +8069,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseUpdatePackage._get_http_options() ) + request, metadata = self._interceptor.pre_update_package(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseUpdatePackage._get_transcoded_request( http_options, request @@ -5819,6 +8084,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1.ArtifactRegistryClient.UpdatePackage", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "UpdatePackage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._UpdatePackage._get_response( self._host, @@ -5840,7 +8132,29 @@ def __call__( pb_resp = gda_package.Package.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_package(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gda_package.Package.to_json(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.artifactregistry_v1.ArtifactRegistryClient.update_package", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "UpdatePackage", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateProjectSettings( @@ -5879,7 +8193,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> settings.ProjectSettings: r"""Call the update project settings method over HTTP. @@ -5889,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: ~.settings.ProjectSettings: @@ -5902,6 +8218,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseUpdateProjectSettings._get_http_options() ) + request, metadata = self._interceptor.pre_update_project_settings( request, metadata ) @@ -5918,6 +8235,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1.ArtifactRegistryClient.UpdateProjectSettings", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "UpdateProjectSettings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ArtifactRegistryRestTransport._UpdateProjectSettings._get_response( @@ -5941,7 +8285,29 @@ def __call__( pb_resp = settings.ProjectSettings.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_project_settings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = settings.ProjectSettings.to_json(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.artifactregistry_v1.ArtifactRegistryClient.update_project_settings", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "UpdateProjectSettings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateRepository( @@ -5980,7 +8346,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gda_repository.Repository: r"""Call the update repository method over HTTP. @@ -5990,8 +8356,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gda_repository.Repository: @@ -6003,6 +8371,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseUpdateRepository._get_http_options() ) + request, metadata = self._interceptor.pre_update_repository( request, metadata ) @@ -6019,6 +8388,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1.ArtifactRegistryClient.UpdateRepository", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "UpdateRepository", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._UpdateRepository._get_response( self._host, @@ -6040,7 +8436,29 @@ def __call__( pb_resp = gda_repository.Repository.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_repository(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gda_repository.Repository.to_json(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.artifactregistry_v1.ArtifactRegistryClient.update_repository", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "UpdateRepository", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateRule( @@ -6078,7 +8496,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gda_rule.Rule: r"""Call the update rule method over HTTP. @@ -6088,8 +8506,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gda_rule.Rule: @@ -6105,6 +8525,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseUpdateRule._get_http_options() ) + request, metadata = self._interceptor.pre_update_rule(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseUpdateRule._get_transcoded_request( http_options, request @@ -6119,6 +8540,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1.ArtifactRegistryClient.UpdateRule", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "UpdateRule", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._UpdateRule._get_response( self._host, @@ -6140,7 +8588,29 @@ def __call__( pb_resp = gda_rule.Rule.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_rule(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gda_rule.Rule.to_json(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.artifactregistry_v1.ArtifactRegistryClient.update_rule", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "UpdateRule", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateTag( @@ -6178,7 +8648,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gda_tag.Tag: r"""Call the update tag method over HTTP. @@ -6189,8 +8659,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gda_tag.Tag: @@ -6203,6 +8675,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseUpdateTag._get_http_options() ) + request, metadata = self._interceptor.pre_update_tag(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseUpdateTag._get_transcoded_request( http_options, request @@ -6217,6 +8690,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1.ArtifactRegistryClient.UpdateTag", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "UpdateTag", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._UpdateTag._get_response( self._host, @@ -6238,7 +8738,29 @@ def __call__( pb_resp = gda_tag.Tag.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_tag(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gda_tag.Tag.to_json(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.artifactregistry_v1.ArtifactRegistryClient.update_tag", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "UpdateTag", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateVersion( @@ -6276,7 +8798,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gda_version.Version: r"""Call the update version method over HTTP. @@ -6286,8 +8808,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gda_version.Version: @@ -6302,6 +8826,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseUpdateVersion._get_http_options() ) + request, metadata = self._interceptor.pre_update_version(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseUpdateVersion._get_transcoded_request( http_options, request @@ -6316,6 +8841,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1.ArtifactRegistryClient.UpdateVersion", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "UpdateVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._UpdateVersion._get_response( self._host, @@ -6337,7 +8889,29 @@ def __call__( pb_resp = gda_version.Version.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gda_version.Version.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.devtools.artifactregistry_v1.ArtifactRegistryClient.update_version", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "UpdateVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateVPCSCConfig( @@ -6376,7 +8950,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gda_vpcsc_config.VPCSCConfig: r"""Call the update vpcsc config method over HTTP. @@ -6386,8 +8960,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gda_vpcsc_config.VPCSCConfig: @@ -6399,6 +8975,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseUpdateVPCSCConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_vpcsc_config( request, metadata ) @@ -6415,6 +8992,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1.ArtifactRegistryClient.UpdateVPCSCConfig", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "UpdateVPCSCConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._UpdateVPCSCConfig._get_response( self._host, @@ -6436,7 +9040,29 @@ def __call__( pb_resp = gda_vpcsc_config.VPCSCConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_vpcsc_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gda_vpcsc_config.VPCSCConfig.to_json(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.artifactregistry_v1.ArtifactRegistryClient.update_vpcsc_config", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "UpdateVPCSCConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -6854,7 +9480,7 @@ 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. @@ -6864,8 +9490,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -6874,6 +9502,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -6884,6 +9513,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.artifactregistry_v1.ArtifactRegistryClient.GetLocation", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._GetLocation._get_response( self._host, @@ -6903,6 +9559,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.devtools.artifactregistry_v1.ArtifactRegistryAsyncClient.GetLocation", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -6943,7 +9620,7 @@ 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. @@ -6953,8 +9630,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -6963,6 +9642,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -6973,6 +9653,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.artifactregistry_v1.ArtifactRegistryClient.ListLocations", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._ListLocations._get_response( self._host, @@ -6992,6 +9699,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.devtools.artifactregistry_v1.ArtifactRegistryAsyncClient.ListLocations", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -7032,7 +9760,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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. @@ -7042,8 +9770,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -7052,6 +9782,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -7062,6 +9793,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.artifactregistry_v1.ArtifactRegistryClient.GetOperation", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._GetOperation._get_response( self._host, @@ -7081,6 +9839,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.devtools.artifactregistry_v1.ArtifactRegistryAsyncClient.GetOperation", + extra={ + "serviceName": "google.devtools.artifactregistry.v1.ArtifactRegistry", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1beta2/gapic_version.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1beta2/gapic_version.py index 0b9427f4e8a5..558c8aab67c5 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1beta2/gapic_version.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1beta2/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-artifact-registry/google/cloud/artifactregistry_v1beta2/services/artifact_registry/async_client.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1beta2/services/artifact_registry/async_client.py index 024641d10b4a..a41fad5ebc5e 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1beta2/services/artifact_registry/async_client.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1beta2/services/artifact_registry/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, ArtifactRegistryTransport from .transports.grpc_asyncio import ArtifactRegistryGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class ArtifactRegistryAsyncClient: """The Artifact Registry API service. @@ -303,13 +313,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.devtools.artifactregistry_v1beta2.ArtifactRegistryAsyncClient`.", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "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.artifactregistry.v1beta2.ArtifactRegistry", + "credentialsType": None, + }, + ) + async def import_apt_artifacts( self, request: Optional[Union[apt_artifact.ImportAptArtifactsRequest, 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]]] = (), ) -> operation_async.AsyncOperation: r"""Imports Apt artifacts. The returned Operation will complete once the resources are imported. Package, @@ -353,8 +385,10 @@ async def sample_import_apt_artifacts(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -411,7 +445,7 @@ async def import_yum_artifacts( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 Yum (RPM) artifacts. The returned Operation will complete once the resources are imported. Package, @@ -455,8 +489,10 @@ async def sample_import_yum_artifacts(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -514,7 +550,7 @@ async def list_repositories( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListRepositoriesAsyncPager: r"""Lists repositories. @@ -559,8 +595,10 @@ async def sample_list_repositories(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1beta2.services.artifact_registry.pagers.ListRepositoriesAsyncPager: @@ -635,7 +673,7 @@ async def get_repository( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> repository.Repository: r"""Gets a repository. @@ -678,8 +716,10 @@ async def sample_get_repository(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1beta2.types.Repository: @@ -742,7 +782,7 @@ async def create_repository( repository_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 repository. The returned Operation will finish once the repository has been created. Its @@ -805,8 +845,10 @@ async def sample_create_repository(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -884,7 +926,7 @@ async def update_repository( 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]]] = (), ) -> gda_repository.Repository: r"""Updates a repository. @@ -934,8 +976,10 @@ async def sample_update_repository(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1beta2.types.Repository: @@ -1000,7 +1044,7 @@ async def delete_repository( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 repository and all of its contents. The returned Operation will finish once the repository has @@ -1050,8 +1094,10 @@ async def sample_delete_repository(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -1130,7 +1176,7 @@ async def list_packages( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPackagesAsyncPager: r"""Lists packages. @@ -1173,8 +1219,10 @@ async def sample_list_packages(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1beta2.services.artifact_registry.pagers.ListPackagesAsyncPager: @@ -1249,7 +1297,7 @@ async def get_package( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> package.Package: r"""Gets a package. @@ -1289,8 +1337,10 @@ async def sample_get_package(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1beta2.types.Package: @@ -1351,7 +1401,7 @@ async def delete_package( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 package and all of its versions and tags. The returned operation will complete once the package @@ -1397,8 +1447,10 @@ async def sample_delete_package(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -1477,7 +1529,7 @@ async def list_versions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListVersionsAsyncPager: r"""Lists versions. @@ -1520,8 +1572,10 @@ async def sample_list_versions(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1beta2.services.artifact_registry.pagers.ListVersionsAsyncPager: @@ -1596,7 +1650,7 @@ async def get_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> version.Version: r"""Gets a version @@ -1636,8 +1690,10 @@ async def sample_get_version(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1beta2.types.Version: @@ -1701,7 +1757,7 @@ async def delete_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a version and all of its content. The returned operation will complete once the version has @@ -1747,8 +1803,10 @@ async def sample_delete_version(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -1827,7 +1885,7 @@ async def list_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.ListFilesAsyncPager: r"""Lists files. @@ -1871,8 +1929,10 @@ async def sample_list_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.artifactregistry_v1beta2.services.artifact_registry.pagers.ListFilesAsyncPager: @@ -1947,7 +2007,7 @@ async def get_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]]] = (), ) -> file.File: r"""Gets a file. @@ -1987,8 +2047,10 @@ async def sample_get_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.artifactregistry_v1beta2.types.File: @@ -2048,7 +2110,7 @@ async def list_tags( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTagsAsyncPager: r"""Lists tags. @@ -2091,8 +2153,10 @@ async def sample_list_tags(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1beta2.services.artifact_registry.pagers.ListTagsAsyncPager: @@ -2167,7 +2231,7 @@ async def get_tag( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tag.Tag: r"""Gets a tag. @@ -2207,8 +2271,10 @@ async def sample_get_tag(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1beta2.types.Tag: @@ -2270,7 +2336,7 @@ async def create_tag( tag_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]]] = (), ) -> gda_tag.Tag: r"""Creates a tag. @@ -2324,8 +2390,10 @@ async def sample_create_tag(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1beta2.types.Tag: @@ -2392,7 +2460,7 @@ async def update_tag( 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]]] = (), ) -> gda_tag.Tag: r"""Updates a tag. @@ -2443,8 +2511,10 @@ async def sample_update_tag(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1beta2.types.Tag: @@ -2508,7 +2578,7 @@ async def delete_tag( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 tag. @@ -2545,8 +2615,10 @@ async def sample_delete_tag(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -2597,7 +2669,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"""Updates the IAM policy for a given resource. @@ -2634,8 +2706,10 @@ async def sample_set_iam_policy(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.iam.v1.policy_pb2.Policy: @@ -2711,7 +2785,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 policy for a given resource. @@ -2748,8 +2822,10 @@ async def sample_get_iam_policy(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.iam.v1.policy_pb2.Policy: @@ -2825,7 +2901,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 if the caller has a list of permissions on a resource. @@ -2864,8 +2940,10 @@ async def sample_test_iam_permissions(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -2912,7 +2990,7 @@ async def get_project_settings( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> settings.ProjectSettings: r"""Retrieves the Settings for the Project. @@ -2956,8 +3034,10 @@ async def sample_get_project_settings(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1beta2.types.ProjectSettings: @@ -3019,7 +3099,7 @@ async def update_project_settings( 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]]] = (), ) -> settings.ProjectSettings: r"""Updates the Settings for the Project. @@ -3066,8 +3146,10 @@ async def sample_update_project_settings(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1beta2.types.ProjectSettings: @@ -3131,7 +3213,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. @@ -3142,8 +3224,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. @@ -3184,7 +3268,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. @@ -3195,8 +3279,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-artifact-registry/google/cloud/artifactregistry_v1beta2/services/artifact_registry/client.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1beta2/services/artifact_registry/client.py index f696780b4097..c31d94a1615a 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1beta2/services/artifact_registry/client.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1beta2/services/artifact_registry/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 @@ -750,6 +760,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( @@ -816,13 +830,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.devtools.artifactregistry_v1beta2.ArtifactRegistryClient`.", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "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.artifactregistry.v1beta2.ArtifactRegistry", + "credentialsType": None, + }, + ) + def import_apt_artifacts( self, request: Optional[Union[apt_artifact.ImportAptArtifactsRequest, 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]]] = (), ) -> operation.Operation: r"""Imports Apt artifacts. The returned Operation will complete once the resources are imported. Package, @@ -866,8 +903,10 @@ def sample_import_apt_artifacts(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -922,7 +961,7 @@ def import_yum_artifacts( *, retry: OptionalRetry = gapic_v1.method.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 Yum (RPM) artifacts. The returned Operation will complete once the resources are imported. Package, @@ -966,8 +1005,10 @@ def sample_import_yum_artifacts(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -1023,7 +1064,7 @@ def list_repositories( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListRepositoriesPager: r"""Lists repositories. @@ -1068,8 +1109,10 @@ def sample_list_repositories(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1beta2.services.artifact_registry.pagers.ListRepositoriesPager: @@ -1141,7 +1184,7 @@ def get_repository( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> repository.Repository: r"""Gets a repository. @@ -1184,8 +1227,10 @@ def sample_get_repository(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1beta2.types.Repository: @@ -1245,7 +1290,7 @@ def create_repository( repository_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 repository. The returned Operation will finish once the repository has been created. Its @@ -1308,8 +1353,10 @@ def sample_create_repository(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -1384,7 +1431,7 @@ def update_repository( 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]]] = (), ) -> gda_repository.Repository: r"""Updates a repository. @@ -1434,8 +1481,10 @@ def sample_update_repository(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1beta2.types.Repository: @@ -1497,7 +1546,7 @@ def delete_repository( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 repository and all of its contents. The returned Operation will finish once the repository has @@ -1547,8 +1596,10 @@ def sample_delete_repository(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -1624,7 +1675,7 @@ def list_packages( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListPackagesPager: r"""Lists packages. @@ -1667,8 +1718,10 @@ def sample_list_packages(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1beta2.services.artifact_registry.pagers.ListPackagesPager: @@ -1740,7 +1793,7 @@ def get_package( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> package.Package: r"""Gets a package. @@ -1780,8 +1833,10 @@ def sample_get_package(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1beta2.types.Package: @@ -1839,7 +1894,7 @@ def delete_package( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 package and all of its versions and tags. The returned operation will complete once the package @@ -1885,8 +1940,10 @@ def sample_delete_package(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -1962,7 +2019,7 @@ def list_versions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListVersionsPager: r"""Lists versions. @@ -2005,8 +2062,10 @@ def sample_list_versions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1beta2.services.artifact_registry.pagers.ListVersionsPager: @@ -2078,7 +2137,7 @@ def get_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> version.Version: r"""Gets a version @@ -2118,8 +2177,10 @@ def sample_get_version(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1beta2.types.Version: @@ -2180,7 +2241,7 @@ def delete_version( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a version and all of its content. The returned operation will complete once the version has @@ -2226,8 +2287,10 @@ def sample_delete_version(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -2303,7 +2366,7 @@ def list_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.ListFilesPager: r"""Lists files. @@ -2347,8 +2410,10 @@ def sample_list_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.artifactregistry_v1beta2.services.artifact_registry.pagers.ListFilesPager: @@ -2420,7 +2485,7 @@ def get_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]]] = (), ) -> file.File: r"""Gets a file. @@ -2460,8 +2525,10 @@ def sample_get_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.artifactregistry_v1beta2.types.File: @@ -2520,7 +2587,7 @@ def list_tags( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTagsPager: r"""Lists tags. @@ -2563,8 +2630,10 @@ def sample_list_tags(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1beta2.services.artifact_registry.pagers.ListTagsPager: @@ -2636,7 +2705,7 @@ def get_tag( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tag.Tag: r"""Gets a tag. @@ -2676,8 +2745,10 @@ def sample_get_tag(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1beta2.types.Tag: @@ -2738,7 +2809,7 @@ def create_tag( tag_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]]] = (), ) -> gda_tag.Tag: r"""Creates a tag. @@ -2792,8 +2863,10 @@ def sample_create_tag(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1beta2.types.Tag: @@ -2857,7 +2930,7 @@ def update_tag( 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]]] = (), ) -> gda_tag.Tag: r"""Updates a tag. @@ -2908,8 +2981,10 @@ def sample_update_tag(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1beta2.types.Tag: @@ -2970,7 +3045,7 @@ def delete_tag( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 tag. @@ -3007,8 +3082,10 @@ def sample_delete_tag(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -3056,7 +3133,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"""Updates the IAM policy for a given resource. @@ -3093,8 +3170,10 @@ def sample_set_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.iam.v1.policy_pb2.Policy: @@ -3169,7 +3248,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 policy for a given resource. @@ -3206,8 +3285,10 @@ def sample_get_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.iam.v1.policy_pb2.Policy: @@ -3282,7 +3363,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 if the caller has a list of permissions on a resource. @@ -3321,8 +3402,10 @@ def sample_test_iam_permissions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse: @@ -3368,7 +3451,7 @@ def get_project_settings( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> settings.ProjectSettings: r"""Retrieves the Settings for the Project. @@ -3412,8 +3495,10 @@ def sample_get_project_settings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1beta2.types.ProjectSettings: @@ -3472,7 +3557,7 @@ def update_project_settings( 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]]] = (), ) -> settings.ProjectSettings: r"""Updates the Settings for the Project. @@ -3519,8 +3604,10 @@ def sample_update_project_settings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.artifactregistry_v1beta2.types.ProjectSettings: @@ -3594,7 +3681,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. @@ -3605,8 +3692,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. @@ -3647,7 +3736,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. @@ -3658,8 +3747,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-artifact-registry/google/cloud/artifactregistry_v1beta2/services/artifact_registry/pagers.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1beta2/services/artifact_registry/pagers.py index ad3dc7bd689c..7ac58f5214d8 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1beta2/services/artifact_registry/pagers.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1beta2/services/artifact_registry/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 = repository.ListRepositoriesRequest(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 = repository.ListRepositoriesRequest(request) @@ -225,7 +229,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -239,8 +243,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = package.ListPackagesRequest(request) @@ -299,7 +305,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. @@ -313,8 +319,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 = package.ListPackagesRequest(request) @@ -377,7 +385,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -391,8 +399,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = version.ListVersionsRequest(request) @@ -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 = version.ListVersionsRequest(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 = file.ListFilesRequest(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 = file.ListFilesRequest(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 = tag.ListTagsRequest(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 = tag.ListTagsRequest(request) diff --git a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/grpc.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/grpc.py index 1084ec6ab5ac..a08966dd73b6 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/grpc.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1beta2/services/artifact_registry/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.artifactregistry_v1beta2.types import apt_artifact, file, package from google.cloud.artifactregistry_v1beta2.types import repository as gda_repository @@ -37,6 +43,81 @@ from .base import DEFAULT_CLIENT_INFO, ArtifactRegistryTransport +try: + from google.api_core import client_logging # 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.artifactregistry.v1beta2.ArtifactRegistry", + "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.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ArtifactRegistryGrpcTransport(ArtifactRegistryTransport): """gRPC backend transport for ArtifactRegistry. @@ -203,7 +284,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientInterceptor() + self._logged_channel = grpc.intercept_channel( + self._grpc_channel, self._interceptor + ) + + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @classmethod @@ -267,7 +353,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 import_apt_artifacts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_apt_artifacts" not in self._stubs: - self._stubs["import_apt_artifacts"] = self.grpc_channel.unary_unary( + self._stubs["import_apt_artifacts"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/ImportAptArtifacts", request_serializer=apt_artifact.ImportAptArtifactsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -325,7 +413,7 @@ def import_yum_artifacts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_yum_artifacts" not in self._stubs: - self._stubs["import_yum_artifacts"] = self.grpc_channel.unary_unary( + self._stubs["import_yum_artifacts"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/ImportYumArtifacts", request_serializer=yum_artifact.ImportYumArtifactsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -353,7 +441,7 @@ def list_repositories( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_repositories" not in self._stubs: - self._stubs["list_repositories"] = self.grpc_channel.unary_unary( + self._stubs["list_repositories"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/ListRepositories", request_serializer=repository.ListRepositoriesRequest.serialize, response_deserializer=repository.ListRepositoriesResponse.deserialize, @@ -379,7 +467,7 @@ def get_repository( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_repository" not in self._stubs: - self._stubs["get_repository"] = self.grpc_channel.unary_unary( + self._stubs["get_repository"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/GetRepository", request_serializer=repository.GetRepositoryRequest.serialize, response_deserializer=repository.Repository.deserialize, @@ -407,7 +495,7 @@ def create_repository( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_repository" not in self._stubs: - self._stubs["create_repository"] = self.grpc_channel.unary_unary( + self._stubs["create_repository"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/CreateRepository", request_serializer=gda_repository.CreateRepositoryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -433,7 +521,7 @@ def update_repository( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_repository" not in self._stubs: - self._stubs["update_repository"] = self.grpc_channel.unary_unary( + self._stubs["update_repository"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/UpdateRepository", request_serializer=gda_repository.UpdateRepositoryRequest.serialize, response_deserializer=gda_repository.Repository.deserialize, @@ -462,7 +550,7 @@ def delete_repository( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_repository" not in self._stubs: - self._stubs["delete_repository"] = self.grpc_channel.unary_unary( + self._stubs["delete_repository"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/DeleteRepository", request_serializer=repository.DeleteRepositoryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -488,7 +576,7 @@ def list_packages( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_packages" not in self._stubs: - self._stubs["list_packages"] = self.grpc_channel.unary_unary( + self._stubs["list_packages"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/ListPackages", request_serializer=package.ListPackagesRequest.serialize, response_deserializer=package.ListPackagesResponse.deserialize, @@ -512,7 +600,7 @@ def get_package(self) -> Callable[[package.GetPackageRequest], package.Package]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_package" not in self._stubs: - self._stubs["get_package"] = self.grpc_channel.unary_unary( + self._stubs["get_package"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/GetPackage", request_serializer=package.GetPackageRequest.serialize, response_deserializer=package.Package.deserialize, @@ -540,7 +628,7 @@ def delete_package( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_package" not in self._stubs: - self._stubs["delete_package"] = self.grpc_channel.unary_unary( + self._stubs["delete_package"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/DeletePackage", request_serializer=package.DeletePackageRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -566,7 +654,7 @@ def list_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_versions" not in self._stubs: - self._stubs["list_versions"] = self.grpc_channel.unary_unary( + self._stubs["list_versions"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/ListVersions", request_serializer=version.ListVersionsRequest.serialize, response_deserializer=version.ListVersionsResponse.deserialize, @@ -590,7 +678,7 @@ def get_version(self) -> Callable[[version.GetVersionRequest], version.Version]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_version" not in self._stubs: - self._stubs["get_version"] = self.grpc_channel.unary_unary( + self._stubs["get_version"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/GetVersion", request_serializer=version.GetVersionRequest.serialize, response_deserializer=version.Version.deserialize, @@ -618,7 +706,7 @@ def delete_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_version" not in self._stubs: - self._stubs["delete_version"] = self.grpc_channel.unary_unary( + self._stubs["delete_version"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/DeleteVersion", request_serializer=version.DeleteVersionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -642,7 +730,7 @@ def list_files(self) -> Callable[[file.ListFilesRequest], file.ListFilesResponse # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_files" not in self._stubs: - self._stubs["list_files"] = self.grpc_channel.unary_unary( + self._stubs["list_files"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/ListFiles", request_serializer=file.ListFilesRequest.serialize, response_deserializer=file.ListFilesResponse.deserialize, @@ -666,7 +754,7 @@ def get_file(self) -> Callable[[file.GetFileRequest], file.File]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_file" not in self._stubs: - self._stubs["get_file"] = self.grpc_channel.unary_unary( + self._stubs["get_file"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/GetFile", request_serializer=file.GetFileRequest.serialize, response_deserializer=file.File.deserialize, @@ -690,7 +778,7 @@ def list_tags(self) -> Callable[[tag.ListTagsRequest], tag.ListTagsResponse]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_tags" not in self._stubs: - self._stubs["list_tags"] = self.grpc_channel.unary_unary( + self._stubs["list_tags"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/ListTags", request_serializer=tag.ListTagsRequest.serialize, response_deserializer=tag.ListTagsResponse.deserialize, @@ -714,7 +802,7 @@ def get_tag(self) -> Callable[[tag.GetTagRequest], tag.Tag]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_tag" not in self._stubs: - self._stubs["get_tag"] = self.grpc_channel.unary_unary( + self._stubs["get_tag"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/GetTag", request_serializer=tag.GetTagRequest.serialize, response_deserializer=tag.Tag.deserialize, @@ -738,7 +826,7 @@ def create_tag(self) -> Callable[[gda_tag.CreateTagRequest], gda_tag.Tag]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_tag" not in self._stubs: - self._stubs["create_tag"] = self.grpc_channel.unary_unary( + self._stubs["create_tag"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/CreateTag", request_serializer=gda_tag.CreateTagRequest.serialize, response_deserializer=gda_tag.Tag.deserialize, @@ -762,7 +850,7 @@ def update_tag(self) -> Callable[[gda_tag.UpdateTagRequest], gda_tag.Tag]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_tag" not in self._stubs: - self._stubs["update_tag"] = self.grpc_channel.unary_unary( + self._stubs["update_tag"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/UpdateTag", request_serializer=gda_tag.UpdateTagRequest.serialize, response_deserializer=gda_tag.Tag.deserialize, @@ -786,7 +874,7 @@ def delete_tag(self) -> Callable[[tag.DeleteTagRequest], empty_pb2.Empty]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_tag" not in self._stubs: - self._stubs["delete_tag"] = self.grpc_channel.unary_unary( + self._stubs["delete_tag"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/DeleteTag", request_serializer=tag.DeleteTagRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -812,7 +900,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.devtools.artifactregistry.v1beta2.ArtifactRegistry/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -838,7 +926,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.devtools.artifactregistry.v1beta2.ArtifactRegistry/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -868,7 +956,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.devtools.artifactregistry.v1beta2.ArtifactRegistry/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -894,7 +982,7 @@ def get_project_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_project_settings" not in self._stubs: - self._stubs["get_project_settings"] = self.grpc_channel.unary_unary( + self._stubs["get_project_settings"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/GetProjectSettings", request_serializer=settings.GetProjectSettingsRequest.serialize, response_deserializer=settings.ProjectSettings.deserialize, @@ -920,7 +1008,7 @@ def update_project_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_project_settings" not in self._stubs: - self._stubs["update_project_settings"] = self.grpc_channel.unary_unary( + self._stubs["update_project_settings"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/UpdateProjectSettings", request_serializer=settings.UpdateProjectSettingsRequest.serialize, response_deserializer=settings.ProjectSettings.deserialize, @@ -928,7 +1016,7 @@ def update_project_settings( return self._stubs["update_project_settings"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def list_locations( @@ -942,7 +1030,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, @@ -959,7 +1047,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-artifact-registry/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/grpc_asyncio.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/grpc_asyncio.py index a9f595420e08..a560e2542797 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/grpc_asyncio.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1beta2/services/artifact_registry/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.artifactregistry_v1beta2.types import apt_artifact, file, package from google.cloud.artifactregistry_v1beta2.types import repository as gda_repository @@ -41,6 +47,82 @@ from .base import DEFAULT_CLIENT_INFO, ArtifactRegistryTransport from .grpc import ArtifactRegistryGrpcTransport +try: + from google.api_core import client_logging # 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.artifactregistry.v1beta2.ArtifactRegistry", + "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.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ArtifactRegistryGrpcAsyncIOTransport(ArtifactRegistryTransport): """gRPC AsyncIO backend transport for ArtifactRegistry. @@ -250,10 +332,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 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 import_apt_artifacts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_apt_artifacts" not in self._stubs: - self._stubs["import_apt_artifacts"] = self.grpc_channel.unary_unary( + self._stubs["import_apt_artifacts"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/ImportAptArtifacts", request_serializer=apt_artifact.ImportAptArtifactsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -339,7 +424,7 @@ def import_yum_artifacts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "import_yum_artifacts" not in self._stubs: - self._stubs["import_yum_artifacts"] = self.grpc_channel.unary_unary( + self._stubs["import_yum_artifacts"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/ImportYumArtifacts", request_serializer=yum_artifact.ImportYumArtifactsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -368,7 +453,7 @@ def list_repositories( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_repositories" not in self._stubs: - self._stubs["list_repositories"] = self.grpc_channel.unary_unary( + self._stubs["list_repositories"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/ListRepositories", request_serializer=repository.ListRepositoriesRequest.serialize, response_deserializer=repository.ListRepositoriesResponse.deserialize, @@ -394,7 +479,7 @@ def get_repository( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_repository" not in self._stubs: - self._stubs["get_repository"] = self.grpc_channel.unary_unary( + self._stubs["get_repository"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/GetRepository", request_serializer=repository.GetRepositoryRequest.serialize, response_deserializer=repository.Repository.deserialize, @@ -424,7 +509,7 @@ def create_repository( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_repository" not in self._stubs: - self._stubs["create_repository"] = self.grpc_channel.unary_unary( + self._stubs["create_repository"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/CreateRepository", request_serializer=gda_repository.CreateRepositoryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -452,7 +537,7 @@ def update_repository( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_repository" not in self._stubs: - self._stubs["update_repository"] = self.grpc_channel.unary_unary( + self._stubs["update_repository"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/UpdateRepository", request_serializer=gda_repository.UpdateRepositoryRequest.serialize, response_deserializer=gda_repository.Repository.deserialize, @@ -483,7 +568,7 @@ def delete_repository( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_repository" not in self._stubs: - self._stubs["delete_repository"] = self.grpc_channel.unary_unary( + self._stubs["delete_repository"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/DeleteRepository", request_serializer=repository.DeleteRepositoryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -511,7 +596,7 @@ def list_packages( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_packages" not in self._stubs: - self._stubs["list_packages"] = self.grpc_channel.unary_unary( + self._stubs["list_packages"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/ListPackages", request_serializer=package.ListPackagesRequest.serialize, response_deserializer=package.ListPackagesResponse.deserialize, @@ -537,7 +622,7 @@ def get_package( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_package" not in self._stubs: - self._stubs["get_package"] = self.grpc_channel.unary_unary( + self._stubs["get_package"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/GetPackage", request_serializer=package.GetPackageRequest.serialize, response_deserializer=package.Package.deserialize, @@ -565,7 +650,7 @@ def delete_package( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_package" not in self._stubs: - self._stubs["delete_package"] = self.grpc_channel.unary_unary( + self._stubs["delete_package"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/DeletePackage", request_serializer=package.DeletePackageRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -593,7 +678,7 @@ def list_versions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_versions" not in self._stubs: - self._stubs["list_versions"] = self.grpc_channel.unary_unary( + self._stubs["list_versions"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/ListVersions", request_serializer=version.ListVersionsRequest.serialize, response_deserializer=version.ListVersionsResponse.deserialize, @@ -619,7 +704,7 @@ def get_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_version" not in self._stubs: - self._stubs["get_version"] = self.grpc_channel.unary_unary( + self._stubs["get_version"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/GetVersion", request_serializer=version.GetVersionRequest.serialize, response_deserializer=version.Version.deserialize, @@ -647,7 +732,7 @@ def delete_version( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_version" not in self._stubs: - self._stubs["delete_version"] = self.grpc_channel.unary_unary( + self._stubs["delete_version"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/DeleteVersion", request_serializer=version.DeleteVersionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -673,7 +758,7 @@ def list_files( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_files" not in self._stubs: - self._stubs["list_files"] = self.grpc_channel.unary_unary( + self._stubs["list_files"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/ListFiles", request_serializer=file.ListFilesRequest.serialize, response_deserializer=file.ListFilesResponse.deserialize, @@ -697,7 +782,7 @@ def get_file(self) -> Callable[[file.GetFileRequest], Awaitable[file.File]]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_file" not in self._stubs: - self._stubs["get_file"] = self.grpc_channel.unary_unary( + self._stubs["get_file"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/GetFile", request_serializer=file.GetFileRequest.serialize, response_deserializer=file.File.deserialize, @@ -723,7 +808,7 @@ def list_tags( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_tags" not in self._stubs: - self._stubs["list_tags"] = self.grpc_channel.unary_unary( + self._stubs["list_tags"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/ListTags", request_serializer=tag.ListTagsRequest.serialize, response_deserializer=tag.ListTagsResponse.deserialize, @@ -747,7 +832,7 @@ def get_tag(self) -> Callable[[tag.GetTagRequest], Awaitable[tag.Tag]]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_tag" not in self._stubs: - self._stubs["get_tag"] = self.grpc_channel.unary_unary( + self._stubs["get_tag"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/GetTag", request_serializer=tag.GetTagRequest.serialize, response_deserializer=tag.Tag.deserialize, @@ -773,7 +858,7 @@ def create_tag( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_tag" not in self._stubs: - self._stubs["create_tag"] = self.grpc_channel.unary_unary( + self._stubs["create_tag"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/CreateTag", request_serializer=gda_tag.CreateTagRequest.serialize, response_deserializer=gda_tag.Tag.deserialize, @@ -799,7 +884,7 @@ def update_tag( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_tag" not in self._stubs: - self._stubs["update_tag"] = self.grpc_channel.unary_unary( + self._stubs["update_tag"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/UpdateTag", request_serializer=gda_tag.UpdateTagRequest.serialize, response_deserializer=gda_tag.Tag.deserialize, @@ -825,7 +910,7 @@ def delete_tag( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_tag" not in self._stubs: - self._stubs["delete_tag"] = self.grpc_channel.unary_unary( + self._stubs["delete_tag"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/DeleteTag", request_serializer=tag.DeleteTagRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -851,7 +936,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.devtools.artifactregistry.v1beta2.ArtifactRegistry/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -877,7 +962,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.devtools.artifactregistry.v1beta2.ArtifactRegistry/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -907,7 +992,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.devtools.artifactregistry.v1beta2.ArtifactRegistry/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -935,7 +1020,7 @@ def get_project_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_project_settings" not in self._stubs: - self._stubs["get_project_settings"] = self.grpc_channel.unary_unary( + self._stubs["get_project_settings"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/GetProjectSettings", request_serializer=settings.GetProjectSettingsRequest.serialize, response_deserializer=settings.ProjectSettings.deserialize, @@ -963,7 +1048,7 @@ def update_project_settings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_project_settings" not in self._stubs: - self._stubs["update_project_settings"] = self.grpc_channel.unary_unary( + self._stubs["update_project_settings"] = self._logged_channel.unary_unary( "/google.devtools.artifactregistry.v1beta2.ArtifactRegistry/UpdateProjectSettings", request_serializer=settings.UpdateProjectSettingsRequest.serialize, response_deserializer=settings.ProjectSettings.deserialize, @@ -1251,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: @@ -1269,7 +1354,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, @@ -1286,7 +1371,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-artifact-registry/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/rest.py b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/rest.py index 3e2aef45dc6d..0c13932b472f 100644 --- a/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1beta2/services/artifact_registry/transports/rest.py +++ b/packages/google-cloud-artifact-registry/google/cloud/artifactregistry_v1beta2/services/artifact_registry/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 @@ -48,6 +48,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, @@ -276,8 +284,10 @@ def post_update_tag(self, response): def pre_create_repository( self, request: gda_repository.CreateRepositoryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gda_repository.CreateRepositoryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gda_repository.CreateRepositoryRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_repository Override in a subclass to manipulate the request or metadata @@ -297,8 +307,10 @@ def post_create_repository( return response def pre_create_tag( - self, request: gda_tag.CreateTagRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[gda_tag.CreateTagRequest, Sequence[Tuple[str, str]]]: + self, + request: gda_tag.CreateTagRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[gda_tag.CreateTagRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_tag Override in a subclass to manipulate the request or metadata @@ -316,8 +328,10 @@ def post_create_tag(self, response: gda_tag.Tag) -> gda_tag.Tag: return response def pre_delete_package( - self, request: package.DeletePackageRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[package.DeletePackageRequest, Sequence[Tuple[str, str]]]: + self, + request: package.DeletePackageRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[package.DeletePackageRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_package Override in a subclass to manipulate the request or metadata @@ -339,8 +353,10 @@ def post_delete_package( def pre_delete_repository( self, request: repository.DeleteRepositoryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[repository.DeleteRepositoryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + repository.DeleteRepositoryRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_repository Override in a subclass to manipulate the request or metadata @@ -360,8 +376,10 @@ def post_delete_repository( return response def pre_delete_tag( - self, request: tag.DeleteTagRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[tag.DeleteTagRequest, Sequence[Tuple[str, str]]]: + self, + request: tag.DeleteTagRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[tag.DeleteTagRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_tag Override in a subclass to manipulate the request or metadata @@ -370,8 +388,10 @@ def pre_delete_tag( return request, metadata def pre_delete_version( - self, request: version.DeleteVersionRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[version.DeleteVersionRequest, Sequence[Tuple[str, str]]]: + self, + request: version.DeleteVersionRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[version.DeleteVersionRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_version Override in a subclass to manipulate the request or metadata @@ -391,8 +411,10 @@ def post_delete_version( return response def pre_get_file( - self, request: file.GetFileRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[file.GetFileRequest, Sequence[Tuple[str, str]]]: + self, + request: file.GetFileRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[file.GetFileRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_file Override in a subclass to manipulate the request or metadata @@ -412,8 +434,10 @@ def post_get_file(self, response: file.File) -> file.File: 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 @@ -431,8 +455,10 @@ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: return response def pre_get_package( - self, request: package.GetPackageRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[package.GetPackageRequest, Sequence[Tuple[str, str]]]: + self, + request: package.GetPackageRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[package.GetPackageRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_package Override in a subclass to manipulate the request or metadata @@ -452,8 +478,10 @@ def post_get_package(self, response: package.Package) -> package.Package: def pre_get_project_settings( self, request: settings.GetProjectSettingsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[settings.GetProjectSettingsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + settings.GetProjectSettingsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_project_settings Override in a subclass to manipulate the request or metadata @@ -475,8 +503,10 @@ def post_get_project_settings( def pre_get_repository( self, request: repository.GetRepositoryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[repository.GetRepositoryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + repository.GetRepositoryRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_repository Override in a subclass to manipulate the request or metadata @@ -496,8 +526,10 @@ def post_get_repository( return response def pre_get_tag( - self, request: tag.GetTagRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[tag.GetTagRequest, Sequence[Tuple[str, str]]]: + self, + request: tag.GetTagRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[tag.GetTagRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_tag Override in a subclass to manipulate the request or metadata @@ -515,8 +547,10 @@ def post_get_tag(self, response: tag.Tag) -> tag.Tag: return response def pre_get_version( - self, request: version.GetVersionRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[version.GetVersionRequest, Sequence[Tuple[str, str]]]: + self, + request: version.GetVersionRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[version.GetVersionRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_version Override in a subclass to manipulate the request or metadata @@ -536,8 +570,10 @@ def post_get_version(self, response: version.Version) -> version.Version: def pre_import_apt_artifacts( self, request: apt_artifact.ImportAptArtifactsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[apt_artifact.ImportAptArtifactsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + apt_artifact.ImportAptArtifactsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for import_apt_artifacts Override in a subclass to manipulate the request or metadata @@ -559,8 +595,10 @@ def post_import_apt_artifacts( def pre_import_yum_artifacts( self, request: yum_artifact.ImportYumArtifactsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[yum_artifact.ImportYumArtifactsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + yum_artifact.ImportYumArtifactsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for import_yum_artifacts Override in a subclass to manipulate the request or metadata @@ -580,8 +618,10 @@ def post_import_yum_artifacts( return response def pre_list_files( - self, request: file.ListFilesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[file.ListFilesRequest, Sequence[Tuple[str, str]]]: + self, + request: file.ListFilesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[file.ListFilesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_files Override in a subclass to manipulate the request or metadata @@ -601,8 +641,10 @@ def post_list_files( return response def pre_list_packages( - self, request: package.ListPackagesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[package.ListPackagesRequest, Sequence[Tuple[str, str]]]: + self, + request: package.ListPackagesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[package.ListPackagesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_packages Override in a subclass to manipulate the request or metadata @@ -624,8 +666,10 @@ def post_list_packages( def pre_list_repositories( self, request: repository.ListRepositoriesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[repository.ListRepositoriesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + repository.ListRepositoriesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_repositories Override in a subclass to manipulate the request or metadata @@ -645,8 +689,10 @@ def post_list_repositories( return response def pre_list_tags( - self, request: tag.ListTagsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[tag.ListTagsRequest, Sequence[Tuple[str, str]]]: + self, + request: tag.ListTagsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[tag.ListTagsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_tags Override in a subclass to manipulate the request or metadata @@ -664,8 +710,10 @@ def post_list_tags(self, response: tag.ListTagsResponse) -> tag.ListTagsResponse return response def pre_list_versions( - self, request: version.ListVersionsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[version.ListVersionsRequest, Sequence[Tuple[str, str]]]: + self, + request: version.ListVersionsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[version.ListVersionsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_versions Override in a subclass to manipulate the request or metadata @@ -687,8 +735,10 @@ def post_list_versions( 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 @@ -708,8 +758,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 @@ -731,8 +784,10 @@ def post_test_iam_permissions( def pre_update_project_settings( self, request: settings.UpdateProjectSettingsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[settings.UpdateProjectSettingsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + settings.UpdateProjectSettingsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_project_settings Override in a subclass to manipulate the request or metadata @@ -754,8 +809,10 @@ def post_update_project_settings( def pre_update_repository( self, request: gda_repository.UpdateRepositoryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gda_repository.UpdateRepositoryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gda_repository.UpdateRepositoryRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_repository Override in a subclass to manipulate the request or metadata @@ -775,8 +832,10 @@ def post_update_repository( return response def pre_update_tag( - self, request: gda_tag.UpdateTagRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[gda_tag.UpdateTagRequest, Sequence[Tuple[str, str]]]: + self, + request: gda_tag.UpdateTagRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[gda_tag.UpdateTagRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_tag Override in a subclass to manipulate the request or metadata @@ -796,8 +855,10 @@ def post_update_tag(self, response: gda_tag.Tag) -> gda_tag.Tag: 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 @@ -819,8 +880,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 @@ -1009,7 +1072,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create repository method over HTTP. @@ -1020,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: ~.operations_pb2.Operation: @@ -1034,6 +1099,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseCreateRepository._get_http_options() ) + request, metadata = self._interceptor.pre_create_repository( request, metadata ) @@ -1050,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 = json_format.MessageToJson(request) + 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.artifactregistry_v1beta2.ArtifactRegistryClient.CreateRepository", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "CreateRepository", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._CreateRepository._get_response( self._host, @@ -1069,7 +1162,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_repository(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.devtools.artifactregistry_v1beta2.ArtifactRegistryClient.create_repository", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "CreateRepository", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateTag( @@ -1107,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]]] = (), ) -> gda_tag.Tag: r"""Call the create tag method over HTTP. @@ -1117,8 +1232,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gda_tag.Tag: @@ -1131,6 +1248,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseCreateTag._get_http_options() ) + request, metadata = self._interceptor.pre_create_tag(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseCreateTag._get_transcoded_request( http_options, request @@ -1145,6 +1263,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1beta2.ArtifactRegistryClient.CreateTag", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "CreateTag", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._CreateTag._get_response( self._host, @@ -1166,7 +1311,29 @@ def __call__( pb_resp = gda_tag.Tag.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_tag(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gda_tag.Tag.to_json(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.artifactregistry_v1beta2.ArtifactRegistryClient.create_tag", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "CreateTag", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeletePackage( @@ -1203,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 delete package method over HTTP. @@ -1213,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: @@ -1227,6 +1396,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseDeletePackage._get_http_options() ) + request, metadata = self._interceptor.pre_delete_package(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseDeletePackage._get_transcoded_request( http_options, request @@ -1237,6 +1407,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.artifactregistry_v1beta2.ArtifactRegistryClient.DeletePackage", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "DeletePackage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._DeletePackage._get_response( self._host, @@ -1255,7 +1452,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_package(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.devtools.artifactregistry_v1beta2.ArtifactRegistryClient.delete_package", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "DeletePackage", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteRepository( @@ -1293,7 +1512,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete repository method over HTTP. @@ -1303,8 +1522,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1317,6 +1538,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseDeleteRepository._get_http_options() ) + request, metadata = self._interceptor.pre_delete_repository( request, metadata ) @@ -1329,6 +1551,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.artifactregistry_v1beta2.ArtifactRegistryClient.DeleteRepository", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "DeleteRepository", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._DeleteRepository._get_response( self._host, @@ -1347,7 +1596,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_repository(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.devtools.artifactregistry_v1beta2.ArtifactRegistryClient.delete_repository", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "DeleteRepository", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteTag( @@ -1384,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]]] = (), ): r"""Call the delete tag method over HTTP. @@ -1394,13 +1665,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 = ( _BaseArtifactRegistryRestTransport._BaseDeleteTag._get_http_options() ) + request, metadata = self._interceptor.pre_delete_tag(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseDeleteTag._get_transcoded_request( http_options, request @@ -1411,6 +1685,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.devtools.artifactregistry_v1beta2.ArtifactRegistryClient.DeleteTag", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "DeleteTag", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._DeleteTag._get_response( self._host, @@ -1460,7 +1761,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 version method over HTTP. @@ -1470,8 +1771,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1484,6 +1787,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseDeleteVersion._get_http_options() ) + request, metadata = self._interceptor.pre_delete_version(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseDeleteVersion._get_transcoded_request( http_options, request @@ -1494,6 +1798,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.artifactregistry_v1beta2.ArtifactRegistryClient.DeleteVersion", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "DeleteVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._DeleteVersion._get_response( self._host, @@ -1512,7 +1843,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_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.devtools.artifactregistry_v1beta2.ArtifactRegistryClient.delete_version", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "DeleteVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetFile( @@ -1549,7 +1902,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> file.File: r"""Call the get file method over HTTP. @@ -1559,8 +1912,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.file.File: @@ -1573,6 +1928,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseGetFile._get_http_options() ) + request, metadata = self._interceptor.pre_get_file(request, metadata) transcoded_request = ( _BaseArtifactRegistryRestTransport._BaseGetFile._get_transcoded_request( @@ -1587,6 +1943,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1beta2.ArtifactRegistryClient.GetFile", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "GetFile", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._GetFile._get_response( self._host, @@ -1607,7 +1990,29 @@ def __call__( pb_resp = file.File.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_file(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = file.File.to_json(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.artifactregistry_v1beta2.ArtifactRegistryClient.get_file", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "GetFile", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy( @@ -1644,7 +2049,7 @@ 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. @@ -1654,8 +2059,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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: @@ -1740,6 +2147,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -1750,6 +2158,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.artifactregistry_v1beta2.ArtifactRegistryClient.GetIamPolicy", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._GetIamPolicy._get_response( self._host, @@ -1770,7 +2205,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_iam_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.devtools.artifactregistry_v1beta2.ArtifactRegistryClient.get_iam_policy", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetPackage( @@ -1807,7 +2264,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> package.Package: r"""Call the get package method over HTTP. @@ -1817,8 +2274,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.package.Package: @@ -1830,6 +2289,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseGetPackage._get_http_options() ) + request, metadata = self._interceptor.pre_get_package(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetPackage._get_transcoded_request( http_options, request @@ -1840,6 +2300,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1beta2.ArtifactRegistryClient.GetPackage", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "GetPackage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._GetPackage._get_response( self._host, @@ -1860,7 +2347,29 @@ def __call__( pb_resp = package.Package.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_package(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = package.Package.to_json(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.artifactregistry_v1beta2.ArtifactRegistryClient.get_package", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "GetPackage", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetProjectSettings( @@ -1898,7 +2407,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> settings.ProjectSettings: r"""Call the get project settings method over HTTP. @@ -1909,8 +2418,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.settings.ProjectSettings: @@ -1922,6 +2433,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseGetProjectSettings._get_http_options() ) + request, metadata = self._interceptor.pre_get_project_settings( request, metadata ) @@ -1934,6 +2446,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1beta2.ArtifactRegistryClient.GetProjectSettings", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "GetProjectSettings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._GetProjectSettings._get_response( self._host, @@ -1954,7 +2493,29 @@ def __call__( pb_resp = settings.ProjectSettings.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_project_settings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = settings.ProjectSettings.to_json(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.artifactregistry_v1beta2.ArtifactRegistryClient.get_project_settings", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "GetProjectSettings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetRepository( @@ -1991,7 +2552,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> repository.Repository: r"""Call the get repository method over HTTP. @@ -2001,8 +2562,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.repository.Repository: @@ -2014,6 +2577,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseGetRepository._get_http_options() ) + request, metadata = self._interceptor.pre_get_repository(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetRepository._get_transcoded_request( http_options, request @@ -2024,6 +2588,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1beta2.ArtifactRegistryClient.GetRepository", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "GetRepository", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._GetRepository._get_response( self._host, @@ -2044,7 +2635,29 @@ def __call__( pb_resp = repository.Repository.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_repository(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = repository.Repository.to_json(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.artifactregistry_v1beta2.ArtifactRegistryClient.get_repository", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "GetRepository", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetTag( @@ -2081,7 +2694,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> tag.Tag: r"""Call the get tag method over HTTP. @@ -2091,8 +2704,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.tag.Tag: @@ -2105,6 +2720,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseGetTag._get_http_options() ) + request, metadata = self._interceptor.pre_get_tag(request, metadata) transcoded_request = ( _BaseArtifactRegistryRestTransport._BaseGetTag._get_transcoded_request( @@ -2119,6 +2735,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1beta2.ArtifactRegistryClient.GetTag", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "GetTag", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._GetTag._get_response( self._host, @@ -2139,7 +2782,29 @@ def __call__( pb_resp = tag.Tag.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_tag(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = tag.Tag.to_json(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.artifactregistry_v1beta2.ArtifactRegistryClient.get_tag", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "GetTag", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetVersion( @@ -2176,7 +2841,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> version.Version: r"""Call the get version method over HTTP. @@ -2186,8 +2851,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.version.Version: @@ -2202,6 +2869,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseGetVersion._get_http_options() ) + request, metadata = self._interceptor.pre_get_version(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetVersion._get_transcoded_request( http_options, request @@ -2212,6 +2880,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1beta2.ArtifactRegistryClient.GetVersion", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "GetVersion", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._GetVersion._get_response( self._host, @@ -2232,7 +2927,29 @@ def __call__( pb_resp = version.Version.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_version(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = version.Version.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.devtools.artifactregistry_v1beta2.ArtifactRegistryClient.get_version", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "GetVersion", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportAptArtifacts( @@ -2271,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]]] = (), ) -> operations_pb2.Operation: r"""Call the import apt artifacts method over HTTP. @@ -2282,8 +2999,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2296,6 +3015,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseImportAptArtifacts._get_http_options() ) + request, metadata = self._interceptor.pre_import_apt_artifacts( request, metadata ) @@ -2312,6 +3032,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.artifactregistry_v1beta2.ArtifactRegistryClient.ImportAptArtifacts", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "ImportAptArtifacts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._ImportAptArtifacts._get_response( self._host, @@ -2331,7 +3078,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_apt_artifacts(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.devtools.artifactregistry_v1beta2.ArtifactRegistryClient.import_apt_artifacts", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "ImportAptArtifacts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ImportYumArtifacts( @@ -2370,7 +3139,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 yum artifacts method over HTTP. @@ -2381,8 +3150,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2395,6 +3166,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseImportYumArtifacts._get_http_options() ) + request, metadata = self._interceptor.pre_import_yum_artifacts( request, metadata ) @@ -2411,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 = json_format.MessageToJson(request) + 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.artifactregistry_v1beta2.ArtifactRegistryClient.ImportYumArtifacts", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "ImportYumArtifacts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._ImportYumArtifacts._get_response( self._host, @@ -2430,7 +3229,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_yum_artifacts(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.devtools.artifactregistry_v1beta2.ArtifactRegistryClient.import_yum_artifacts", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "ImportYumArtifacts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListFiles( @@ -2467,7 +3288,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> file.ListFilesResponse: r"""Call the list files method over HTTP. @@ -2477,8 +3298,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.file.ListFilesResponse: @@ -2488,6 +3311,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseListFiles._get_http_options() ) + request, metadata = self._interceptor.pre_list_files(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseListFiles._get_transcoded_request( http_options, request @@ -2498,6 +3322,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1beta2.ArtifactRegistryClient.ListFiles", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "ListFiles", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._ListFiles._get_response( self._host, @@ -2518,7 +3369,29 @@ def __call__( pb_resp = file.ListFilesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_files(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = file.ListFilesResponse.to_json(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.artifactregistry_v1beta2.ArtifactRegistryClient.list_files", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "ListFiles", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListPackages( @@ -2555,7 +3428,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> package.ListPackagesResponse: r"""Call the list packages method over HTTP. @@ -2565,8 +3438,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.package.ListPackagesResponse: @@ -2576,6 +3451,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseListPackages._get_http_options() ) + request, metadata = self._interceptor.pre_list_packages(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseListPackages._get_transcoded_request( http_options, request @@ -2586,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 = type(request).to_json(request) + 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.artifactregistry_v1beta2.ArtifactRegistryClient.ListPackages", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "ListPackages", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._ListPackages._get_response( self._host, @@ -2606,7 +3509,29 @@ def __call__( pb_resp = package.ListPackagesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_packages(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = package.ListPackagesResponse.to_json(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.artifactregistry_v1beta2.ArtifactRegistryClient.list_packages", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "ListPackages", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListRepositories( @@ -2644,7 +3569,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> repository.ListRepositoriesResponse: r"""Call the list repositories method over HTTP. @@ -2654,8 +3579,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.repository.ListRepositoriesResponse: @@ -2667,6 +3594,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseListRepositories._get_http_options() ) + request, metadata = self._interceptor.pre_list_repositories( request, metadata ) @@ -2679,6 +3607,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1beta2.ArtifactRegistryClient.ListRepositories", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "ListRepositories", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._ListRepositories._get_response( self._host, @@ -2699,7 +3654,31 @@ def __call__( pb_resp = repository.ListRepositoriesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_repositories(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = repository.ListRepositoriesResponse.to_json( + 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.artifactregistry_v1beta2.ArtifactRegistryClient.list_repositories", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "ListRepositories", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTags( @@ -2736,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]]] = (), ) -> tag.ListTagsResponse: r"""Call the list tags method over HTTP. @@ -2746,8 +3725,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.tag.ListTagsResponse: @@ -2757,6 +3738,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseListTags._get_http_options() ) + request, metadata = self._interceptor.pre_list_tags(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseListTags._get_transcoded_request( http_options, request @@ -2769,6 +3751,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1beta2.ArtifactRegistryClient.ListTags", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "ListTags", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._ListTags._get_response( self._host, @@ -2789,7 +3798,29 @@ def __call__( pb_resp = tag.ListTagsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_tags(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = tag.ListTagsResponse.to_json(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.artifactregistry_v1beta2.ArtifactRegistryClient.list_tags", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "ListTags", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListVersions( @@ -2826,7 +3857,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> version.ListVersionsResponse: r"""Call the list versions method over HTTP. @@ -2836,8 +3867,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.version.ListVersionsResponse: @@ -2847,6 +3880,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseListVersions._get_http_options() ) + request, metadata = self._interceptor.pre_list_versions(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseListVersions._get_transcoded_request( http_options, request @@ -2857,6 +3891,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1beta2.ArtifactRegistryClient.ListVersions", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "ListVersions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._ListVersions._get_response( self._host, @@ -2877,7 +3938,29 @@ def __call__( pb_resp = version.ListVersionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_versions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = version.ListVersionsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.devtools.artifactregistry_v1beta2.ArtifactRegistryClient.list_versions", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "ListVersions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -2915,7 +3998,7 @@ 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. @@ -2925,8 +4008,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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: @@ -3011,6 +4096,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -3025,6 +4111,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.artifactregistry_v1beta2.ArtifactRegistryClient.SetIamPolicy", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._SetIamPolicy._get_response( self._host, @@ -3046,7 +4159,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_iam_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.devtools.artifactregistry_v1beta2.ArtifactRegistryClient.set_iam_policy", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -3085,7 +4220,7 @@ 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. @@ -3095,8 +4230,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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: @@ -3106,6 +4243,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -3122,6 +4260,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.artifactregistry_v1beta2.ArtifactRegistryClient.TestIamPermissions", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._TestIamPermissions._get_response( self._host, @@ -3143,7 +4308,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_test_iam_permissions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.devtools.artifactregistry_v1beta2.ArtifactRegistryClient.test_iam_permissions", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateProjectSettings( @@ -3182,7 +4369,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> settings.ProjectSettings: r"""Call the update project settings method over HTTP. @@ -3192,8 +4379,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.settings.ProjectSettings: @@ -3205,6 +4394,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseUpdateProjectSettings._get_http_options() ) + request, metadata = self._interceptor.pre_update_project_settings( request, metadata ) @@ -3221,6 +4411,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1beta2.ArtifactRegistryClient.UpdateProjectSettings", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "UpdateProjectSettings", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ArtifactRegistryRestTransport._UpdateProjectSettings._get_response( @@ -3244,7 +4461,29 @@ def __call__( pb_resp = settings.ProjectSettings.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_project_settings(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = settings.ProjectSettings.to_json(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.artifactregistry_v1beta2.ArtifactRegistryClient.update_project_settings", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "UpdateProjectSettings", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateRepository( @@ -3283,7 +4522,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gda_repository.Repository: r"""Call the update repository method over HTTP. @@ -3293,8 +4532,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gda_repository.Repository: @@ -3306,6 +4547,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseUpdateRepository._get_http_options() ) + request, metadata = self._interceptor.pre_update_repository( request, metadata ) @@ -3322,6 +4564,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1beta2.ArtifactRegistryClient.UpdateRepository", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "UpdateRepository", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._UpdateRepository._get_response( self._host, @@ -3343,7 +4612,29 @@ def __call__( pb_resp = gda_repository.Repository.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_repository(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gda_repository.Repository.to_json(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.artifactregistry_v1beta2.ArtifactRegistryClient.update_repository", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "UpdateRepository", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateTag( @@ -3381,7 +4672,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gda_tag.Tag: r"""Call the update tag method over HTTP. @@ -3392,8 +4683,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gda_tag.Tag: @@ -3406,6 +4699,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseUpdateTag._get_http_options() ) + request, metadata = self._interceptor.pre_update_tag(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseUpdateTag._get_transcoded_request( http_options, request @@ -3420,6 +4714,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.artifactregistry_v1beta2.ArtifactRegistryClient.UpdateTag", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "UpdateTag", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._UpdateTag._get_response( self._host, @@ -3441,7 +4762,29 @@ def __call__( pb_resp = gda_tag.Tag.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_tag(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gda_tag.Tag.to_json(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.artifactregistry_v1beta2.ArtifactRegistryClient.update_tag", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "UpdateTag", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -3669,7 +5012,7 @@ 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. @@ -3679,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: locations_pb2.Location: Response from GetLocation method. @@ -3689,6 +5034,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -3699,6 +5045,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.artifactregistry_v1beta2.ArtifactRegistryClient.GetLocation", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._GetLocation._get_response( self._host, @@ -3718,6 +5091,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.devtools.artifactregistry_v1beta2.ArtifactRegistryAsyncClient.GetLocation", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -3758,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]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -3768,8 +5162,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -3778,6 +5174,7 @@ def __call__( http_options = ( _BaseArtifactRegistryRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseArtifactRegistryRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -3788,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.devtools.artifactregistry_v1beta2.ArtifactRegistryClient.ListLocations", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ArtifactRegistryRestTransport._ListLocations._get_response( self._host, @@ -3807,6 +5231,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.devtools.artifactregistry_v1beta2.ArtifactRegistryAsyncClient.ListLocations", + extra={ + "serviceName": "google.devtools.artifactregistry.v1beta2.ArtifactRegistry", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-artifact-registry/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1.json b/packages/google-cloud-artifact-registry/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1.json index 5d9aa157563e..43448eb993ec 100644 --- a/packages/google-cloud-artifact-registry/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1.json +++ b/packages/google-cloud-artifact-registry/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-artifact-registry", - "version": "1.13.1" + "version": "0.1.0" }, "snippets": [ { @@ -51,7 +51,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -224,7 +224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -312,7 +312,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -401,7 +401,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -489,7 +489,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -578,7 +578,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.Rule", @@ -666,7 +666,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.Rule", @@ -755,7 +755,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.Tag", @@ -843,7 +843,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.Tag", @@ -924,7 +924,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1004,7 +1004,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1085,7 +1085,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1165,7 +1165,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", @@ -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]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1487,7 +1487,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1568,7 +1568,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_rule" @@ -1645,7 +1645,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_rule" @@ -1723,7 +1723,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_tag" @@ -1800,7 +1800,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_tag" @@ -1878,7 +1878,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1958,7 +1958,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2039,7 +2039,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.Attachment", @@ -2119,7 +2119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.Attachment", @@ -2200,7 +2200,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.DockerImage", @@ -2280,7 +2280,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.DockerImage", @@ -2361,7 +2361,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.File", @@ -2441,7 +2441,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.File", @@ -2518,7 +2518,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -2594,7 +2594,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -2675,7 +2675,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.MavenArtifact", @@ -2755,7 +2755,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.MavenArtifact", @@ -2836,7 +2836,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.NpmPackage", @@ -2916,7 +2916,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.NpmPackage", @@ -2997,7 +2997,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.Package", @@ -3077,7 +3077,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.Package", @@ -3158,7 +3158,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.ProjectSettings", @@ -3238,7 +3238,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.ProjectSettings", @@ -3319,7 +3319,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.PythonPackage", @@ -3399,7 +3399,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.PythonPackage", @@ -3480,7 +3480,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.Repository", @@ -3560,7 +3560,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.Repository", @@ -3641,7 +3641,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.Rule", @@ -3721,7 +3721,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.Rule", @@ -3802,7 +3802,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.Tag", @@ -3882,7 +3882,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.Tag", @@ -3963,7 +3963,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.VPCSCConfig", @@ -4043,7 +4043,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.VPCSCConfig", @@ -4124,7 +4124,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.Version", @@ -4204,7 +4204,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.Version", @@ -4281,7 +4281,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4357,7 +4357,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4434,7 +4434,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4510,7 +4510,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4591,7 +4591,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListAttachmentsAsyncPager", @@ -4671,7 +4671,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListAttachmentsPager", @@ -4752,7 +4752,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListDockerImagesAsyncPager", @@ -4832,7 +4832,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListDockerImagesPager", @@ -4913,7 +4913,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListFilesAsyncPager", @@ -4993,7 +4993,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListFilesPager", @@ -5074,7 +5074,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListMavenArtifactsAsyncPager", @@ -5154,7 +5154,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListMavenArtifactsPager", @@ -5235,7 +5235,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListNpmPackagesAsyncPager", @@ -5315,7 +5315,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListNpmPackagesPager", @@ -5396,7 +5396,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListPackagesAsyncPager", @@ -5476,7 +5476,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListPackagesPager", @@ -5557,7 +5557,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListPythonPackagesAsyncPager", @@ -5637,7 +5637,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListPythonPackagesPager", @@ -5718,7 +5718,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListRepositoriesAsyncPager", @@ -5798,7 +5798,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListRepositoriesPager", @@ -5879,7 +5879,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListRulesAsyncPager", @@ -5959,7 +5959,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListRulesPager", @@ -6040,7 +6040,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListTagsAsyncPager", @@ -6120,7 +6120,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListTagsPager", @@ -6201,7 +6201,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListVersionsAsyncPager", @@ -6281,7 +6281,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.services.artifact_registry.pagers.ListVersionsPager", @@ -6358,7 +6358,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -6434,7 +6434,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -6511,7 +6511,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -6587,7 +6587,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -6672,7 +6672,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.File", @@ -6756,7 +6756,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.File", @@ -6841,7 +6841,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.Package", @@ -6925,7 +6925,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.Package", @@ -7010,7 +7010,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.ProjectSettings", @@ -7094,7 +7094,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.ProjectSettings", @@ -7179,7 +7179,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.Repository", @@ -7263,7 +7263,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.Repository", @@ -7348,7 +7348,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.Rule", @@ -7432,7 +7432,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.Rule", @@ -7517,7 +7517,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.Tag", @@ -7601,7 +7601,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.Tag", @@ -7686,7 +7686,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.VPCSCConfig", @@ -7770,7 +7770,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.VPCSCConfig", @@ -7855,7 +7855,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.Version", @@ -7939,7 +7939,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1.types.Version", diff --git a/packages/google-cloud-artifact-registry/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1beta2.json b/packages/google-cloud-artifact-registry/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1beta2.json index 191eb79f1ee3..914e581f4fb1 100644 --- a/packages/google-cloud-artifact-registry/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1beta2.json +++ b/packages/google-cloud-artifact-registry/samples/generated_samples/snippet_metadata_google.devtools.artifactregistry.v1beta2.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-artifact-registry", - "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.api_core.operation_async.AsyncOperation", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -232,7 +232,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1beta2.types.Tag", @@ -320,7 +320,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1beta2.types.Tag", @@ -401,7 +401,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -481,7 +481,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -562,7 +562,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -642,7 +642,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -723,7 +723,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_tag" @@ -800,7 +800,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_tag" @@ -878,7 +878,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -958,7 +958,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1039,7 +1039,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1beta2.types.File", @@ -1119,7 +1119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1beta2.types.File", @@ -1196,7 +1196,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -1272,7 +1272,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -1353,7 +1353,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1beta2.types.Package", @@ -1433,7 +1433,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1beta2.types.Package", @@ -1514,7 +1514,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1beta2.types.ProjectSettings", @@ -1594,7 +1594,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1beta2.types.ProjectSettings", @@ -1675,7 +1675,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1beta2.types.Repository", @@ -1755,7 +1755,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1beta2.types.Repository", @@ -1836,7 +1836,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1beta2.types.Tag", @@ -1916,7 +1916,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1beta2.types.Tag", @@ -1997,7 +1997,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1beta2.types.Version", @@ -2077,7 +2077,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1beta2.types.Version", @@ -2154,7 +2154,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2230,7 +2230,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2307,7 +2307,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2383,7 +2383,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2464,7 +2464,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1beta2.services.artifact_registry.pagers.ListFilesAsyncPager", @@ -2544,7 +2544,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1beta2.services.artifact_registry.pagers.ListFilesPager", @@ -2625,7 +2625,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1beta2.services.artifact_registry.pagers.ListPackagesAsyncPager", @@ -2705,7 +2705,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1beta2.services.artifact_registry.pagers.ListPackagesPager", @@ -2786,7 +2786,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1beta2.services.artifact_registry.pagers.ListRepositoriesAsyncPager", @@ -2866,7 +2866,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1beta2.services.artifact_registry.pagers.ListRepositoriesPager", @@ -2947,7 +2947,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1beta2.services.artifact_registry.pagers.ListTagsAsyncPager", @@ -3027,7 +3027,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1beta2.services.artifact_registry.pagers.ListTagsPager", @@ -3108,7 +3108,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1beta2.services.artifact_registry.pagers.ListVersionsAsyncPager", @@ -3188,7 +3188,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1beta2.services.artifact_registry.pagers.ListVersionsPager", @@ -3265,7 +3265,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -3341,7 +3341,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -3418,7 +3418,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -3494,7 +3494,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -3579,7 +3579,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1beta2.types.ProjectSettings", @@ -3663,7 +3663,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1beta2.types.ProjectSettings", @@ -3748,7 +3748,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1beta2.types.Repository", @@ -3832,7 +3832,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1beta2.types.Repository", @@ -3917,7 +3917,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1beta2.types.Tag", @@ -4001,7 +4001,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.artifactregistry_v1beta2.types.Tag", diff --git a/packages/google-cloud-artifact-registry/tests/unit/gapic/artifactregistry_v1/test_artifact_registry.py b/packages/google-cloud-artifact-registry/tests/unit/gapic/artifactregistry_v1/test_artifact_registry.py index 579c52851bd6..01fef8477a4a 100644 --- a/packages/google-cloud-artifact-registry/tests/unit/gapic/artifactregistry_v1/test_artifact_registry.py +++ b/packages/google-cloud-artifact-registry/tests/unit/gapic/artifactregistry_v1/test_artifact_registry.py @@ -19668,6 +19668,7 @@ def test_list_docker_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_docker_images(request) @@ -19724,6 +19725,7 @@ def test_list_docker_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_docker_images(**mock_args) @@ -19920,6 +19922,7 @@ def test_get_docker_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_docker_image(request) @@ -19967,6 +19970,7 @@ def test_get_docker_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_docker_image(**mock_args) @@ -20109,6 +20113,7 @@ def test_list_maven_artifacts_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_maven_artifacts(request) @@ -20164,6 +20169,7 @@ def test_list_maven_artifacts_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_maven_artifacts(**mock_args) @@ -20364,6 +20370,7 @@ def test_get_maven_artifact_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_maven_artifact(request) @@ -20411,6 +20418,7 @@ def test_get_maven_artifact_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_maven_artifact(**mock_args) @@ -20551,6 +20559,7 @@ def test_list_npm_packages_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_npm_packages(request) @@ -20606,6 +20615,7 @@ def test_list_npm_packages_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_npm_packages(**mock_args) @@ -20800,6 +20810,7 @@ def test_get_npm_package_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_npm_package(request) @@ -20847,6 +20858,7 @@ def test_get_npm_package_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_npm_package(**mock_args) @@ -20989,6 +21001,7 @@ def test_list_python_packages_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_python_packages(request) @@ -21044,6 +21057,7 @@ def test_list_python_packages_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_python_packages(**mock_args) @@ -21244,6 +21258,7 @@ def test_get_python_package_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_python_package(request) @@ -21291,6 +21306,7 @@ def test_get_python_package_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_python_package(**mock_args) @@ -21521,6 +21537,7 @@ def test_list_repositories_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_repositories(request) @@ -21576,6 +21593,7 @@ def test_list_repositories_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_repositories(**mock_args) @@ -21770,6 +21788,7 @@ def test_get_repository_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_repository(request) @@ -21817,6 +21836,7 @@ def test_get_repository_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_repository(**mock_args) @@ -21961,6 +21981,7 @@ def test_create_repository_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_repository(request) @@ -22025,6 +22046,7 @@ def test_create_repository_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_repository(**mock_args) @@ -22135,6 +22157,7 @@ def test_update_repository_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_repository(**mock_args) @@ -22274,6 +22297,7 @@ def test_delete_repository_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_repository(request) @@ -22319,6 +22343,7 @@ def test_delete_repository_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_repository(**mock_args) @@ -22457,6 +22482,7 @@ def test_list_packages_rest_required_fields(request_type=package.ListPackagesReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_packages(request) @@ -22514,6 +22540,7 @@ def test_list_packages_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_packages(**mock_args) @@ -22706,6 +22733,7 @@ def test_get_package_rest_required_fields(request_type=package.GetPackageRequest response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_package(request) @@ -22753,6 +22781,7 @@ def test_get_package_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_package(**mock_args) @@ -22883,6 +22912,7 @@ def test_delete_package_rest_required_fields(request_type=package.DeletePackageR response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_package(request) @@ -22928,6 +22958,7 @@ def test_delete_package_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_package(**mock_args) @@ -23023,6 +23054,7 @@ def test_list_versions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_versions(**mock_args) @@ -23181,6 +23213,7 @@ def test_get_version_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_version(**mock_args) @@ -23278,6 +23311,7 @@ def test_delete_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.delete_version(**mock_args) @@ -23416,6 +23450,7 @@ def test_batch_delete_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.batch_delete_versions(request) @@ -23462,6 +23497,7 @@ def test_batch_delete_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.batch_delete_versions(**mock_args) @@ -23592,6 +23628,7 @@ def test_update_version_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_version(request) @@ -23642,6 +23679,7 @@ def test_update_version_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_version(**mock_args) @@ -23781,6 +23819,7 @@ def test_list_files_rest_required_fields(request_type=file.ListFilesRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_files(request) @@ -23838,6 +23877,7 @@ def test_list_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_files(**mock_args) @@ -24030,6 +24070,7 @@ def test_get_file_rest_required_fields(request_type=file.GetFileRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_file(request) @@ -24077,6 +24118,7 @@ def test_get_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_file(**mock_args) @@ -24207,6 +24249,7 @@ def test_delete_file_rest_required_fields(request_type=file.DeleteFileRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_file(request) @@ -24252,6 +24295,7 @@ def test_delete_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.delete_file(**mock_args) @@ -24379,6 +24423,7 @@ def test_update_file_rest_required_fields(request_type=gda_file.UpdateFileReques response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_file(request) @@ -24437,6 +24482,7 @@ def test_update_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.update_file(**mock_args) @@ -24533,6 +24579,7 @@ def test_list_tags_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_tags(**mock_args) @@ -24691,6 +24738,7 @@ def test_get_tag_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_tag(**mock_args) @@ -24788,6 +24836,7 @@ def test_create_tag_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_tag(**mock_args) @@ -24888,6 +24937,7 @@ def test_update_tag_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_tag(**mock_args) @@ -24982,6 +25032,7 @@ def test_delete_tag_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_tag(**mock_args) @@ -25114,6 +25165,7 @@ def test_create_rule_rest_required_fields(request_type=gda_rule.CreateRuleReques response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_rule(request) @@ -25163,6 +25215,7 @@ def test_create_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_rule(**mock_args) @@ -25301,6 +25354,7 @@ def test_list_rules_rest_required_fields(request_type=rule.ListRulesRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_rules(request) @@ -25356,6 +25410,7 @@ def test_list_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_rules(**mock_args) @@ -25548,6 +25603,7 @@ def test_get_rule_rest_required_fields(request_type=rule.GetRuleRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_rule(request) @@ -25595,6 +25651,7 @@ def test_get_rule_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_rule(**mock_args) @@ -25693,6 +25750,7 @@ def test_update_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_rule(**mock_args) @@ -25820,6 +25878,7 @@ def test_delete_rule_rest_required_fields(request_type=rule.DeleteRuleRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_rule(request) @@ -25865,6 +25924,7 @@ def test_delete_rule_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_rule(**mock_args) @@ -25995,6 +26055,7 @@ def test_set_iam_policy_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.set_iam_policy(request) @@ -26122,6 +26183,7 @@ def test_get_iam_policy_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_iam_policy(request) @@ -26248,6 +26310,7 @@ def test_test_iam_permissions_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.test_iam_permissions(request) @@ -26379,6 +26442,7 @@ def test_get_project_settings_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_project_settings(request) @@ -26424,6 +26488,7 @@ def test_get_project_settings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_project_settings(**mock_args) @@ -26523,6 +26588,7 @@ def test_update_project_settings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_project_settings(**mock_args) @@ -26657,6 +26723,7 @@ def test_get_vpcsc_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_vpcsc_config(request) @@ -26702,6 +26769,7 @@ def test_get_vpcsc_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_vpcsc_config(**mock_args) @@ -26801,6 +26869,7 @@ def test_update_vpcsc_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_vpcsc_config(**mock_args) @@ -26900,6 +26969,7 @@ def test_update_package_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_package(**mock_args) @@ -27042,6 +27112,7 @@ def test_list_attachments_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_attachments(request) @@ -27098,6 +27169,7 @@ def test_list_attachments_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_attachments(**mock_args) @@ -27294,6 +27366,7 @@ def test_get_attachment_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_attachment(request) @@ -27341,6 +27414,7 @@ def test_get_attachment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_attachment(**mock_args) @@ -27485,6 +27559,7 @@ def test_create_attachment_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_attachment(request) @@ -27547,6 +27622,7 @@ def test_create_attachment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_attachment(**mock_args) @@ -27683,6 +27759,7 @@ def test_delete_attachment_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_attachment(request) @@ -27728,6 +27805,7 @@ def test_delete_attachment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_attachment(**mock_args) @@ -30370,6 +30448,7 @@ def test_list_docker_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_docker_images(request) @@ -30405,6 +30484,7 @@ def test_list_docker_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_docker_images(request) # Establish that the response is the type that we expect. @@ -30445,6 +30525,7 @@ def test_list_docker_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 = artifact.ListDockerImagesResponse.to_json( artifact.ListDockerImagesResponse() ) @@ -30491,6 +30572,7 @@ def test_get_docker_image_rest_bad_request(request_type=artifact.GetDockerImageR response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_docker_image(request) @@ -30532,6 +30614,7 @@ def test_get_docker_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_docker_image(request) # Establish that the response is the type that we expect. @@ -30574,6 +30657,7 @@ def test_get_docker_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 = artifact.DockerImage.to_json(artifact.DockerImage()) req.return_value.content = return_value @@ -30618,6 +30702,7 @@ def test_list_maven_artifacts_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_maven_artifacts(request) @@ -30653,6 +30738,7 @@ def test_list_maven_artifacts_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_maven_artifacts(request) # Establish that the response is the type that we expect. @@ -30693,6 +30779,7 @@ def test_list_maven_artifacts_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = artifact.ListMavenArtifactsResponse.to_json( artifact.ListMavenArtifactsResponse() ) @@ -30741,6 +30828,7 @@ def test_get_maven_artifact_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_maven_artifact(request) @@ -30782,6 +30870,7 @@ def test_get_maven_artifact_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_maven_artifact(request) # Establish that the response is the type that we expect. @@ -30826,6 +30915,7 @@ def test_get_maven_artifact_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = artifact.MavenArtifact.to_json(artifact.MavenArtifact()) req.return_value.content = return_value @@ -30870,6 +30960,7 @@ def test_list_npm_packages_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_npm_packages(request) @@ -30905,6 +30996,7 @@ def test_list_npm_packages_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_npm_packages(request) # Establish that the response is the type that we expect. @@ -30945,6 +31037,7 @@ def test_list_npm_packages_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = artifact.ListNpmPackagesResponse.to_json( artifact.ListNpmPackagesResponse() ) @@ -30991,6 +31084,7 @@ def test_get_npm_package_rest_bad_request(request_type=artifact.GetNpmPackageReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_npm_package(request) @@ -31031,6 +31125,7 @@ def test_get_npm_package_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_npm_package(request) # Establish that the response is the type that we expect. @@ -31072,6 +31167,7 @@ def test_get_npm_package_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = artifact.NpmPackage.to_json(artifact.NpmPackage()) req.return_value.content = return_value @@ -31116,6 +31212,7 @@ def test_list_python_packages_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_python_packages(request) @@ -31151,6 +31248,7 @@ def test_list_python_packages_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_python_packages(request) # Establish that the response is the type that we expect. @@ -31191,6 +31289,7 @@ def test_list_python_packages_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = artifact.ListPythonPackagesResponse.to_json( artifact.ListPythonPackagesResponse() ) @@ -31239,6 +31338,7 @@ def test_get_python_package_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_python_package(request) @@ -31279,6 +31379,7 @@ def test_get_python_package_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_python_package(request) # Establish that the response is the type that we expect. @@ -31322,6 +31423,7 @@ def test_get_python_package_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = artifact.PythonPackage.to_json(artifact.PythonPackage()) req.return_value.content = return_value @@ -31366,6 +31468,7 @@ def test_import_apt_artifacts_rest_bad_request( response_value.status_code = 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_apt_artifacts(request) @@ -31396,6 +31499,7 @@ def test_import_apt_artifacts_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_apt_artifacts(request) # Establish that the response is the type that we expect. @@ -31437,6 +31541,7 @@ def test_import_apt_artifacts_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -31481,6 +31586,7 @@ def test_import_yum_artifacts_rest_bad_request( response_value.status_code = 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_yum_artifacts(request) @@ -31511,6 +31617,7 @@ def test_import_yum_artifacts_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_yum_artifacts(request) # Establish that the response is the type that we expect. @@ -31552,6 +31659,7 @@ def test_import_yum_artifacts_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -31596,6 +31704,7 @@ def test_list_repositories_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_repositories(request) @@ -31631,6 +31740,7 @@ def test_list_repositories_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_repositories(request) # Establish that the response is the type that we expect. @@ -31671,6 +31781,7 @@ def test_list_repositories_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = repository.ListRepositoriesResponse.to_json( repository.ListRepositoriesResponse() ) @@ -31715,6 +31826,7 @@ def test_get_repository_rest_bad_request(request_type=repository.GetRepositoryRe response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_repository(request) @@ -31759,6 +31871,7 @@ def test_get_repository_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_repository(request) # Establish that the response is the type that we expect. @@ -31808,6 +31921,7 @@ def test_get_repository_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = repository.Repository.to_json(repository.Repository()) req.return_value.content = return_value @@ -31852,6 +31966,7 @@ def test_create_repository_rest_bad_request( response_value.status_code = 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_repository(request) @@ -32019,6 +32134,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_repository(request) # Establish that the response is the type that we expect. @@ -32060,6 +32176,7 @@ def test_create_repository_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -32108,6 +32225,7 @@ def test_update_repository_rest_bad_request( response_value.status_code = 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_repository(request) @@ -32293,6 +32411,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_repository(request) # Establish that the response is the type that we expect. @@ -32342,6 +32461,7 @@ def test_update_repository_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = gda_repository.Repository.to_json(gda_repository.Repository()) req.return_value.content = return_value @@ -32386,6 +32506,7 @@ def test_delete_repository_rest_bad_request( response_value.status_code = 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_repository(request) @@ -32416,6 +32537,7 @@ def test_delete_repository_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_repository(request) # Establish that the response is the type that we expect. @@ -32457,6 +32579,7 @@ def test_delete_repository_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -32499,6 +32622,7 @@ def test_list_packages_rest_bad_request(request_type=package.ListPackagesRequest response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_packages(request) @@ -32534,6 +32658,7 @@ def test_list_packages_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_packages(request) # Establish that the response is the type that we expect. @@ -32572,6 +32697,7 @@ def test_list_packages_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = package.ListPackagesResponse.to_json( package.ListPackagesResponse() ) @@ -32618,6 +32744,7 @@ def test_get_package_rest_bad_request(request_type=package.GetPackageRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_package(request) @@ -32656,6 +32783,7 @@ def test_get_package_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_package(request) # Establish that the response is the type that we expect. @@ -32695,6 +32823,7 @@ def test_get_package_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = package.Package.to_json(package.Package()) req.return_value.content = return_value @@ -32739,6 +32868,7 @@ def test_delete_package_rest_bad_request(request_type=package.DeletePackageReque response_value.status_code = 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_package(request) @@ -32771,6 +32901,7 @@ def test_delete_package_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_package(request) # Establish that the response is the type that we expect. @@ -32810,6 +32941,7 @@ def test_delete_package_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -32854,6 +32986,7 @@ def test_list_versions_rest_bad_request(request_type=version.ListVersionsRequest response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_versions(request) @@ -32891,6 +33024,7 @@ def test_list_versions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_versions(request) # Establish that the response is the type that we expect. @@ -32929,6 +33063,7 @@ def test_list_versions_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = version.ListVersionsResponse.to_json( version.ListVersionsResponse() ) @@ -32975,6 +33110,7 @@ def test_get_version_rest_bad_request(request_type=version.GetVersionRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_version(request) @@ -33013,6 +33149,7 @@ def test_get_version_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_version(request) # Establish that the response is the type that we expect. @@ -33052,6 +33189,7 @@ def test_get_version_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = version.Version.to_json(version.Version()) req.return_value.content = return_value @@ -33096,6 +33234,7 @@ def test_delete_version_rest_bad_request(request_type=version.DeleteVersionReque response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_version(request) @@ -33128,6 +33267,7 @@ def test_delete_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.delete_version(request) # Establish that the response is the type that we expect. @@ -33167,6 +33307,7 @@ def test_delete_version_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -33213,6 +33354,7 @@ def test_batch_delete_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.batch_delete_versions(request) @@ -33245,6 +33387,7 @@ def test_batch_delete_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.batch_delete_versions(request) # Establish that the response is the type that we expect. @@ -33286,6 +33429,7 @@ def test_batch_delete_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -33332,6 +33476,7 @@ def test_update_version_rest_bad_request(request_type=gda_version.UpdateVersionR response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_version(request) @@ -33448,6 +33593,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_version(request) # Establish that the response is the type that we expect. @@ -33489,6 +33635,7 @@ def test_update_version_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = gda_version.Version.to_json(gda_version.Version()) req.return_value.content = return_value @@ -33531,6 +33678,7 @@ def test_list_files_rest_bad_request(request_type=file.ListFilesRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_files(request) @@ -33566,6 +33714,7 @@ def test_list_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_files(request) # Establish that the response is the type that we expect. @@ -33604,6 +33753,7 @@ def test_list_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 = file.ListFilesResponse.to_json(file.ListFilesResponse()) req.return_value.content = return_value @@ -33648,6 +33798,7 @@ def test_get_file_rest_bad_request(request_type=file.GetFileRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_file(request) @@ -33687,6 +33838,7 @@ def test_get_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_file(request) # Establish that the response is the type that we expect. @@ -33727,6 +33879,7 @@ def test_get_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 = file.File.to_json(file.File()) req.return_value.content = return_value @@ -33771,6 +33924,7 @@ def test_delete_file_rest_bad_request(request_type=file.DeleteFileRequest): response_value.status_code = 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_file(request) @@ -33803,6 +33957,7 @@ def test_delete_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.delete_file(request) # Establish that the response is the type that we expect. @@ -33842,6 +33997,7 @@ def test_delete_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -33888,6 +34044,7 @@ def test_update_file_rest_bad_request(request_type=gda_file.UpdateFileRequest): response_value.status_code = 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_file(request) @@ -34006,6 +34163,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_file(request) # Establish that the response is the type that we expect. @@ -34046,6 +34204,7 @@ def test_update_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 = gda_file.File.to_json(gda_file.File()) req.return_value.content = return_value @@ -34090,6 +34249,7 @@ def test_list_tags_rest_bad_request(request_type=tag.ListTagsRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_tags(request) @@ -34127,6 +34287,7 @@ def test_list_tags_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_tags(request) # Establish that the response is the type that we expect. @@ -34165,6 +34326,7 @@ def test_list_tags_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = tag.ListTagsResponse.to_json(tag.ListTagsResponse()) req.return_value.content = return_value @@ -34209,6 +34371,7 @@ def test_get_tag_rest_bad_request(request_type=tag.GetTagRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_tag(request) @@ -34247,6 +34410,7 @@ def test_get_tag_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_tag(request) # Establish that the response is the type that we expect. @@ -34286,6 +34450,7 @@ def test_get_tag_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = tag.Tag.to_json(tag.Tag()) req.return_value.content = return_value @@ -34330,6 +34495,7 @@ def test_create_tag_rest_bad_request(request_type=gda_tag.CreateTagRequest): response_value.status_code = 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_tag(request) @@ -34436,6 +34602,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_tag(request) # Establish that the response is the type that we expect. @@ -34475,6 +34642,7 @@ def test_create_tag_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = gda_tag.Tag.to_json(gda_tag.Tag()) req.return_value.content = return_value @@ -34521,6 +34689,7 @@ def test_update_tag_rest_bad_request(request_type=gda_tag.UpdateTagRequest): response_value.status_code = 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_tag(request) @@ -34632,6 +34801,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_tag(request) # Establish that the response is the type that we expect. @@ -34671,6 +34841,7 @@ def test_update_tag_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = gda_tag.Tag.to_json(gda_tag.Tag()) req.return_value.content = return_value @@ -34715,6 +34886,7 @@ def test_delete_tag_rest_bad_request(request_type=tag.DeleteTagRequest): response_value.status_code = 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_tag(request) @@ -34747,6 +34919,7 @@ def test_delete_tag_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_tag(request) # Establish that the response is the type that we expect. @@ -34781,6 +34954,7 @@ def test_delete_tag_rest_interceptors(null_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 = tag.DeleteTagRequest() metadata = [ @@ -34819,6 +34993,7 @@ def test_create_rule_rest_bad_request(request_type=gda_rule.CreateRuleRequest): response_value.status_code = 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_rule(request) @@ -34936,6 +35111,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_rule(request) # Establish that the response is the type that we expect. @@ -34977,6 +35153,7 @@ def test_create_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 = gda_rule.Rule.to_json(gda_rule.Rule()) req.return_value.content = return_value @@ -35019,6 +35196,7 @@ def test_list_rules_rest_bad_request(request_type=rule.ListRulesRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_rules(request) @@ -35054,6 +35232,7 @@ def test_list_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_rules(request) # Establish that the response is the type that we expect. @@ -35092,6 +35271,7 @@ def test_list_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 = rule.ListRulesResponse.to_json(rule.ListRulesResponse()) req.return_value.content = return_value @@ -35136,6 +35316,7 @@ def test_get_rule_rest_bad_request(request_type=rule.GetRuleRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_rule(request) @@ -35176,6 +35357,7 @@ def test_get_rule_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_rule(request) # Establish that the response is the type that we expect. @@ -35217,6 +35399,7 @@ def test_get_rule_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = rule.Rule.to_json(rule.Rule()) req.return_value.content = return_value @@ -35263,6 +35446,7 @@ def test_update_rule_rest_bad_request(request_type=gda_rule.UpdateRuleRequest): response_value.status_code = 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_rule(request) @@ -35384,6 +35568,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_rule(request) # Establish that the response is the type that we expect. @@ -35425,6 +35610,7 @@ def test_update_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 = gda_rule.Rule.to_json(gda_rule.Rule()) req.return_value.content = return_value @@ -35469,6 +35655,7 @@ def test_delete_rule_rest_bad_request(request_type=rule.DeleteRuleRequest): response_value.status_code = 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_rule(request) @@ -35501,6 +35688,7 @@ def test_delete_rule_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_rule(request) # Establish that the response is the type that we expect. @@ -35535,6 +35723,7 @@ def test_delete_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"} request = rule.DeleteRuleRequest() metadata = [ @@ -35577,6 +35766,7 @@ def test_set_iam_policy_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.set_iam_policy(request) @@ -35612,6 +35802,7 @@ def test_set_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -35651,6 +35842,7 @@ def test_set_iam_policy_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(policy_pb2.Policy()) req.return_value.content = return_value @@ -35697,6 +35889,7 @@ def test_get_iam_policy_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_iam_policy(request) @@ -35732,6 +35925,7 @@ def test_get_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_iam_policy(request) # Establish that the response is the type that we expect. @@ -35771,6 +35965,7 @@ def test_get_iam_policy_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(policy_pb2.Policy()) req.return_value.content = return_value @@ -35817,6 +36012,7 @@ def test_test_iam_permissions_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.test_iam_permissions(request) @@ -35851,6 +36047,7 @@ def test_test_iam_permissions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -35889,6 +36086,7 @@ def test_test_iam_permissions_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson( iam_policy_pb2.TestIamPermissionsResponse() ) @@ -35935,6 +36133,7 @@ def test_get_project_settings_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_project_settings(request) @@ -35972,6 +36171,7 @@ def test_get_project_settings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_project_settings(request) # Establish that the response is the type that we expect. @@ -36017,6 +36217,7 @@ def test_get_project_settings_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = settings.ProjectSettings.to_json(settings.ProjectSettings()) req.return_value.content = return_value @@ -36061,6 +36262,7 @@ def test_update_project_settings_rest_bad_request( response_value.status_code = 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_project_settings(request) @@ -36170,6 +36372,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_project_settings(request) # Establish that the response is the type that we expect. @@ -36215,6 +36418,7 @@ def test_update_project_settings_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = settings.ProjectSettings.to_json(settings.ProjectSettings()) req.return_value.content = return_value @@ -36259,6 +36463,7 @@ def test_get_vpcsc_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_vpcsc_config(request) @@ -36295,6 +36500,7 @@ def test_get_vpcsc_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_vpcsc_config(request) # Establish that the response is the type that we expect. @@ -36336,6 +36542,7 @@ def test_get_vpcsc_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 = vpcsc_config.VPCSCConfig.to_json(vpcsc_config.VPCSCConfig()) req.return_value.content = return_value @@ -36382,6 +36589,7 @@ def test_update_vpcsc_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_vpcsc_config(request) @@ -36491,6 +36699,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_vpcsc_config(request) # Establish that the response is the type that we expect. @@ -36532,6 +36741,7 @@ def test_update_vpcsc_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 = gda_vpcsc_config.VPCSCConfig.to_json( gda_vpcsc_config.VPCSCConfig() ) @@ -36580,6 +36790,7 @@ def test_update_package_rest_bad_request(request_type=gda_package.UpdatePackageR response_value.status_code = 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_package(request) @@ -36694,6 +36905,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_package(request) # Establish that the response is the type that we expect. @@ -36735,6 +36947,7 @@ def test_update_package_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = gda_package.Package.to_json(gda_package.Package()) req.return_value.content = return_value @@ -36779,6 +36992,7 @@ def test_list_attachments_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_attachments(request) @@ -36814,6 +37028,7 @@ def test_list_attachments_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_attachments(request) # Establish that the response is the type that we expect. @@ -36854,6 +37069,7 @@ def test_list_attachments_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = attachment.ListAttachmentsResponse.to_json( attachment.ListAttachmentsResponse() ) @@ -36900,6 +37116,7 @@ def test_get_attachment_rest_bad_request(request_type=attachment.GetAttachmentRe response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_attachment(request) @@ -36942,6 +37159,7 @@ def test_get_attachment_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_attachment(request) # Establish that the response is the type that we expect. @@ -36987,6 +37205,7 @@ def test_get_attachment_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = attachment.Attachment.to_json(attachment.Attachment()) req.return_value.content = return_value @@ -37031,6 +37250,7 @@ def test_create_attachment_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_attachment(request) @@ -37139,6 +37359,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_attachment(request) # Establish that the response is the type that we expect. @@ -37180,6 +37401,7 @@ def test_create_attachment_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -37226,6 +37448,7 @@ def test_delete_attachment_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_attachment(request) @@ -37258,6 +37481,7 @@ def test_delete_attachment_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_attachment(request) # Establish that the response is the type that we expect. @@ -37299,6 +37523,7 @@ def test_delete_attachment_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -37343,6 +37568,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) @@ -37373,6 +37599,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) @@ -37401,6 +37628,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) @@ -37431,6 +37659,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) @@ -37461,6 +37690,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) @@ -37491,6 +37721,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-artifact-registry/tests/unit/gapic/artifactregistry_v1beta2/test_artifact_registry.py b/packages/google-cloud-artifact-registry/tests/unit/gapic/artifactregistry_v1beta2/test_artifact_registry.py index 049506cc9b08..e0648ecd9971 100644 --- a/packages/google-cloud-artifact-registry/tests/unit/gapic/artifactregistry_v1beta2/test_artifact_registry.py +++ b/packages/google-cloud-artifact-registry/tests/unit/gapic/artifactregistry_v1beta2/test_artifact_registry.py @@ -10334,6 +10334,7 @@ def test_list_repositories_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_repositories(request) @@ -10387,6 +10388,7 @@ def test_list_repositories_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_repositories(**mock_args) @@ -10581,6 +10583,7 @@ def test_get_repository_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_repository(request) @@ -10628,6 +10631,7 @@ def test_get_repository_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_repository(**mock_args) @@ -10765,6 +10769,7 @@ def test_create_repository_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_repository(request) @@ -10814,6 +10819,7 @@ def test_create_repository_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_repository(**mock_args) @@ -10924,6 +10930,7 @@ def test_update_repository_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_repository(**mock_args) @@ -11063,6 +11070,7 @@ def test_delete_repository_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_repository(request) @@ -11108,6 +11116,7 @@ def test_delete_repository_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_repository(**mock_args) @@ -11203,6 +11212,7 @@ def test_list_packages_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_packages(**mock_args) @@ -11361,6 +11371,7 @@ def test_get_package_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_package(**mock_args) @@ -11458,6 +11469,7 @@ def test_delete_package_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_package(**mock_args) @@ -11553,6 +11565,7 @@ def test_list_versions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_versions(**mock_args) @@ -11711,6 +11724,7 @@ def test_get_version_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_version(**mock_args) @@ -11808,6 +11822,7 @@ def test_delete_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.delete_version(**mock_args) @@ -11903,6 +11918,7 @@ def test_list_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_files(**mock_args) @@ -12061,6 +12077,7 @@ def test_get_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_file(**mock_args) @@ -12156,6 +12173,7 @@ def test_list_tags_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_tags(**mock_args) @@ -12314,6 +12332,7 @@ def test_get_tag_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_tag(**mock_args) @@ -12411,6 +12430,7 @@ def test_create_tag_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_tag(**mock_args) @@ -12511,6 +12531,7 @@ def test_update_tag_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_tag(**mock_args) @@ -12605,6 +12626,7 @@ def test_delete_tag_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_tag(**mock_args) @@ -12735,6 +12757,7 @@ def test_set_iam_policy_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.set_iam_policy(request) @@ -12862,6 +12885,7 @@ def test_get_iam_policy_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_iam_policy(request) @@ -12988,6 +13012,7 @@ def test_test_iam_permissions_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.test_iam_permissions(request) @@ -13119,6 +13144,7 @@ def test_get_project_settings_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_project_settings(request) @@ -13164,6 +13190,7 @@ def test_get_project_settings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_project_settings(**mock_args) @@ -13264,6 +13291,7 @@ def test_update_project_settings_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_project_settings(**mock_args) @@ -14679,6 +14707,7 @@ def test_import_apt_artifacts_rest_bad_request( response_value.status_code = 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_apt_artifacts(request) @@ -14709,6 +14738,7 @@ def test_import_apt_artifacts_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_apt_artifacts(request) # Establish that the response is the type that we expect. @@ -14750,6 +14780,7 @@ def test_import_apt_artifacts_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -14794,6 +14825,7 @@ def test_import_yum_artifacts_rest_bad_request( response_value.status_code = 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_yum_artifacts(request) @@ -14824,6 +14856,7 @@ def test_import_yum_artifacts_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_yum_artifacts(request) # Establish that the response is the type that we expect. @@ -14865,6 +14898,7 @@ def test_import_yum_artifacts_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -14909,6 +14943,7 @@ def test_list_repositories_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_repositories(request) @@ -14944,6 +14979,7 @@ def test_list_repositories_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_repositories(request) # Establish that the response is the type that we expect. @@ -14984,6 +15020,7 @@ def test_list_repositories_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = repository.ListRepositoriesResponse.to_json( repository.ListRepositoriesResponse() ) @@ -15028,6 +15065,7 @@ def test_get_repository_rest_bad_request(request_type=repository.GetRepositoryRe response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_repository(request) @@ -15066,6 +15104,7 @@ def test_get_repository_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_repository(request) # Establish that the response is the type that we expect. @@ -15109,6 +15148,7 @@ def test_get_repository_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = repository.Repository.to_json(repository.Repository()) req.return_value.content = return_value @@ -15153,6 +15193,7 @@ def test_create_repository_rest_bad_request( response_value.status_code = 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_repository(request) @@ -15260,6 +15301,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_repository(request) # Establish that the response is the type that we expect. @@ -15301,6 +15343,7 @@ def test_create_repository_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -15349,6 +15392,7 @@ def test_update_repository_rest_bad_request( response_value.status_code = 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_repository(request) @@ -15468,6 +15512,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_repository(request) # Establish that the response is the type that we expect. @@ -15511,6 +15556,7 @@ def test_update_repository_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = gda_repository.Repository.to_json(gda_repository.Repository()) req.return_value.content = return_value @@ -15555,6 +15601,7 @@ def test_delete_repository_rest_bad_request( response_value.status_code = 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_repository(request) @@ -15585,6 +15632,7 @@ def test_delete_repository_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_repository(request) # Establish that the response is the type that we expect. @@ -15626,6 +15674,7 @@ def test_delete_repository_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -15668,6 +15717,7 @@ def test_list_packages_rest_bad_request(request_type=package.ListPackagesRequest response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_packages(request) @@ -15703,6 +15753,7 @@ def test_list_packages_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_packages(request) # Establish that the response is the type that we expect. @@ -15741,6 +15792,7 @@ def test_list_packages_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = package.ListPackagesResponse.to_json( package.ListPackagesResponse() ) @@ -15787,6 +15839,7 @@ def test_get_package_rest_bad_request(request_type=package.GetPackageRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_package(request) @@ -15825,6 +15878,7 @@ def test_get_package_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_package(request) # Establish that the response is the type that we expect. @@ -15864,6 +15918,7 @@ def test_get_package_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = package.Package.to_json(package.Package()) req.return_value.content = return_value @@ -15908,6 +15963,7 @@ def test_delete_package_rest_bad_request(request_type=package.DeletePackageReque response_value.status_code = 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_package(request) @@ -15940,6 +15996,7 @@ def test_delete_package_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_package(request) # Establish that the response is the type that we expect. @@ -15979,6 +16036,7 @@ def test_delete_package_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -16023,6 +16081,7 @@ def test_list_versions_rest_bad_request(request_type=version.ListVersionsRequest response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_versions(request) @@ -16060,6 +16119,7 @@ def test_list_versions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_versions(request) # Establish that the response is the type that we expect. @@ -16098,6 +16158,7 @@ def test_list_versions_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = version.ListVersionsResponse.to_json( version.ListVersionsResponse() ) @@ -16144,6 +16205,7 @@ def test_get_version_rest_bad_request(request_type=version.GetVersionRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_version(request) @@ -16182,6 +16244,7 @@ def test_get_version_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_version(request) # Establish that the response is the type that we expect. @@ -16221,6 +16284,7 @@ def test_get_version_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = version.Version.to_json(version.Version()) req.return_value.content = return_value @@ -16265,6 +16329,7 @@ def test_delete_version_rest_bad_request(request_type=version.DeleteVersionReque response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_version(request) @@ -16297,6 +16362,7 @@ def test_delete_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.delete_version(request) # Establish that the response is the type that we expect. @@ -16336,6 +16402,7 @@ def test_delete_version_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -16378,6 +16445,7 @@ def test_list_files_rest_bad_request(request_type=file.ListFilesRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_files(request) @@ -16413,6 +16481,7 @@ def test_list_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_files(request) # Establish that the response is the type that we expect. @@ -16451,6 +16520,7 @@ def test_list_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 = file.ListFilesResponse.to_json(file.ListFilesResponse()) req.return_value.content = return_value @@ -16495,6 +16565,7 @@ def test_get_file_rest_bad_request(request_type=file.GetFileRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_file(request) @@ -16534,6 +16605,7 @@ def test_get_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_file(request) # Establish that the response is the type that we expect. @@ -16574,6 +16646,7 @@ def test_get_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 = file.File.to_json(file.File()) req.return_value.content = return_value @@ -16618,6 +16691,7 @@ def test_list_tags_rest_bad_request(request_type=tag.ListTagsRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_tags(request) @@ -16655,6 +16729,7 @@ def test_list_tags_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_tags(request) # Establish that the response is the type that we expect. @@ -16693,6 +16768,7 @@ def test_list_tags_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = tag.ListTagsResponse.to_json(tag.ListTagsResponse()) req.return_value.content = return_value @@ -16737,6 +16813,7 @@ def test_get_tag_rest_bad_request(request_type=tag.GetTagRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_tag(request) @@ -16775,6 +16852,7 @@ def test_get_tag_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_tag(request) # Establish that the response is the type that we expect. @@ -16814,6 +16892,7 @@ def test_get_tag_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = tag.Tag.to_json(tag.Tag()) req.return_value.content = return_value @@ -16858,6 +16937,7 @@ def test_create_tag_rest_bad_request(request_type=gda_tag.CreateTagRequest): response_value.status_code = 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_tag(request) @@ -16964,6 +17044,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_tag(request) # Establish that the response is the type that we expect. @@ -17003,6 +17084,7 @@ def test_create_tag_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = gda_tag.Tag.to_json(gda_tag.Tag()) req.return_value.content = return_value @@ -17049,6 +17131,7 @@ def test_update_tag_rest_bad_request(request_type=gda_tag.UpdateTagRequest): response_value.status_code = 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_tag(request) @@ -17160,6 +17243,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_tag(request) # Establish that the response is the type that we expect. @@ -17199,6 +17283,7 @@ def test_update_tag_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = gda_tag.Tag.to_json(gda_tag.Tag()) req.return_value.content = return_value @@ -17243,6 +17328,7 @@ def test_delete_tag_rest_bad_request(request_type=tag.DeleteTagRequest): response_value.status_code = 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_tag(request) @@ -17275,6 +17361,7 @@ def test_delete_tag_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_tag(request) # Establish that the response is the type that we expect. @@ -17309,6 +17396,7 @@ def test_delete_tag_rest_interceptors(null_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 = tag.DeleteTagRequest() metadata = [ @@ -17351,6 +17439,7 @@ def test_set_iam_policy_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.set_iam_policy(request) @@ -17386,6 +17475,7 @@ def test_set_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.set_iam_policy(request) # Establish that the response is the type that we expect. @@ -17425,6 +17515,7 @@ def test_set_iam_policy_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(policy_pb2.Policy()) req.return_value.content = return_value @@ -17471,6 +17562,7 @@ def test_get_iam_policy_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_iam_policy(request) @@ -17506,6 +17598,7 @@ def test_get_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_iam_policy(request) # Establish that the response is the type that we expect. @@ -17545,6 +17638,7 @@ def test_get_iam_policy_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(policy_pb2.Policy()) req.return_value.content = return_value @@ -17591,6 +17685,7 @@ def test_test_iam_permissions_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.test_iam_permissions(request) @@ -17625,6 +17720,7 @@ def test_test_iam_permissions_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.test_iam_permissions(request) # Establish that the response is the type that we expect. @@ -17663,6 +17759,7 @@ def test_test_iam_permissions_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson( iam_policy_pb2.TestIamPermissionsResponse() ) @@ -17709,6 +17806,7 @@ def test_get_project_settings_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_project_settings(request) @@ -17745,6 +17843,7 @@ def test_get_project_settings_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_project_settings(request) # Establish that the response is the type that we expect. @@ -17789,6 +17888,7 @@ def test_get_project_settings_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = settings.ProjectSettings.to_json(settings.ProjectSettings()) req.return_value.content = return_value @@ -17833,6 +17933,7 @@ def test_update_project_settings_rest_bad_request( response_value.status_code = 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_project_settings(request) @@ -17940,6 +18041,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_project_settings(request) # Establish that the response is the type that we expect. @@ -17984,6 +18086,7 @@ def test_update_project_settings_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = settings.ProjectSettings.to_json(settings.ProjectSettings()) req.return_value.content = return_value @@ -18028,6 +18131,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) @@ -18058,6 +18162,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) @@ -18086,6 +18191,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) @@ -18116,6 +18222,7 @@ def test_list_locations_rest(request_type): response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_locations(request) diff --git a/packages/google-cloud-asset/google/cloud/asset/gapic_version.py b/packages/google-cloud-asset/google/cloud/asset/gapic_version.py index 7af2fa694463..558c8aab67c5 100644 --- a/packages/google-cloud-asset/google/cloud/asset/gapic_version.py +++ b/packages/google-cloud-asset/google/cloud/asset/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "3.27.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-asset/google/cloud/asset_v1/gapic_version.py b/packages/google-cloud-asset/google/cloud/asset_v1/gapic_version.py index 7af2fa694463..558c8aab67c5 100644 --- a/packages/google-cloud-asset/google/cloud/asset_v1/gapic_version.py +++ b/packages/google-cloud-asset/google/cloud/asset_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "3.27.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-asset/google/cloud/asset_v1/services/asset_service/async_client.py b/packages/google-cloud-asset/google/cloud/asset_v1/services/asset_service/async_client.py index 13ad0a5e27b4..5870dcb351e8 100644 --- a/packages/google-cloud-asset/google/cloud/asset_v1/services/asset_service/async_client.py +++ b/packages/google-cloud-asset/google/cloud/asset_v1/services/asset_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -57,6 +58,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, AssetServiceTransport from .transports.grpc_asyncio import AssetServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class AssetServiceAsyncClient: """Asset service definition.""" @@ -272,13 +282,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.asset_v1.AssetServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "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.asset.v1.AssetService", + "credentialsType": None, + }, + ) + async def export_assets( self, request: Optional[Union[asset_service.ExportAssetsRequest, 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]]] = (), ) -> operation_async.AsyncOperation: r"""Exports assets with time and resource types to a given Cloud Storage location/BigQuery table. For Cloud Storage location @@ -334,8 +366,10 @@ async def sample_export_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: @@ -395,7 +429,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 assets with time and resource types and returns paged results in response. @@ -445,8 +479,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.asset_v1.services.asset_service.pagers.ListAssetsAsyncPager: @@ -522,7 +558,7 @@ async def batch_get_assets_history( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.BatchGetAssetsHistoryResponse: r"""Batch gets the update history of assets that overlap a time window. For IAM_POLICY content, this API outputs history when @@ -564,8 +600,10 @@ async def sample_batch_get_assets_history(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.asset_v1.types.BatchGetAssetsHistoryResponse: @@ -610,7 +648,7 @@ async def create_feed( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.Feed: r"""Creates a feed in a parent project/folder/organization to listen to its asset @@ -667,8 +705,10 @@ async def sample_create_feed(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.asset_v1.types.Feed: @@ -735,7 +775,7 @@ async def get_feed( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.Feed: r"""Gets details about an asset feed. @@ -780,8 +820,10 @@ async def sample_get_feed(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.asset_v1.types.Feed: @@ -846,7 +888,7 @@ async def list_feeds( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.ListFeedsResponse: r"""Lists all asset feeds in a parent project/folder/organization. @@ -894,8 +936,10 @@ async def sample_list_feeds(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.asset_v1.types.ListFeedsResponse: @@ -954,7 +998,7 @@ async def update_feed( feed: Optional[asset_service.Feed] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.Feed: r"""Updates an asset feed configuration. @@ -1003,8 +1047,10 @@ async def sample_update_feed(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.asset_v1.types.Feed: @@ -1073,7 +1119,7 @@ async def delete_feed( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 asset feed. @@ -1115,8 +1161,10 @@ async def sample_delete_feed(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -1170,7 +1218,7 @@ async def search_all_resources( asset_types: 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]]] = (), ) -> pagers.SearchAllResourcesAsyncPager: r"""Searches all Google Cloud resources within the specified scope, such as a project, folder, or organization. The caller must be @@ -1356,8 +1404,10 @@ async def sample_search_all_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.asset_v1.services.asset_service.pagers.SearchAllResourcesAsyncPager: @@ -1439,7 +1489,7 @@ async def search_all_iam_policies( query: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchAllIamPoliciesAsyncPager: r"""Searches all IAM policies within the specified scope, such as a project, folder, or organization. The caller must be granted the @@ -1554,8 +1604,10 @@ async def sample_search_all_iam_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.asset_v1.services.asset_service.pagers.SearchAllIamPoliciesAsyncPager: @@ -1631,7 +1683,7 @@ async def analyze_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]]] = (), ) -> asset_service.AnalyzeIamPolicyResponse: r"""Analyzes IAM policies to answer which identities have what accesses on which resources. @@ -1672,8 +1724,10 @@ async def sample_analyze_iam_policy(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.asset_v1.types.AnalyzeIamPolicyResponse: @@ -1723,7 +1777,7 @@ async def analyze_iam_policy_longrunning( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 IAM policies asynchronously to answer which identities have what accesses on which resources, and writes the analysis @@ -1782,8 +1836,10 @@ async def sample_analyze_iam_policy_longrunning(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -1841,7 +1897,7 @@ async def analyze_move( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.AnalyzeMoveResponse: r"""Analyze moving a resource to a specified destination without kicking off the actual move. The analysis is @@ -1885,8 +1941,10 @@ async def sample_analyze_move(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.asset_v1.types.AnalyzeMoveResponse: @@ -1932,7 +1990,7 @@ async def query_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]]] = (), ) -> asset_service.QueryAssetsResponse: r"""Issue a job that queries assets using a SQL statement compatible with `BigQuery @@ -1984,8 +2042,10 @@ async def sample_query_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.asset_v1.types.QueryAssetsResponse: @@ -2032,7 +2092,7 @@ async def create_saved_query( saved_query_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]]] = (), ) -> asset_service.SavedQuery: r"""Creates a saved query in a parent project/folder/organization. @@ -2104,8 +2164,10 @@ async def sample_create_saved_query(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.asset_v1.types.SavedQuery: @@ -2170,7 +2232,7 @@ async def get_saved_query( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.SavedQuery: r"""Gets details about a saved query. @@ -2217,8 +2279,10 @@ async def sample_get_saved_query(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.asset_v1.types.SavedQuery: @@ -2279,7 +2343,7 @@ async def list_saved_queries( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSavedQueriesAsyncPager: r"""Lists all saved queries in a parent project/folder/organization. @@ -2329,8 +2393,10 @@ async def sample_list_saved_queries(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.asset_v1.services.asset_service.pagers.ListSavedQueriesAsyncPager: @@ -2406,7 +2472,7 @@ async def update_saved_query( 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]]] = (), ) -> asset_service.SavedQuery: r"""Updates a saved query. @@ -2461,8 +2527,10 @@ async def sample_update_saved_query(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.asset_v1.types.SavedQuery: @@ -2527,7 +2595,7 @@ async def delete_saved_query( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 saved query. @@ -2571,8 +2639,10 @@ async def sample_delete_saved_query(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -2625,7 +2695,7 @@ async def batch_get_effective_iam_policies( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.BatchGetEffectiveIamPoliciesResponse: r"""Gets effective IAM policies for a batch of resources. @@ -2663,8 +2733,10 @@ async def sample_batch_get_effective_iam_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.asset_v1.types.BatchGetEffectiveIamPoliciesResponse: @@ -2713,7 +2785,7 @@ async def analyze_org_policies( 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.AnalyzeOrgPoliciesAsyncPager: r"""Analyzes organization policies under a scope. @@ -2790,8 +2862,10 @@ async def sample_analyze_org_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.asset_v1.services.asset_service.pagers.AnalyzeOrgPoliciesAsyncPager: @@ -2874,7 +2948,7 @@ async def analyze_org_policy_governed_containers( 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.AnalyzeOrgPolicyGovernedContainersAsyncPager: r"""Analyzes organization policies governed containers (projects, folders or organization) under a scope. @@ -2952,8 +3026,10 @@ async def sample_analyze_org_policy_governed_containers(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.asset_v1.services.asset_service.pagers.AnalyzeOrgPolicyGovernedContainersAsyncPager: @@ -3038,7 +3114,7 @@ async def analyze_org_policy_governed_assets( 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.AnalyzeOrgPolicyGovernedAssetsAsyncPager: r"""Analyzes organization policies governed assets (Google Cloud resources or policies) under a scope. This RPC supports custom @@ -3187,8 +3263,10 @@ async def sample_analyze_org_policy_governed_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.asset_v1.services.asset_service.pagers.AnalyzeOrgPolicyGovernedAssetsAsyncPager: @@ -3266,7 +3344,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. @@ -3277,8 +3355,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-asset/google/cloud/asset_v1/services/asset_service/client.py b/packages/google-cloud-asset/google/cloud/asset_v1/services/asset_service/client.py index ab8f4a588fee..d165632ed4f1 100644 --- a/packages/google-cloud-asset/google/cloud/asset_v1/services/asset_service/client.py +++ b/packages/google-cloud-asset/google/cloud/asset_v1/services/asset_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 @@ -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,13 +762,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.asset_v1.AssetServiceClient`.", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "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.asset.v1.AssetService", + "credentialsType": None, + }, + ) + def export_assets( self, request: Optional[Union[asset_service.ExportAssetsRequest, 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]]] = (), ) -> operation.Operation: r"""Exports assets with time and resource types to a given Cloud Storage location/BigQuery table. For Cloud Storage location @@ -810,8 +847,10 @@ def sample_export_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: @@ -869,7 +908,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 assets with time and resource types and returns paged results in response. @@ -919,8 +958,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.asset_v1.services.asset_service.pagers.ListAssetsPager: @@ -993,7 +1034,7 @@ def batch_get_assets_history( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.BatchGetAssetsHistoryResponse: r"""Batch gets the update history of assets that overlap a time window. For IAM_POLICY content, this API outputs history when @@ -1035,8 +1076,10 @@ def sample_batch_get_assets_history(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.asset_v1.types.BatchGetAssetsHistoryResponse: @@ -1079,7 +1122,7 @@ def create_feed( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.Feed: r"""Creates a feed in a parent project/folder/organization to listen to its asset @@ -1136,8 +1179,10 @@ def sample_create_feed(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.asset_v1.types.Feed: @@ -1201,7 +1246,7 @@ def get_feed( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.Feed: r"""Gets details about an asset feed. @@ -1246,8 +1291,10 @@ def sample_get_feed(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.asset_v1.types.Feed: @@ -1311,7 +1358,7 @@ def list_feeds( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.ListFeedsResponse: r"""Lists all asset feeds in a parent project/folder/organization. @@ -1359,8 +1406,10 @@ def sample_list_feeds(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.asset_v1.types.ListFeedsResponse: @@ -1416,7 +1465,7 @@ def update_feed( feed: Optional[asset_service.Feed] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.Feed: r"""Updates an asset feed configuration. @@ -1465,8 +1514,10 @@ def sample_update_feed(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.asset_v1.types.Feed: @@ -1532,7 +1583,7 @@ def delete_feed( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 asset feed. @@ -1574,8 +1625,10 @@ def sample_delete_feed(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -1626,7 +1679,7 @@ def search_all_resources( asset_types: 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]]] = (), ) -> pagers.SearchAllResourcesPager: r"""Searches all Google Cloud resources within the specified scope, such as a project, folder, or organization. The caller must be @@ -1812,8 +1865,10 @@ def sample_search_all_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.asset_v1.services.asset_service.pagers.SearchAllResourcesPager: @@ -1892,7 +1947,7 @@ def search_all_iam_policies( query: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchAllIamPoliciesPager: r"""Searches all IAM policies within the specified scope, such as a project, folder, or organization. The caller must be granted the @@ -2007,8 +2062,10 @@ def sample_search_all_iam_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.asset_v1.services.asset_service.pagers.SearchAllIamPoliciesPager: @@ -2081,7 +2138,7 @@ def analyze_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]]] = (), ) -> asset_service.AnalyzeIamPolicyResponse: r"""Analyzes IAM policies to answer which identities have what accesses on which resources. @@ -2122,8 +2179,10 @@ def sample_analyze_iam_policy(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.asset_v1.types.AnalyzeIamPolicyResponse: @@ -2171,7 +2230,7 @@ def analyze_iam_policy_longrunning( *, retry: OptionalRetry = gapic_v1.method.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 IAM policies asynchronously to answer which identities have what accesses on which resources, and writes the analysis @@ -2230,8 +2289,10 @@ def sample_analyze_iam_policy_longrunning(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -2289,7 +2350,7 @@ def analyze_move( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.AnalyzeMoveResponse: r"""Analyze moving a resource to a specified destination without kicking off the actual move. The analysis is @@ -2333,8 +2394,10 @@ def sample_analyze_move(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.asset_v1.types.AnalyzeMoveResponse: @@ -2378,7 +2441,7 @@ def query_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]]] = (), ) -> asset_service.QueryAssetsResponse: r"""Issue a job that queries assets using a SQL statement compatible with `BigQuery @@ -2430,8 +2493,10 @@ def sample_query_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.asset_v1.types.QueryAssetsResponse: @@ -2476,7 +2541,7 @@ def create_saved_query( saved_query_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]]] = (), ) -> asset_service.SavedQuery: r"""Creates a saved query in a parent project/folder/organization. @@ -2548,8 +2613,10 @@ def sample_create_saved_query(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.asset_v1.types.SavedQuery: @@ -2611,7 +2678,7 @@ def get_saved_query( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.SavedQuery: r"""Gets details about a saved query. @@ -2658,8 +2725,10 @@ def sample_get_saved_query(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.asset_v1.types.SavedQuery: @@ -2717,7 +2786,7 @@ def list_saved_queries( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSavedQueriesPager: r"""Lists all saved queries in a parent project/folder/organization. @@ -2767,8 +2836,10 @@ def sample_list_saved_queries(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.asset_v1.services.asset_service.pagers.ListSavedQueriesPager: @@ -2841,7 +2912,7 @@ def update_saved_query( 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]]] = (), ) -> asset_service.SavedQuery: r"""Updates a saved query. @@ -2896,8 +2967,10 @@ def sample_update_saved_query(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.asset_v1.types.SavedQuery: @@ -2959,7 +3032,7 @@ def delete_saved_query( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 saved query. @@ -3003,8 +3076,10 @@ def sample_delete_saved_query(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -3054,7 +3129,7 @@ def batch_get_effective_iam_policies( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.BatchGetEffectiveIamPoliciesResponse: r"""Gets effective IAM policies for a batch of resources. @@ -3092,8 +3167,10 @@ def sample_batch_get_effective_iam_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.asset_v1.types.BatchGetEffectiveIamPoliciesResponse: @@ -3142,7 +3219,7 @@ def analyze_org_policies( 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.AnalyzeOrgPoliciesPager: r"""Analyzes organization policies under a scope. @@ -3219,8 +3296,10 @@ def sample_analyze_org_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.asset_v1.services.asset_service.pagers.AnalyzeOrgPoliciesPager: @@ -3300,7 +3379,7 @@ def analyze_org_policy_governed_containers( 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.AnalyzeOrgPolicyGovernedContainersPager: r"""Analyzes organization policies governed containers (projects, folders or organization) under a scope. @@ -3378,8 +3457,10 @@ def sample_analyze_org_policy_governed_containers(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.asset_v1.services.asset_service.pagers.AnalyzeOrgPolicyGovernedContainersPager: @@ -3463,7 +3544,7 @@ def analyze_org_policy_governed_assets( 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.AnalyzeOrgPolicyGovernedAssetsPager: r"""Analyzes organization policies governed assets (Google Cloud resources or policies) under a scope. This RPC supports custom @@ -3612,8 +3693,10 @@ def sample_analyze_org_policy_governed_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.asset_v1.services.asset_service.pagers.AnalyzeOrgPolicyGovernedAssetsPager: @@ -3703,7 +3786,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. @@ -3714,8 +3797,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-asset/google/cloud/asset_v1/services/asset_service/pagers.py b/packages/google-cloud-asset/google/cloud/asset_v1/services/asset_service/pagers.py index 9b2d397a6421..70433f5e5926 100644 --- a/packages/google-cloud-asset/google/cloud/asset_v1/services/asset_service/pagers.py +++ b/packages/google-cloud-asset/google/cloud/asset_v1/services/asset_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 = asset_service.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 = asset_service.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 = asset_service.SearchAllResourcesRequest(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 = asset_service.SearchAllResourcesRequest(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 = asset_service.SearchAllIamPoliciesRequest(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 = asset_service.SearchAllIamPoliciesRequest(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 = asset_service.ListSavedQueriesRequest(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 = asset_service.ListSavedQueriesRequest(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 = asset_service.AnalyzeOrgPoliciesRequest(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 = asset_service.AnalyzeOrgPoliciesRequest(request) @@ -831,7 +851,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -845,8 +865,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = asset_service.AnalyzeOrgPolicyGovernedContainersRequest(request) @@ -913,7 +935,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. @@ -927,8 +949,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 = asset_service.AnalyzeOrgPolicyGovernedContainersRequest(request) @@ -997,7 +1021,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1011,8 +1035,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = asset_service.AnalyzeOrgPolicyGovernedAssetsRequest(request) @@ -1075,7 +1101,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. @@ -1089,8 +1115,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 = asset_service.AnalyzeOrgPolicyGovernedAssetsRequest(request) diff --git a/packages/google-cloud-asset/google/cloud/asset_v1/services/asset_service/transports/grpc.py b/packages/google-cloud-asset/google/cloud/asset_v1/services/asset_service/transports/grpc.py index faa124f3ca16..d8607e3fb72f 100644 --- a/packages/google-cloud-asset/google/cloud/asset_v1/services/asset_service/transports/grpc.py +++ b/packages/google-cloud-asset/google/cloud/asset_v1/services/asset_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.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.asset_v1.types import asset_service from .base import DEFAULT_CLIENT_INFO, AssetServiceTransport +try: + from google.api_core import client_logging # 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.asset.v1.AssetService", + "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.asset.v1.AssetService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AssetServiceGrpcTransport(AssetServiceTransport): """gRPC backend transport for AssetService. @@ -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 @@ -282,7 +370,7 @@ def export_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_assets" not in self._stubs: - self._stubs["export_assets"] = self.grpc_channel.unary_unary( + self._stubs["export_assets"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/ExportAssets", request_serializer=asset_service.ExportAssetsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -309,7 +397,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.asset.v1.AssetService/ListAssets", request_serializer=asset_service.ListAssetsRequest.serialize, response_deserializer=asset_service.ListAssetsResponse.deserialize, @@ -344,7 +432,7 @@ def batch_get_assets_history( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_get_assets_history" not in self._stubs: - self._stubs["batch_get_assets_history"] = self.grpc_channel.unary_unary( + self._stubs["batch_get_assets_history"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/BatchGetAssetsHistory", request_serializer=asset_service.BatchGetAssetsHistoryRequest.serialize, response_deserializer=asset_service.BatchGetAssetsHistoryResponse.deserialize, @@ -372,7 +460,7 @@ def create_feed( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_feed" not in self._stubs: - self._stubs["create_feed"] = self.grpc_channel.unary_unary( + self._stubs["create_feed"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/CreateFeed", request_serializer=asset_service.CreateFeedRequest.serialize, response_deserializer=asset_service.Feed.deserialize, @@ -396,7 +484,7 @@ def get_feed(self) -> Callable[[asset_service.GetFeedRequest], asset_service.Fee # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_feed" not in self._stubs: - self._stubs["get_feed"] = self.grpc_channel.unary_unary( + self._stubs["get_feed"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/GetFeed", request_serializer=asset_service.GetFeedRequest.serialize, response_deserializer=asset_service.Feed.deserialize, @@ -423,7 +511,7 @@ def list_feeds( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_feeds" not in self._stubs: - self._stubs["list_feeds"] = self.grpc_channel.unary_unary( + self._stubs["list_feeds"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/ListFeeds", request_serializer=asset_service.ListFeedsRequest.serialize, response_deserializer=asset_service.ListFeedsResponse.deserialize, @@ -449,7 +537,7 @@ def update_feed( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_feed" not in self._stubs: - self._stubs["update_feed"] = self.grpc_channel.unary_unary( + self._stubs["update_feed"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/UpdateFeed", request_serializer=asset_service.UpdateFeedRequest.serialize, response_deserializer=asset_service.Feed.deserialize, @@ -475,7 +563,7 @@ def delete_feed( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_feed" not in self._stubs: - self._stubs["delete_feed"] = self.grpc_channel.unary_unary( + self._stubs["delete_feed"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/DeleteFeed", request_serializer=asset_service.DeleteFeedRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -507,7 +595,7 @@ def search_all_resources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_all_resources" not in self._stubs: - self._stubs["search_all_resources"] = self.grpc_channel.unary_unary( + self._stubs["search_all_resources"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/SearchAllResources", request_serializer=asset_service.SearchAllResourcesRequest.serialize, response_deserializer=asset_service.SearchAllResourcesResponse.deserialize, @@ -539,7 +627,7 @@ def search_all_iam_policies( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_all_iam_policies" not in self._stubs: - self._stubs["search_all_iam_policies"] = self.grpc_channel.unary_unary( + self._stubs["search_all_iam_policies"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/SearchAllIamPolicies", request_serializer=asset_service.SearchAllIamPoliciesRequest.serialize, response_deserializer=asset_service.SearchAllIamPoliciesResponse.deserialize, @@ -568,7 +656,7 @@ def analyze_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "analyze_iam_policy" not in self._stubs: - self._stubs["analyze_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["analyze_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/AnalyzeIamPolicy", request_serializer=asset_service.AnalyzeIamPolicyRequest.serialize, response_deserializer=asset_service.AnalyzeIamPolicyResponse.deserialize, @@ -609,7 +697,7 @@ def analyze_iam_policy_longrunning( if "analyze_iam_policy_longrunning" not in self._stubs: self._stubs[ "analyze_iam_policy_longrunning" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/AnalyzeIamPolicyLongrunning", request_serializer=asset_service.AnalyzeIamPolicyLongrunningRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -643,7 +731,7 @@ def analyze_move( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "analyze_move" not in self._stubs: - self._stubs["analyze_move"] = self.grpc_channel.unary_unary( + self._stubs["analyze_move"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/AnalyzeMove", request_serializer=asset_service.AnalyzeMoveRequest.serialize, response_deserializer=asset_service.AnalyzeMoveResponse.deserialize, @@ -686,7 +774,7 @@ def query_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "query_assets" not in self._stubs: - self._stubs["query_assets"] = self.grpc_channel.unary_unary( + self._stubs["query_assets"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/QueryAssets", request_serializer=asset_service.QueryAssetsRequest.serialize, response_deserializer=asset_service.QueryAssetsResponse.deserialize, @@ -713,7 +801,7 @@ def create_saved_query( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_saved_query" not in self._stubs: - self._stubs["create_saved_query"] = self.grpc_channel.unary_unary( + self._stubs["create_saved_query"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/CreateSavedQuery", request_serializer=asset_service.CreateSavedQueryRequest.serialize, response_deserializer=asset_service.SavedQuery.deserialize, @@ -739,7 +827,7 @@ def get_saved_query( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_saved_query" not in self._stubs: - self._stubs["get_saved_query"] = self.grpc_channel.unary_unary( + self._stubs["get_saved_query"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/GetSavedQuery", request_serializer=asset_service.GetSavedQueryRequest.serialize, response_deserializer=asset_service.SavedQuery.deserialize, @@ -768,7 +856,7 @@ def list_saved_queries( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_saved_queries" not in self._stubs: - self._stubs["list_saved_queries"] = self.grpc_channel.unary_unary( + self._stubs["list_saved_queries"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/ListSavedQueries", request_serializer=asset_service.ListSavedQueriesRequest.serialize, response_deserializer=asset_service.ListSavedQueriesResponse.deserialize, @@ -794,7 +882,7 @@ def update_saved_query( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_saved_query" not in self._stubs: - self._stubs["update_saved_query"] = self.grpc_channel.unary_unary( + self._stubs["update_saved_query"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/UpdateSavedQuery", request_serializer=asset_service.UpdateSavedQueryRequest.serialize, response_deserializer=asset_service.SavedQuery.deserialize, @@ -820,7 +908,7 @@ def delete_saved_query( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_saved_query" not in self._stubs: - self._stubs["delete_saved_query"] = self.grpc_channel.unary_unary( + self._stubs["delete_saved_query"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/DeleteSavedQuery", request_serializer=asset_service.DeleteSavedQueryRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -852,7 +940,7 @@ def batch_get_effective_iam_policies( if "batch_get_effective_iam_policies" not in self._stubs: self._stubs[ "batch_get_effective_iam_policies" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/BatchGetEffectiveIamPolicies", request_serializer=asset_service.BatchGetEffectiveIamPoliciesRequest.serialize, response_deserializer=asset_service.BatchGetEffectiveIamPoliciesResponse.deserialize, @@ -881,7 +969,7 @@ def analyze_org_policies( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "analyze_org_policies" not in self._stubs: - self._stubs["analyze_org_policies"] = self.grpc_channel.unary_unary( + self._stubs["analyze_org_policies"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/AnalyzeOrgPolicies", request_serializer=asset_service.AnalyzeOrgPoliciesRequest.serialize, response_deserializer=asset_service.AnalyzeOrgPoliciesResponse.deserialize, @@ -914,7 +1002,7 @@ def analyze_org_policy_governed_containers( if "analyze_org_policy_governed_containers" not in self._stubs: self._stubs[ "analyze_org_policy_governed_containers" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/AnalyzeOrgPolicyGovernedContainers", request_serializer=asset_service.AnalyzeOrgPolicyGovernedContainersRequest.serialize, response_deserializer=asset_service.AnalyzeOrgPolicyGovernedContainersResponse.deserialize, @@ -995,7 +1083,7 @@ def analyze_org_policy_governed_assets( if "analyze_org_policy_governed_assets" not in self._stubs: self._stubs[ "analyze_org_policy_governed_assets" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/AnalyzeOrgPolicyGovernedAssets", request_serializer=asset_service.AnalyzeOrgPolicyGovernedAssetsRequest.serialize, response_deserializer=asset_service.AnalyzeOrgPolicyGovernedAssetsResponse.deserialize, @@ -1003,7 +1091,7 @@ def analyze_org_policy_governed_assets( return self._stubs["analyze_org_policy_governed_assets"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -1015,7 +1103,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-asset/google/cloud/asset_v1/services/asset_service/transports/grpc_asyncio.py b/packages/google-cloud-asset/google/cloud/asset_v1/services/asset_service/transports/grpc_asyncio.py index ed111859805a..dc77d87a4a8e 100644 --- a/packages/google-cloud-asset/google/cloud/asset_v1/services/asset_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-asset/google/cloud/asset_v1/services/asset_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.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.asset_v1.types import asset_service from .base import DEFAULT_CLIENT_INFO, AssetServiceTransport from .grpc import AssetServiceGrpcTransport +try: + from google.api_core import client_logging # 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.asset.v1.AssetService", + "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.asset.v1.AssetService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AssetServiceGrpcAsyncIOTransport(AssetServiceTransport): """gRPC AsyncIO backend transport for AssetService. @@ -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. @@ -294,7 +379,7 @@ def export_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "export_assets" not in self._stubs: - self._stubs["export_assets"] = self.grpc_channel.unary_unary( + self._stubs["export_assets"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/ExportAssets", request_serializer=asset_service.ExportAssetsRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -323,7 +408,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.asset.v1.AssetService/ListAssets", request_serializer=asset_service.ListAssetsRequest.serialize, response_deserializer=asset_service.ListAssetsResponse.deserialize, @@ -358,7 +443,7 @@ def batch_get_assets_history( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_get_assets_history" not in self._stubs: - self._stubs["batch_get_assets_history"] = self.grpc_channel.unary_unary( + self._stubs["batch_get_assets_history"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/BatchGetAssetsHistory", request_serializer=asset_service.BatchGetAssetsHistoryRequest.serialize, response_deserializer=asset_service.BatchGetAssetsHistoryResponse.deserialize, @@ -386,7 +471,7 @@ def create_feed( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_feed" not in self._stubs: - self._stubs["create_feed"] = self.grpc_channel.unary_unary( + self._stubs["create_feed"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/CreateFeed", request_serializer=asset_service.CreateFeedRequest.serialize, response_deserializer=asset_service.Feed.deserialize, @@ -412,7 +497,7 @@ def get_feed( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_feed" not in self._stubs: - self._stubs["get_feed"] = self.grpc_channel.unary_unary( + self._stubs["get_feed"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/GetFeed", request_serializer=asset_service.GetFeedRequest.serialize, response_deserializer=asset_service.Feed.deserialize, @@ -441,7 +526,7 @@ def list_feeds( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_feeds" not in self._stubs: - self._stubs["list_feeds"] = self.grpc_channel.unary_unary( + self._stubs["list_feeds"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/ListFeeds", request_serializer=asset_service.ListFeedsRequest.serialize, response_deserializer=asset_service.ListFeedsResponse.deserialize, @@ -467,7 +552,7 @@ def update_feed( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_feed" not in self._stubs: - self._stubs["update_feed"] = self.grpc_channel.unary_unary( + self._stubs["update_feed"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/UpdateFeed", request_serializer=asset_service.UpdateFeedRequest.serialize, response_deserializer=asset_service.Feed.deserialize, @@ -493,7 +578,7 @@ def delete_feed( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_feed" not in self._stubs: - self._stubs["delete_feed"] = self.grpc_channel.unary_unary( + self._stubs["delete_feed"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/DeleteFeed", request_serializer=asset_service.DeleteFeedRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -525,7 +610,7 @@ def search_all_resources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_all_resources" not in self._stubs: - self._stubs["search_all_resources"] = self.grpc_channel.unary_unary( + self._stubs["search_all_resources"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/SearchAllResources", request_serializer=asset_service.SearchAllResourcesRequest.serialize, response_deserializer=asset_service.SearchAllResourcesResponse.deserialize, @@ -557,7 +642,7 @@ def search_all_iam_policies( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_all_iam_policies" not in self._stubs: - self._stubs["search_all_iam_policies"] = self.grpc_channel.unary_unary( + self._stubs["search_all_iam_policies"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/SearchAllIamPolicies", request_serializer=asset_service.SearchAllIamPoliciesRequest.serialize, response_deserializer=asset_service.SearchAllIamPoliciesResponse.deserialize, @@ -587,7 +672,7 @@ def analyze_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "analyze_iam_policy" not in self._stubs: - self._stubs["analyze_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["analyze_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/AnalyzeIamPolicy", request_serializer=asset_service.AnalyzeIamPolicyRequest.serialize, response_deserializer=asset_service.AnalyzeIamPolicyResponse.deserialize, @@ -629,7 +714,7 @@ def analyze_iam_policy_longrunning( if "analyze_iam_policy_longrunning" not in self._stubs: self._stubs[ "analyze_iam_policy_longrunning" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/AnalyzeIamPolicyLongrunning", request_serializer=asset_service.AnalyzeIamPolicyLongrunningRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -663,7 +748,7 @@ def analyze_move( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "analyze_move" not in self._stubs: - self._stubs["analyze_move"] = self.grpc_channel.unary_unary( + self._stubs["analyze_move"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/AnalyzeMove", request_serializer=asset_service.AnalyzeMoveRequest.serialize, response_deserializer=asset_service.AnalyzeMoveResponse.deserialize, @@ -706,7 +791,7 @@ def query_assets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "query_assets" not in self._stubs: - self._stubs["query_assets"] = self.grpc_channel.unary_unary( + self._stubs["query_assets"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/QueryAssets", request_serializer=asset_service.QueryAssetsRequest.serialize, response_deserializer=asset_service.QueryAssetsResponse.deserialize, @@ -735,7 +820,7 @@ def create_saved_query( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_saved_query" not in self._stubs: - self._stubs["create_saved_query"] = self.grpc_channel.unary_unary( + self._stubs["create_saved_query"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/CreateSavedQuery", request_serializer=asset_service.CreateSavedQueryRequest.serialize, response_deserializer=asset_service.SavedQuery.deserialize, @@ -763,7 +848,7 @@ def get_saved_query( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_saved_query" not in self._stubs: - self._stubs["get_saved_query"] = self.grpc_channel.unary_unary( + self._stubs["get_saved_query"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/GetSavedQuery", request_serializer=asset_service.GetSavedQueryRequest.serialize, response_deserializer=asset_service.SavedQuery.deserialize, @@ -793,7 +878,7 @@ def list_saved_queries( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_saved_queries" not in self._stubs: - self._stubs["list_saved_queries"] = self.grpc_channel.unary_unary( + self._stubs["list_saved_queries"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/ListSavedQueries", request_serializer=asset_service.ListSavedQueriesRequest.serialize, response_deserializer=asset_service.ListSavedQueriesResponse.deserialize, @@ -821,7 +906,7 @@ def update_saved_query( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_saved_query" not in self._stubs: - self._stubs["update_saved_query"] = self.grpc_channel.unary_unary( + self._stubs["update_saved_query"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/UpdateSavedQuery", request_serializer=asset_service.UpdateSavedQueryRequest.serialize, response_deserializer=asset_service.SavedQuery.deserialize, @@ -847,7 +932,7 @@ def delete_saved_query( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_saved_query" not in self._stubs: - self._stubs["delete_saved_query"] = self.grpc_channel.unary_unary( + self._stubs["delete_saved_query"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/DeleteSavedQuery", request_serializer=asset_service.DeleteSavedQueryRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -879,7 +964,7 @@ def batch_get_effective_iam_policies( if "batch_get_effective_iam_policies" not in self._stubs: self._stubs[ "batch_get_effective_iam_policies" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/BatchGetEffectiveIamPolicies", request_serializer=asset_service.BatchGetEffectiveIamPoliciesRequest.serialize, response_deserializer=asset_service.BatchGetEffectiveIamPoliciesResponse.deserialize, @@ -908,7 +993,7 @@ def analyze_org_policies( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "analyze_org_policies" not in self._stubs: - self._stubs["analyze_org_policies"] = self.grpc_channel.unary_unary( + self._stubs["analyze_org_policies"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/AnalyzeOrgPolicies", request_serializer=asset_service.AnalyzeOrgPoliciesRequest.serialize, response_deserializer=asset_service.AnalyzeOrgPoliciesResponse.deserialize, @@ -941,7 +1026,7 @@ def analyze_org_policy_governed_containers( if "analyze_org_policy_governed_containers" not in self._stubs: self._stubs[ "analyze_org_policy_governed_containers" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/AnalyzeOrgPolicyGovernedContainers", request_serializer=asset_service.AnalyzeOrgPolicyGovernedContainersRequest.serialize, response_deserializer=asset_service.AnalyzeOrgPolicyGovernedContainersResponse.deserialize, @@ -1022,7 +1107,7 @@ def analyze_org_policy_governed_assets( if "analyze_org_policy_governed_assets" not in self._stubs: self._stubs[ "analyze_org_policy_governed_assets" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.asset.v1.AssetService/AnalyzeOrgPolicyGovernedAssets", request_serializer=asset_service.AnalyzeOrgPolicyGovernedAssetsRequest.serialize, response_deserializer=asset_service.AnalyzeOrgPolicyGovernedAssetsResponse.deserialize, @@ -1315,7 +1400,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: @@ -1331,7 +1416,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-asset/google/cloud/asset_v1/services/asset_service/transports/rest.py b/packages/google-cloud-asset/google/cloud/asset_v1/services/asset_service/transports/rest.py index c06c577e89be..ebdff51d6ef8 100644 --- a/packages/google-cloud-asset/google/cloud/asset_v1/services/asset_service/transports/rest.py +++ b/packages/google-cloud-asset/google/cloud/asset_v1/services/asset_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, @@ -247,8 +255,10 @@ def post_update_saved_query(self, response): def pre_analyze_iam_policy( self, request: asset_service.AnalyzeIamPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[asset_service.AnalyzeIamPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + asset_service.AnalyzeIamPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for analyze_iam_policy Override in a subclass to manipulate the request or metadata @@ -270,9 +280,10 @@ def post_analyze_iam_policy( def pre_analyze_iam_policy_longrunning( self, request: asset_service.AnalyzeIamPolicyLongrunningRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - asset_service.AnalyzeIamPolicyLongrunningRequest, Sequence[Tuple[str, str]] + asset_service.AnalyzeIamPolicyLongrunningRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for analyze_iam_policy_longrunning @@ -295,8 +306,10 @@ def post_analyze_iam_policy_longrunning( def pre_analyze_move( self, request: asset_service.AnalyzeMoveRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[asset_service.AnalyzeMoveRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + asset_service.AnalyzeMoveRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for analyze_move Override in a subclass to manipulate the request or metadata @@ -318,8 +331,10 @@ def post_analyze_move( def pre_analyze_org_policies( self, request: asset_service.AnalyzeOrgPoliciesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[asset_service.AnalyzeOrgPoliciesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + asset_service.AnalyzeOrgPoliciesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for analyze_org_policies Override in a subclass to manipulate the request or metadata @@ -341,9 +356,10 @@ def post_analyze_org_policies( def pre_analyze_org_policy_governed_assets( self, request: asset_service.AnalyzeOrgPolicyGovernedAssetsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - asset_service.AnalyzeOrgPolicyGovernedAssetsRequest, Sequence[Tuple[str, str]] + asset_service.AnalyzeOrgPolicyGovernedAssetsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for analyze_org_policy_governed_assets @@ -366,10 +382,10 @@ def post_analyze_org_policy_governed_assets( def pre_analyze_org_policy_governed_containers( self, request: asset_service.AnalyzeOrgPolicyGovernedContainersRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ asset_service.AnalyzeOrgPolicyGovernedContainersRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for analyze_org_policy_governed_containers @@ -392,8 +408,11 @@ def post_analyze_org_policy_governed_containers( def pre_batch_get_assets_history( self, request: asset_service.BatchGetAssetsHistoryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[asset_service.BatchGetAssetsHistoryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + asset_service.BatchGetAssetsHistoryRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for batch_get_assets_history Override in a subclass to manipulate the request or metadata @@ -415,9 +434,10 @@ def post_batch_get_assets_history( def pre_batch_get_effective_iam_policies( self, request: asset_service.BatchGetEffectiveIamPoliciesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - asset_service.BatchGetEffectiveIamPoliciesRequest, Sequence[Tuple[str, str]] + asset_service.BatchGetEffectiveIamPoliciesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for batch_get_effective_iam_policies @@ -440,8 +460,10 @@ def post_batch_get_effective_iam_policies( def pre_create_feed( self, request: asset_service.CreateFeedRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[asset_service.CreateFeedRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + asset_service.CreateFeedRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_feed Override in a subclass to manipulate the request or metadata @@ -461,8 +483,10 @@ def post_create_feed(self, response: asset_service.Feed) -> asset_service.Feed: def pre_create_saved_query( self, request: asset_service.CreateSavedQueryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[asset_service.CreateSavedQueryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + asset_service.CreateSavedQueryRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_saved_query Override in a subclass to manipulate the request or metadata @@ -484,8 +508,10 @@ def post_create_saved_query( def pre_delete_feed( self, request: asset_service.DeleteFeedRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[asset_service.DeleteFeedRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + asset_service.DeleteFeedRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_feed Override in a subclass to manipulate the request or metadata @@ -496,8 +522,10 @@ def pre_delete_feed( def pre_delete_saved_query( self, request: asset_service.DeleteSavedQueryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[asset_service.DeleteSavedQueryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + asset_service.DeleteSavedQueryRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_saved_query Override in a subclass to manipulate the request or metadata @@ -508,8 +536,10 @@ def pre_delete_saved_query( def pre_export_assets( self, request: asset_service.ExportAssetsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[asset_service.ExportAssetsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + asset_service.ExportAssetsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for export_assets Override in a subclass to manipulate the request or metadata @@ -529,8 +559,10 @@ def post_export_assets( return response def pre_get_feed( - self, request: asset_service.GetFeedRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[asset_service.GetFeedRequest, Sequence[Tuple[str, str]]]: + self, + request: asset_service.GetFeedRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[asset_service.GetFeedRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_feed Override in a subclass to manipulate the request or metadata @@ -550,8 +582,10 @@ def post_get_feed(self, response: asset_service.Feed) -> asset_service.Feed: def pre_get_saved_query( self, request: asset_service.GetSavedQueryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[asset_service.GetSavedQueryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + asset_service.GetSavedQueryRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_saved_query Override in a subclass to manipulate the request or metadata @@ -573,8 +607,10 @@ def post_get_saved_query( def pre_list_assets( self, request: asset_service.ListAssetsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[asset_service.ListAssetsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + asset_service.ListAssetsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_assets Override in a subclass to manipulate the request or metadata @@ -596,8 +632,8 @@ def post_list_assets( def pre_list_feeds( self, request: asset_service.ListFeedsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[asset_service.ListFeedsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[asset_service.ListFeedsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_feeds Override in a subclass to manipulate the request or metadata @@ -619,8 +655,10 @@ def post_list_feeds( def pre_list_saved_queries( self, request: asset_service.ListSavedQueriesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[asset_service.ListSavedQueriesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + asset_service.ListSavedQueriesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_saved_queries Override in a subclass to manipulate the request or metadata @@ -642,8 +680,10 @@ def post_list_saved_queries( def pre_query_assets( self, request: asset_service.QueryAssetsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[asset_service.QueryAssetsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + asset_service.QueryAssetsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for query_assets Override in a subclass to manipulate the request or metadata @@ -665,8 +705,11 @@ def post_query_assets( def pre_search_all_iam_policies( self, request: asset_service.SearchAllIamPoliciesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[asset_service.SearchAllIamPoliciesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + asset_service.SearchAllIamPoliciesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for search_all_iam_policies Override in a subclass to manipulate the request or metadata @@ -688,8 +731,10 @@ def post_search_all_iam_policies( def pre_search_all_resources( self, request: asset_service.SearchAllResourcesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[asset_service.SearchAllResourcesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + asset_service.SearchAllResourcesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for search_all_resources Override in a subclass to manipulate the request or metadata @@ -711,8 +756,10 @@ def post_search_all_resources( def pre_update_feed( self, request: asset_service.UpdateFeedRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[asset_service.UpdateFeedRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + asset_service.UpdateFeedRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_feed Override in a subclass to manipulate the request or metadata @@ -732,8 +779,10 @@ def post_update_feed(self, response: asset_service.Feed) -> asset_service.Feed: def pre_update_saved_query( self, request: asset_service.UpdateSavedQueryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[asset_service.UpdateSavedQueryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + asset_service.UpdateSavedQueryRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_saved_query Override in a subclass to manipulate the request or metadata @@ -755,8 +804,10 @@ def post_update_saved_query( 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 @@ -931,7 +982,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.AnalyzeIamPolicyResponse: r"""Call the analyze iam policy method over HTTP. @@ -942,8 +993,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.asset_service.AnalyzeIamPolicyResponse: @@ -955,6 +1008,7 @@ def __call__( http_options = ( _BaseAssetServiceRestTransport._BaseAnalyzeIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_analyze_iam_policy( request, metadata ) @@ -967,6 +1021,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.asset_v1.AssetServiceClient.AnalyzeIamPolicy", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "AnalyzeIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AssetServiceRestTransport._AnalyzeIamPolicy._get_response( self._host, @@ -987,7 +1068,31 @@ def __call__( pb_resp = asset_service.AnalyzeIamPolicyResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_analyze_iam_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = asset_service.AnalyzeIamPolicyResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.asset_v1.AssetServiceClient.analyze_iam_policy", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "AnalyzeIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _AnalyzeIamPolicyLongrunning( @@ -1026,7 +1131,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 iam policy longrunning method over HTTP. @@ -1038,8 +1143,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1052,6 +1159,7 @@ def __call__( http_options = ( _BaseAssetServiceRestTransport._BaseAnalyzeIamPolicyLongrunning._get_http_options() ) + request, metadata = self._interceptor.pre_analyze_iam_policy_longrunning( request, metadata ) @@ -1068,6 +1176,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.asset_v1.AssetServiceClient.AnalyzeIamPolicyLongrunning", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "AnalyzeIamPolicyLongrunning", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AssetServiceRestTransport._AnalyzeIamPolicyLongrunning._get_response( @@ -1089,7 +1224,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_iam_policy_longrunning(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.asset_v1.AssetServiceClient.analyze_iam_policy_longrunning", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "AnalyzeIamPolicyLongrunning", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _AnalyzeMove( @@ -1126,7 +1283,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.AnalyzeMoveResponse: r"""Call the analyze move method over HTTP. @@ -1137,8 +1294,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.asset_service.AnalyzeMoveResponse: @@ -1150,6 +1309,7 @@ def __call__( http_options = ( _BaseAssetServiceRestTransport._BaseAnalyzeMove._get_http_options() ) + request, metadata = self._interceptor.pre_analyze_move(request, metadata) transcoded_request = ( _BaseAssetServiceRestTransport._BaseAnalyzeMove._get_transcoded_request( @@ -1164,6 +1324,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.asset_v1.AssetServiceClient.AnalyzeMove", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "AnalyzeMove", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AssetServiceRestTransport._AnalyzeMove._get_response( self._host, @@ -1184,7 +1371,31 @@ def __call__( pb_resp = asset_service.AnalyzeMoveResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_analyze_move(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = asset_service.AnalyzeMoveResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.asset_v1.AssetServiceClient.analyze_move", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "AnalyzeMove", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _AnalyzeOrgPolicies( @@ -1221,7 +1432,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.AnalyzeOrgPoliciesResponse: r"""Call the analyze org policies method over HTTP. @@ -1232,8 +1443,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.asset_service.AnalyzeOrgPoliciesResponse: @@ -1245,6 +1458,7 @@ def __call__( http_options = ( _BaseAssetServiceRestTransport._BaseAnalyzeOrgPolicies._get_http_options() ) + request, metadata = self._interceptor.pre_analyze_org_policies( request, metadata ) @@ -1257,6 +1471,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.asset_v1.AssetServiceClient.AnalyzeOrgPolicies", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "AnalyzeOrgPolicies", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AssetServiceRestTransport._AnalyzeOrgPolicies._get_response( self._host, @@ -1277,7 +1518,31 @@ def __call__( pb_resp = asset_service.AnalyzeOrgPoliciesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_analyze_org_policies(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = asset_service.AnalyzeOrgPoliciesResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.asset_v1.AssetServiceClient.analyze_org_policies", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "AnalyzeOrgPolicies", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _AnalyzeOrgPolicyGovernedAssets( @@ -1315,7 +1580,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.AnalyzeOrgPolicyGovernedAssetsResponse: r"""Call the analyze org policy governed assets method over HTTP. @@ -1327,8 +1592,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.asset_service.AnalyzeOrgPolicyGovernedAssetsResponse: @@ -1340,6 +1607,7 @@ def __call__( http_options = ( _BaseAssetServiceRestTransport._BaseAnalyzeOrgPolicyGovernedAssets._get_http_options() ) + ( request, metadata, @@ -1355,6 +1623,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.asset_v1.AssetServiceClient.AnalyzeOrgPolicyGovernedAssets", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "AnalyzeOrgPolicyGovernedAssets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AssetServiceRestTransport._AnalyzeOrgPolicyGovernedAssets._get_response( @@ -1377,7 +1672,33 @@ def __call__( pb_resp = asset_service.AnalyzeOrgPolicyGovernedAssetsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_analyze_org_policy_governed_assets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + asset_service.AnalyzeOrgPolicyGovernedAssetsResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.asset_v1.AssetServiceClient.analyze_org_policy_governed_assets", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "AnalyzeOrgPolicyGovernedAssets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _AnalyzeOrgPolicyGovernedContainers( @@ -1415,7 +1736,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.AnalyzeOrgPolicyGovernedContainersResponse: r"""Call the analyze org policy governed containers method over HTTP. @@ -1427,8 +1748,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.asset_service.AnalyzeOrgPolicyGovernedContainersResponse: @@ -1440,6 +1763,7 @@ def __call__( http_options = ( _BaseAssetServiceRestTransport._BaseAnalyzeOrgPolicyGovernedContainers._get_http_options() ) + ( request, metadata, @@ -1455,6 +1779,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.asset_v1.AssetServiceClient.AnalyzeOrgPolicyGovernedContainers", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "AnalyzeOrgPolicyGovernedContainers", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AssetServiceRestTransport._AnalyzeOrgPolicyGovernedContainers._get_response( self._host, @@ -1475,7 +1826,31 @@ def __call__( pb_resp = asset_service.AnalyzeOrgPolicyGovernedContainersResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_analyze_org_policy_governed_containers(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = asset_service.AnalyzeOrgPolicyGovernedContainersResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.asset_v1.AssetServiceClient.analyze_org_policy_governed_containers", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "AnalyzeOrgPolicyGovernedContainers", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchGetAssetsHistory( @@ -1512,7 +1887,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.BatchGetAssetsHistoryResponse: r"""Call the batch get assets history method over HTTP. @@ -1522,8 +1897,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.asset_service.BatchGetAssetsHistoryResponse: @@ -1533,6 +1910,7 @@ def __call__( http_options = ( _BaseAssetServiceRestTransport._BaseBatchGetAssetsHistory._get_http_options() ) + request, metadata = self._interceptor.pre_batch_get_assets_history( request, metadata ) @@ -1545,6 +1923,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.asset_v1.AssetServiceClient.BatchGetAssetsHistory", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "BatchGetAssetsHistory", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AssetServiceRestTransport._BatchGetAssetsHistory._get_response( self._host, @@ -1565,7 +1970,31 @@ def __call__( pb_resp = asset_service.BatchGetAssetsHistoryResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_get_assets_history(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + asset_service.BatchGetAssetsHistoryResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.asset_v1.AssetServiceClient.batch_get_assets_history", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "BatchGetAssetsHistory", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _BatchGetEffectiveIamPolicies( @@ -1603,7 +2032,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.BatchGetEffectiveIamPoliciesResponse: r"""Call the batch get effective iam policies method over HTTP. @@ -1615,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: ~.asset_service.BatchGetEffectiveIamPoliciesResponse: @@ -1628,6 +2059,7 @@ def __call__( http_options = ( _BaseAssetServiceRestTransport._BaseBatchGetEffectiveIamPolicies._get_http_options() ) + request, metadata = self._interceptor.pre_batch_get_effective_iam_policies( request, metadata ) @@ -1640,6 +2072,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.asset_v1.AssetServiceClient.BatchGetEffectiveIamPolicies", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "BatchGetEffectiveIamPolicies", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AssetServiceRestTransport._BatchGetEffectiveIamPolicies._get_response( @@ -1662,7 +2121,33 @@ def __call__( pb_resp = asset_service.BatchGetEffectiveIamPoliciesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_batch_get_effective_iam_policies(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + asset_service.BatchGetEffectiveIamPoliciesResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.asset_v1.AssetServiceClient.batch_get_effective_iam_policies", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "BatchGetEffectiveIamPolicies", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateFeed( @@ -1700,7 +2185,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.Feed: r"""Call the create feed method over HTTP. @@ -1710,8 +2195,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.asset_service.Feed: @@ -1729,6 +2216,7 @@ def __call__( http_options = ( _BaseAssetServiceRestTransport._BaseCreateFeed._get_http_options() ) + request, metadata = self._interceptor.pre_create_feed(request, metadata) transcoded_request = ( _BaseAssetServiceRestTransport._BaseCreateFeed._get_transcoded_request( @@ -1749,6 +2237,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.asset_v1.AssetServiceClient.CreateFeed", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "CreateFeed", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AssetServiceRestTransport._CreateFeed._get_response( self._host, @@ -1770,7 +2285,29 @@ def __call__( pb_resp = asset_service.Feed.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_feed(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = asset_service.Feed.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.asset_v1.AssetServiceClient.create_feed", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "CreateFeed", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSavedQuery( @@ -1808,7 +2345,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.SavedQuery: r"""Call the create saved query method over HTTP. @@ -1818,8 +2355,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.asset_service.SavedQuery: @@ -1831,6 +2370,7 @@ def __call__( http_options = ( _BaseAssetServiceRestTransport._BaseCreateSavedQuery._get_http_options() ) + request, metadata = self._interceptor.pre_create_saved_query( request, metadata ) @@ -1847,6 +2387,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.asset_v1.AssetServiceClient.CreateSavedQuery", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "CreateSavedQuery", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AssetServiceRestTransport._CreateSavedQuery._get_response( self._host, @@ -1868,7 +2435,29 @@ def __call__( pb_resp = asset_service.SavedQuery.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_saved_query(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = asset_service.SavedQuery.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.asset_v1.AssetServiceClient.create_saved_query", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "CreateSavedQuery", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteFeed( @@ -1905,7 +2494,7 @@ 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 feed method over HTTP. @@ -1915,13 +2504,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 = ( _BaseAssetServiceRestTransport._BaseDeleteFeed._get_http_options() ) + request, metadata = self._interceptor.pre_delete_feed(request, metadata) transcoded_request = ( _BaseAssetServiceRestTransport._BaseDeleteFeed._get_transcoded_request( @@ -1936,6 +2528,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.asset_v1.AssetServiceClient.DeleteFeed", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "DeleteFeed", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AssetServiceRestTransport._DeleteFeed._get_response( self._host, @@ -1985,7 +2604,7 @@ 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 saved query method over HTTP. @@ -1995,13 +2614,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 = ( _BaseAssetServiceRestTransport._BaseDeleteSavedQuery._get_http_options() ) + request, metadata = self._interceptor.pre_delete_saved_query( request, metadata ) @@ -2014,6 +2636,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.asset_v1.AssetServiceClient.DeleteSavedQuery", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "DeleteSavedQuery", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AssetServiceRestTransport._DeleteSavedQuery._get_response( self._host, @@ -2064,7 +2713,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the export assets method over HTTP. @@ -2074,8 +2723,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2088,6 +2739,7 @@ def __call__( http_options = ( _BaseAssetServiceRestTransport._BaseExportAssets._get_http_options() ) + request, metadata = self._interceptor.pre_export_assets(request, metadata) transcoded_request = _BaseAssetServiceRestTransport._BaseExportAssets._get_transcoded_request( http_options, request @@ -2106,6 +2758,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.asset_v1.AssetServiceClient.ExportAssets", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "ExportAssets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AssetServiceRestTransport._ExportAssets._get_response( self._host, @@ -2125,7 +2804,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_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.asset_v1.AssetServiceClient.export_assets", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "ExportAssets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetFeed(_BaseAssetServiceRestTransport._BaseGetFeed, AssetServiceRestStub): @@ -2160,7 +2861,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.Feed: r"""Call the get feed method over HTTP. @@ -2170,8 +2871,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.asset_service.Feed: @@ -2189,6 +2892,7 @@ def __call__( http_options = ( _BaseAssetServiceRestTransport._BaseGetFeed._get_http_options() ) + request, metadata = self._interceptor.pre_get_feed(request, metadata) transcoded_request = ( _BaseAssetServiceRestTransport._BaseGetFeed._get_transcoded_request( @@ -2203,6 +2907,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.asset_v1.AssetServiceClient.GetFeed", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "GetFeed", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AssetServiceRestTransport._GetFeed._get_response( self._host, @@ -2223,7 +2954,29 @@ def __call__( pb_resp = asset_service.Feed.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_feed(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = asset_service.Feed.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.asset_v1.AssetServiceClient.get_feed", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "GetFeed", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetSavedQuery( @@ -2260,7 +3013,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.SavedQuery: r"""Call the get saved query method over HTTP. @@ -2270,8 +3023,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.asset_service.SavedQuery: @@ -2283,6 +3038,7 @@ def __call__( http_options = ( _BaseAssetServiceRestTransport._BaseGetSavedQuery._get_http_options() ) + request, metadata = self._interceptor.pre_get_saved_query(request, metadata) transcoded_request = _BaseAssetServiceRestTransport._BaseGetSavedQuery._get_transcoded_request( http_options, request @@ -2293,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.asset_v1.AssetServiceClient.GetSavedQuery", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "GetSavedQuery", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AssetServiceRestTransport._GetSavedQuery._get_response( self._host, @@ -2313,7 +3096,29 @@ def __call__( pb_resp = asset_service.SavedQuery.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_saved_query(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = asset_service.SavedQuery.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.asset_v1.AssetServiceClient.get_saved_query", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "GetSavedQuery", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAssets( @@ -2350,7 +3155,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.ListAssetsResponse: r"""Call the list assets method over HTTP. @@ -2360,8 +3165,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.asset_service.ListAssetsResponse: @@ -2371,6 +3178,7 @@ def __call__( http_options = ( _BaseAssetServiceRestTransport._BaseListAssets._get_http_options() ) + request, metadata = self._interceptor.pre_list_assets(request, metadata) transcoded_request = ( _BaseAssetServiceRestTransport._BaseListAssets._get_transcoded_request( @@ -2385,6 +3193,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.asset_v1.AssetServiceClient.ListAssets", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "ListAssets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AssetServiceRestTransport._ListAssets._get_response( self._host, @@ -2405,7 +3240,31 @@ def __call__( pb_resp = asset_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 = asset_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.asset_v1.AssetServiceClient.list_assets", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "ListAssets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListFeeds( @@ -2442,7 +3301,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.ListFeedsResponse: r"""Call the list feeds method over HTTP. @@ -2452,8 +3311,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.asset_service.ListFeedsResponse: @@ -2463,6 +3324,7 @@ def __call__( http_options = ( _BaseAssetServiceRestTransport._BaseListFeeds._get_http_options() ) + request, metadata = self._interceptor.pre_list_feeds(request, metadata) transcoded_request = ( _BaseAssetServiceRestTransport._BaseListFeeds._get_transcoded_request( @@ -2477,6 +3339,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.asset_v1.AssetServiceClient.ListFeeds", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "ListFeeds", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AssetServiceRestTransport._ListFeeds._get_response( self._host, @@ -2497,7 +3386,29 @@ def __call__( pb_resp = asset_service.ListFeedsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_feeds(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = asset_service.ListFeedsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.asset_v1.AssetServiceClient.list_feeds", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "ListFeeds", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSavedQueries( @@ -2534,7 +3445,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.ListSavedQueriesResponse: r"""Call the list saved queries method over HTTP. @@ -2544,8 +3455,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.asset_service.ListSavedQueriesResponse: @@ -2555,6 +3468,7 @@ def __call__( http_options = ( _BaseAssetServiceRestTransport._BaseListSavedQueries._get_http_options() ) + request, metadata = self._interceptor.pre_list_saved_queries( request, metadata ) @@ -2567,6 +3481,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.asset_v1.AssetServiceClient.ListSavedQueries", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "ListSavedQueries", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AssetServiceRestTransport._ListSavedQueries._get_response( self._host, @@ -2587,7 +3528,31 @@ def __call__( pb_resp = asset_service.ListSavedQueriesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_saved_queries(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = asset_service.ListSavedQueriesResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.asset_v1.AssetServiceClient.list_saved_queries", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "ListSavedQueries", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _QueryAssets( @@ -2625,7 +3590,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.QueryAssetsResponse: r"""Call the query assets method over HTTP. @@ -2635,8 +3600,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.asset_service.QueryAssetsResponse: @@ -2646,6 +3613,7 @@ def __call__( http_options = ( _BaseAssetServiceRestTransport._BaseQueryAssets._get_http_options() ) + request, metadata = self._interceptor.pre_query_assets(request, metadata) transcoded_request = ( _BaseAssetServiceRestTransport._BaseQueryAssets._get_transcoded_request( @@ -2666,6 +3634,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.asset_v1.AssetServiceClient.QueryAssets", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "QueryAssets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AssetServiceRestTransport._QueryAssets._get_response( self._host, @@ -2687,7 +3682,31 @@ def __call__( pb_resp = asset_service.QueryAssetsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_query_assets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = asset_service.QueryAssetsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.asset_v1.AssetServiceClient.query_assets", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "QueryAssets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchAllIamPolicies( @@ -2724,7 +3743,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.SearchAllIamPoliciesResponse: r"""Call the search all iam policies method over HTTP. @@ -2734,8 +3753,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.asset_service.SearchAllIamPoliciesResponse: @@ -2745,6 +3766,7 @@ def __call__( http_options = ( _BaseAssetServiceRestTransport._BaseSearchAllIamPolicies._get_http_options() ) + request, metadata = self._interceptor.pre_search_all_iam_policies( request, metadata ) @@ -2757,6 +3779,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.asset_v1.AssetServiceClient.SearchAllIamPolicies", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "SearchAllIamPolicies", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AssetServiceRestTransport._SearchAllIamPolicies._get_response( self._host, @@ -2777,7 +3826,31 @@ def __call__( pb_resp = asset_service.SearchAllIamPoliciesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_all_iam_policies(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + asset_service.SearchAllIamPoliciesResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.asset_v1.AssetServiceClient.search_all_iam_policies", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "SearchAllIamPolicies", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchAllResources( @@ -2814,7 +3887,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.SearchAllResourcesResponse: r"""Call the search all resources method over HTTP. @@ -2824,8 +3897,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.asset_service.SearchAllResourcesResponse: @@ -2835,6 +3910,7 @@ def __call__( http_options = ( _BaseAssetServiceRestTransport._BaseSearchAllResources._get_http_options() ) + request, metadata = self._interceptor.pre_search_all_resources( request, metadata ) @@ -2847,6 +3923,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.asset_v1.AssetServiceClient.SearchAllResources", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "SearchAllResources", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AssetServiceRestTransport._SearchAllResources._get_response( self._host, @@ -2867,7 +3970,31 @@ def __call__( pb_resp = asset_service.SearchAllResourcesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_all_resources(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = asset_service.SearchAllResourcesResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.asset_v1.AssetServiceClient.search_all_resources", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "SearchAllResources", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateFeed( @@ -2905,7 +4032,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.Feed: r"""Call the update feed method over HTTP. @@ -2915,8 +4042,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.asset_service.Feed: @@ -2934,6 +4063,7 @@ def __call__( http_options = ( _BaseAssetServiceRestTransport._BaseUpdateFeed._get_http_options() ) + request, metadata = self._interceptor.pre_update_feed(request, metadata) transcoded_request = ( _BaseAssetServiceRestTransport._BaseUpdateFeed._get_transcoded_request( @@ -2954,6 +4084,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.asset_v1.AssetServiceClient.UpdateFeed", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "UpdateFeed", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AssetServiceRestTransport._UpdateFeed._get_response( self._host, @@ -2975,7 +4132,29 @@ def __call__( pb_resp = asset_service.Feed.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_feed(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = asset_service.Feed.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.asset_v1.AssetServiceClient.update_feed", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "UpdateFeed", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateSavedQuery( @@ -3013,7 +4192,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.SavedQuery: r"""Call the update saved query method over HTTP. @@ -3023,8 +4202,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.asset_service.SavedQuery: @@ -3036,6 +4217,7 @@ def __call__( http_options = ( _BaseAssetServiceRestTransport._BaseUpdateSavedQuery._get_http_options() ) + request, metadata = self._interceptor.pre_update_saved_query( request, metadata ) @@ -3052,6 +4234,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.asset_v1.AssetServiceClient.UpdateSavedQuery", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "UpdateSavedQuery", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AssetServiceRestTransport._UpdateSavedQuery._get_response( self._host, @@ -3073,7 +4282,29 @@ def __call__( pb_resp = asset_service.SavedQuery.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_saved_query(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = asset_service.SavedQuery.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.asset_v1.AssetServiceClient.update_saved_query", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "UpdateSavedQuery", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -3327,7 +4558,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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. @@ -3337,8 +4568,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -3347,6 +4580,7 @@ def __call__( http_options = ( _BaseAssetServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseAssetServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -3359,6 +4593,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.asset_v1.AssetServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AssetServiceRestTransport._GetOperation._get_response( self._host, @@ -3378,6 +4639,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.asset_v1.AssetServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.asset.v1.AssetService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-asset/google/cloud/asset_v1p1beta1/gapic_version.py b/packages/google-cloud-asset/google/cloud/asset_v1p1beta1/gapic_version.py index 7af2fa694463..558c8aab67c5 100644 --- a/packages/google-cloud-asset/google/cloud/asset_v1p1beta1/gapic_version.py +++ b/packages/google-cloud-asset/google/cloud/asset_v1p1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "3.27.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-asset/google/cloud/asset_v1p1beta1/services/asset_service/async_client.py b/packages/google-cloud-asset/google/cloud/asset_v1p1beta1/services/asset_service/async_client.py index 2448592a9eda..8343fbadafe5 100644 --- a/packages/google-cloud-asset/google/cloud/asset_v1p1beta1/services/asset_service/async_client.py +++ b/packages/google-cloud-asset/google/cloud/asset_v1p1beta1/services/asset_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, AssetServiceTransport from .transports.grpc_asyncio import AssetServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class AssetServiceAsyncClient: """Asset service definition.""" @@ -250,6 +260,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.asset_v1p1beta1.AssetServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.asset.v1p1beta1.AssetService", + "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.asset.v1p1beta1.AssetService", + "credentialsType": None, + }, + ) + async def search_all_resources( self, request: Optional[Union[asset_service.SearchAllResourcesRequest, dict]] = None, @@ -259,7 +291,7 @@ async def search_all_resources( asset_types: 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]]] = (), ) -> pagers.SearchAllResourcesAsyncPager: r"""Searches all the resources within a given accessible Resource Manager scope (project/folder/organization). This RPC gives @@ -329,8 +361,10 @@ async def sample_search_all_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.asset_v1p1beta1.services.asset_service.pagers.SearchAllResourcesAsyncPager: @@ -412,7 +446,7 @@ async def search_all_iam_policies( query: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchAllIamPoliciesAsyncPager: r"""Searches all the IAM policies within a given accessible Resource Manager scope (project/folder/organization). This RPC gives @@ -478,8 +512,10 @@ async def sample_search_all_iam_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.asset_v1p1beta1.services.asset_service.pagers.SearchAllIamPoliciesAsyncPager: diff --git a/packages/google-cloud-asset/google/cloud/asset_v1p1beta1/services/asset_service/client.py b/packages/google-cloud-asset/google/cloud/asset_v1p1beta1/services/asset_service/client.py index ef68719ec45e..6b3bcdb97929 100644 --- a/packages/google-cloud-asset/google/cloud/asset_v1p1beta1/services/asset_service/client.py +++ b/packages/google-cloud-asset/google/cloud/asset_v1p1beta1/services/asset_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.longrunning import operations_pb2 # type: ignore from google.cloud.asset_v1p1beta1.services.asset_service import pagers @@ -556,6 +566,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -618,6 +632,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.asset_v1p1beta1.AssetServiceClient`.", + extra={ + "serviceName": "google.cloud.asset.v1p1beta1.AssetService", + "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.asset.v1p1beta1.AssetService", + "credentialsType": None, + }, + ) + def search_all_resources( self, request: Optional[Union[asset_service.SearchAllResourcesRequest, dict]] = None, @@ -627,7 +664,7 @@ def search_all_resources( asset_types: 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]]] = (), ) -> pagers.SearchAllResourcesPager: r"""Searches all the resources within a given accessible Resource Manager scope (project/folder/organization). This RPC gives @@ -697,8 +734,10 @@ def sample_search_all_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.asset_v1p1beta1.services.asset_service.pagers.SearchAllResourcesPager: @@ -777,7 +816,7 @@ def search_all_iam_policies( query: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.SearchAllIamPoliciesPager: r"""Searches all the IAM policies within a given accessible Resource Manager scope (project/folder/organization). This RPC gives @@ -843,8 +882,10 @@ def sample_search_all_iam_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.asset_v1p1beta1.services.asset_service.pagers.SearchAllIamPoliciesPager: diff --git a/packages/google-cloud-asset/google/cloud/asset_v1p1beta1/services/asset_service/pagers.py b/packages/google-cloud-asset/google/cloud/asset_v1p1beta1/services/asset_service/pagers.py index bc7ade2ca51e..4066d9a629e3 100644 --- a/packages/google-cloud-asset/google/cloud/asset_v1p1beta1/services/asset_service/pagers.py +++ b/packages/google-cloud-asset/google/cloud/asset_v1p1beta1/services/asset_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 = asset_service.SearchAllResourcesRequest(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 = asset_service.SearchAllResourcesRequest(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 = asset_service.SearchAllIamPoliciesRequest(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 = asset_service.SearchAllIamPoliciesRequest(request) diff --git a/packages/google-cloud-asset/google/cloud/asset_v1p1beta1/services/asset_service/transports/grpc.py b/packages/google-cloud-asset/google/cloud/asset_v1p1beta1/services/asset_service/transports/grpc.py index f09ed8840e9b..e2872fb1b344 100644 --- a/packages/google-cloud-asset/google/cloud/asset_v1p1beta1/services/asset_service/transports/grpc.py +++ b/packages/google-cloud-asset/google/cloud/asset_v1p1beta1/services/asset_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.asset_v1p1beta1.types import asset_service from .base import DEFAULT_CLIENT_INFO, AssetServiceTransport +try: + from google.api_core import client_logging # 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.asset.v1p1beta1.AssetService", + "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.asset.v1p1beta1.AssetService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AssetServiceGrpcTransport(AssetServiceTransport): """gRPC backend transport for AssetService. @@ -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 @@ -263,7 +349,7 @@ def search_all_resources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_all_resources" not in self._stubs: - self._stubs["search_all_resources"] = self.grpc_channel.unary_unary( + self._stubs["search_all_resources"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1p1beta1.AssetService/SearchAllResources", request_serializer=asset_service.SearchAllResourcesRequest.serialize, response_deserializer=asset_service.SearchAllResourcesResponse.deserialize, @@ -299,7 +385,7 @@ def search_all_iam_policies( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_all_iam_policies" not in self._stubs: - self._stubs["search_all_iam_policies"] = self.grpc_channel.unary_unary( + self._stubs["search_all_iam_policies"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1p1beta1.AssetService/SearchAllIamPolicies", request_serializer=asset_service.SearchAllIamPoliciesRequest.serialize, response_deserializer=asset_service.SearchAllIamPoliciesResponse.deserialize, @@ -307,7 +393,7 @@ def search_all_iam_policies( return self._stubs["search_all_iam_policies"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-asset/google/cloud/asset_v1p1beta1/services/asset_service/transports/grpc_asyncio.py b/packages/google-cloud-asset/google/cloud/asset_v1p1beta1/services/asset_service/transports/grpc_asyncio.py index c56df87eee09..281f29206909 100644 --- a/packages/google-cloud-asset/google/cloud/asset_v1p1beta1/services/asset_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-asset/google/cloud/asset_v1p1beta1/services/asset_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.asset_v1p1beta1.types import asset_service from .base import DEFAULT_CLIENT_INFO, AssetServiceTransport from .grpc import AssetServiceGrpcTransport +try: + from google.api_core import client_logging # 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.asset.v1p1beta1.AssetService", + "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.asset.v1p1beta1.AssetService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AssetServiceGrpcAsyncIOTransport(AssetServiceTransport): """gRPC AsyncIO backend transport for AssetService. @@ -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 @@ -271,7 +356,7 @@ def search_all_resources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_all_resources" not in self._stubs: - self._stubs["search_all_resources"] = self.grpc_channel.unary_unary( + self._stubs["search_all_resources"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1p1beta1.AssetService/SearchAllResources", request_serializer=asset_service.SearchAllResourcesRequest.serialize, response_deserializer=asset_service.SearchAllResourcesResponse.deserialize, @@ -307,7 +392,7 @@ def search_all_iam_policies( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_all_iam_policies" not in self._stubs: - self._stubs["search_all_iam_policies"] = self.grpc_channel.unary_unary( + self._stubs["search_all_iam_policies"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1p1beta1.AssetService/SearchAllIamPolicies", request_serializer=asset_service.SearchAllIamPoliciesRequest.serialize, response_deserializer=asset_service.SearchAllIamPoliciesResponse.deserialize, @@ -355,7 +440,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-asset/google/cloud/asset_v1p1beta1/services/asset_service/transports/rest.py b/packages/google-cloud-asset/google/cloud/asset_v1p1beta1/services/asset_service/transports/rest.py index 3a49670a5662..75b7f92f1c1d 100644 --- a/packages/google-cloud-asset/google/cloud/asset_v1p1beta1/services/asset_service/transports/rest.py +++ b/packages/google-cloud-asset/google/cloud/asset_v1p1beta1/services/asset_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -38,6 +38,14 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = logging.getLogger(__name__) DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, @@ -86,8 +94,11 @@ def post_search_all_resources(self, response): def pre_search_all_iam_policies( self, request: asset_service.SearchAllIamPoliciesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[asset_service.SearchAllIamPoliciesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + asset_service.SearchAllIamPoliciesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for search_all_iam_policies Override in a subclass to manipulate the request or metadata @@ -109,8 +120,10 @@ def post_search_all_iam_policies( def pre_search_all_resources( self, request: asset_service.SearchAllResourcesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[asset_service.SearchAllResourcesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + asset_service.SearchAllResourcesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for search_all_resources Override in a subclass to manipulate the request or metadata @@ -250,7 +263,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.SearchAllIamPoliciesResponse: r"""Call the search all iam policies method over HTTP. @@ -260,8 +273,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.asset_service.SearchAllIamPoliciesResponse: @@ -271,6 +286,7 @@ def __call__( http_options = ( _BaseAssetServiceRestTransport._BaseSearchAllIamPolicies._get_http_options() ) + request, metadata = self._interceptor.pre_search_all_iam_policies( request, metadata ) @@ -283,6 +299,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.asset_v1p1beta1.AssetServiceClient.SearchAllIamPolicies", + extra={ + "serviceName": "google.cloud.asset.v1p1beta1.AssetService", + "rpcName": "SearchAllIamPolicies", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AssetServiceRestTransport._SearchAllIamPolicies._get_response( self._host, @@ -303,7 +346,31 @@ def __call__( pb_resp = asset_service.SearchAllIamPoliciesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_all_iam_policies(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + asset_service.SearchAllIamPoliciesResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.asset_v1p1beta1.AssetServiceClient.search_all_iam_policies", + extra={ + "serviceName": "google.cloud.asset.v1p1beta1.AssetService", + "rpcName": "SearchAllIamPolicies", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchAllResources( @@ -340,7 +407,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.SearchAllResourcesResponse: r"""Call the search all resources method over HTTP. @@ -350,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: ~.asset_service.SearchAllResourcesResponse: @@ -361,6 +430,7 @@ def __call__( http_options = ( _BaseAssetServiceRestTransport._BaseSearchAllResources._get_http_options() ) + request, metadata = self._interceptor.pre_search_all_resources( request, metadata ) @@ -373,6 +443,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.asset_v1p1beta1.AssetServiceClient.SearchAllResources", + extra={ + "serviceName": "google.cloud.asset.v1p1beta1.AssetService", + "rpcName": "SearchAllResources", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AssetServiceRestTransport._SearchAllResources._get_response( self._host, @@ -393,7 +490,31 @@ def __call__( pb_resp = asset_service.SearchAllResourcesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_all_resources(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = asset_service.SearchAllResourcesResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.asset_v1p1beta1.AssetServiceClient.search_all_resources", + extra={ + "serviceName": "google.cloud.asset.v1p1beta1.AssetService", + "rpcName": "SearchAllResources", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-asset/google/cloud/asset_v1p2beta1/gapic_version.py b/packages/google-cloud-asset/google/cloud/asset_v1p2beta1/gapic_version.py index 7af2fa694463..558c8aab67c5 100644 --- a/packages/google-cloud-asset/google/cloud/asset_v1p2beta1/gapic_version.py +++ b/packages/google-cloud-asset/google/cloud/asset_v1p2beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "3.27.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-asset/google/cloud/asset_v1p2beta1/services/asset_service/async_client.py b/packages/google-cloud-asset/google/cloud/asset_v1p2beta1/services/asset_service/async_client.py index d06b2cd16643..d5e3753e1036 100644 --- a/packages/google-cloud-asset/google/cloud/asset_v1p2beta1/services/asset_service/async_client.py +++ b/packages/google-cloud-asset/google/cloud/asset_v1p2beta1/services/asset_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, @@ -50,6 +51,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, AssetServiceTransport from .transports.grpc_asyncio import AssetServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class AssetServiceAsyncClient: """Asset service definition.""" @@ -251,6 +261,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.asset_v1p2beta1.AssetServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.asset.v1p2beta1.AssetService", + "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.asset.v1p2beta1.AssetService", + "credentialsType": None, + }, + ) + async def create_feed( self, request: Optional[Union[asset_service.CreateFeedRequest, dict]] = None, @@ -258,7 +290,7 @@ async def create_feed( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.Feed: r"""Creates a feed in a parent project/folder/organization to listen to its asset @@ -315,8 +347,10 @@ async def sample_create_feed(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.asset_v1p2beta1.types.Feed: @@ -383,7 +417,7 @@ async def get_feed( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.Feed: r"""Gets details about an asset feed. @@ -428,8 +462,10 @@ async def sample_get_feed(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.asset_v1p2beta1.types.Feed: @@ -494,7 +530,7 @@ async def list_feeds( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.ListFeedsResponse: r"""Lists all asset feeds in a parent project/folder/organization. @@ -542,8 +578,10 @@ async def sample_list_feeds(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.asset_v1p2beta1.types.ListFeedsResponse: @@ -602,7 +640,7 @@ async def update_feed( feed: Optional[asset_service.Feed] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.Feed: r"""Updates an asset feed configuration. @@ -651,8 +689,10 @@ async def sample_update_feed(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.asset_v1p2beta1.types.Feed: @@ -721,7 +761,7 @@ async def delete_feed( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 asset feed. @@ -763,8 +803,10 @@ async def sample_delete_feed(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -815,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. @@ -826,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. diff --git a/packages/google-cloud-asset/google/cloud/asset_v1p2beta1/services/asset_service/client.py b/packages/google-cloud-asset/google/cloud/asset_v1p2beta1/services/asset_service/client.py index 6a8d3d767b4a..bb244420c734 100644 --- a/packages/google-cloud-asset/google/cloud/asset_v1p2beta1/services/asset_service/client.py +++ b/packages/google-cloud-asset/google/cloud/asset_v1p2beta1/services/asset_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.longrunning import operations_pb2 # type: ignore from google.cloud.asset_v1p2beta1.types import asset_service @@ -572,6 +582,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( @@ -634,6 +648,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.asset_v1p2beta1.AssetServiceClient`.", + extra={ + "serviceName": "google.cloud.asset.v1p2beta1.AssetService", + "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.asset.v1p2beta1.AssetService", + "credentialsType": None, + }, + ) + def create_feed( self, request: Optional[Union[asset_service.CreateFeedRequest, dict]] = None, @@ -641,7 +678,7 @@ def create_feed( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.Feed: r"""Creates a feed in a parent project/folder/organization to listen to its asset @@ -698,8 +735,10 @@ def sample_create_feed(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.asset_v1p2beta1.types.Feed: @@ -763,7 +802,7 @@ def get_feed( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.Feed: r"""Gets details about an asset feed. @@ -808,8 +847,10 @@ def sample_get_feed(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.asset_v1p2beta1.types.Feed: @@ -873,7 +914,7 @@ def list_feeds( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.ListFeedsResponse: r"""Lists all asset feeds in a parent project/folder/organization. @@ -921,8 +962,10 @@ def sample_list_feeds(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.asset_v1p2beta1.types.ListFeedsResponse: @@ -978,7 +1021,7 @@ def update_feed( feed: Optional[asset_service.Feed] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.Feed: r"""Updates an asset feed configuration. @@ -1027,8 +1070,10 @@ def sample_update_feed(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.asset_v1p2beta1.types.Feed: @@ -1094,7 +1139,7 @@ def delete_feed( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 asset feed. @@ -1136,8 +1181,10 @@ def sample_delete_feed(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -1198,7 +1245,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. @@ -1209,8 +1256,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-asset/google/cloud/asset_v1p2beta1/services/asset_service/transports/grpc.py b/packages/google-cloud-asset/google/cloud/asset_v1p2beta1/services/asset_service/transports/grpc.py index 4366e0f9f31d..d35920d10f95 100644 --- a/packages/google-cloud-asset/google/cloud/asset_v1p2beta1/services/asset_service/transports/grpc.py +++ b/packages/google-cloud-asset/google/cloud/asset_v1p2beta1/services/asset_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.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.asset_v1p2beta1.types import asset_service from .base import DEFAULT_CLIENT_INFO, AssetServiceTransport +try: + from google.api_core import client_logging # 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.asset.v1p2beta1.AssetService", + "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.asset.v1p2beta1.AssetService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AssetServiceGrpcTransport(AssetServiceTransport): """gRPC backend transport for AssetService. @@ -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 @@ -257,7 +343,7 @@ def create_feed( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_feed" not in self._stubs: - self._stubs["create_feed"] = self.grpc_channel.unary_unary( + self._stubs["create_feed"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1p2beta1.AssetService/CreateFeed", request_serializer=asset_service.CreateFeedRequest.serialize, response_deserializer=asset_service.Feed.deserialize, @@ -281,7 +367,7 @@ def get_feed(self) -> Callable[[asset_service.GetFeedRequest], asset_service.Fee # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_feed" not in self._stubs: - self._stubs["get_feed"] = self.grpc_channel.unary_unary( + self._stubs["get_feed"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1p2beta1.AssetService/GetFeed", request_serializer=asset_service.GetFeedRequest.serialize, response_deserializer=asset_service.Feed.deserialize, @@ -308,7 +394,7 @@ def list_feeds( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_feeds" not in self._stubs: - self._stubs["list_feeds"] = self.grpc_channel.unary_unary( + self._stubs["list_feeds"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1p2beta1.AssetService/ListFeeds", request_serializer=asset_service.ListFeedsRequest.serialize, response_deserializer=asset_service.ListFeedsResponse.deserialize, @@ -334,7 +420,7 @@ def update_feed( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_feed" not in self._stubs: - self._stubs["update_feed"] = self.grpc_channel.unary_unary( + self._stubs["update_feed"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1p2beta1.AssetService/UpdateFeed", request_serializer=asset_service.UpdateFeedRequest.serialize, response_deserializer=asset_service.Feed.deserialize, @@ -360,7 +446,7 @@ def delete_feed( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_feed" not in self._stubs: - self._stubs["delete_feed"] = self.grpc_channel.unary_unary( + self._stubs["delete_feed"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1p2beta1.AssetService/DeleteFeed", request_serializer=asset_service.DeleteFeedRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -368,7 +454,7 @@ def delete_feed( return self._stubs["delete_feed"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -380,7 +466,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-asset/google/cloud/asset_v1p2beta1/services/asset_service/transports/grpc_asyncio.py b/packages/google-cloud-asset/google/cloud/asset_v1p2beta1/services/asset_service/transports/grpc_asyncio.py index de0dd9e0653d..41d8c2470e6a 100644 --- a/packages/google-cloud-asset/google/cloud/asset_v1p2beta1/services/asset_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-asset/google/cloud/asset_v1p2beta1/services/asset_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.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.asset_v1p2beta1.types import asset_service from .base import DEFAULT_CLIENT_INFO, AssetServiceTransport from .grpc import AssetServiceGrpcTransport +try: + from google.api_core import client_logging # 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.asset.v1p2beta1.AssetService", + "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.asset.v1p2beta1.AssetService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AssetServiceGrpcAsyncIOTransport(AssetServiceTransport): """gRPC AsyncIO backend transport for AssetService. @@ -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 @@ -265,7 +350,7 @@ def create_feed( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_feed" not in self._stubs: - self._stubs["create_feed"] = self.grpc_channel.unary_unary( + self._stubs["create_feed"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1p2beta1.AssetService/CreateFeed", request_serializer=asset_service.CreateFeedRequest.serialize, response_deserializer=asset_service.Feed.deserialize, @@ -291,7 +376,7 @@ def get_feed( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_feed" not in self._stubs: - self._stubs["get_feed"] = self.grpc_channel.unary_unary( + self._stubs["get_feed"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1p2beta1.AssetService/GetFeed", request_serializer=asset_service.GetFeedRequest.serialize, response_deserializer=asset_service.Feed.deserialize, @@ -320,7 +405,7 @@ def list_feeds( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_feeds" not in self._stubs: - self._stubs["list_feeds"] = self.grpc_channel.unary_unary( + self._stubs["list_feeds"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1p2beta1.AssetService/ListFeeds", request_serializer=asset_service.ListFeedsRequest.serialize, response_deserializer=asset_service.ListFeedsResponse.deserialize, @@ -346,7 +431,7 @@ def update_feed( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_feed" not in self._stubs: - self._stubs["update_feed"] = self.grpc_channel.unary_unary( + self._stubs["update_feed"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1p2beta1.AssetService/UpdateFeed", request_serializer=asset_service.UpdateFeedRequest.serialize, response_deserializer=asset_service.Feed.deserialize, @@ -372,7 +457,7 @@ def delete_feed( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_feed" not in self._stubs: - self._stubs["delete_feed"] = self.grpc_channel.unary_unary( + self._stubs["delete_feed"] = self._logged_channel.unary_unary( "/google.cloud.asset.v1p2beta1.AssetService/DeleteFeed", request_serializer=asset_service.DeleteFeedRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -450,7 +535,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: @@ -466,7 +551,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-asset/google/cloud/asset_v1p2beta1/services/asset_service/transports/rest.py b/packages/google-cloud-asset/google/cloud/asset_v1p2beta1/services/asset_service/transports/rest.py index 370ad9ed1214..732090cba91f 100644 --- a/packages/google-cloud-asset/google/cloud/asset_v1p2beta1/services/asset_service/transports/rest.py +++ b/packages/google-cloud-asset/google/cloud/asset_v1p2beta1/services/asset_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, @@ -107,8 +115,10 @@ def post_update_feed(self, response): def pre_create_feed( self, request: asset_service.CreateFeedRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[asset_service.CreateFeedRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + asset_service.CreateFeedRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_feed Override in a subclass to manipulate the request or metadata @@ -128,8 +138,10 @@ def post_create_feed(self, response: asset_service.Feed) -> asset_service.Feed: def pre_delete_feed( self, request: asset_service.DeleteFeedRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[asset_service.DeleteFeedRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + asset_service.DeleteFeedRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_feed Override in a subclass to manipulate the request or metadata @@ -138,8 +150,10 @@ def pre_delete_feed( return request, metadata def pre_get_feed( - self, request: asset_service.GetFeedRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[asset_service.GetFeedRequest, Sequence[Tuple[str, str]]]: + self, + request: asset_service.GetFeedRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[asset_service.GetFeedRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_feed Override in a subclass to manipulate the request or metadata @@ -159,8 +173,8 @@ def post_get_feed(self, response: asset_service.Feed) -> asset_service.Feed: def pre_list_feeds( self, request: asset_service.ListFeedsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[asset_service.ListFeedsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[asset_service.ListFeedsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_feeds Override in a subclass to manipulate the request or metadata @@ -182,8 +196,10 @@ def post_list_feeds( def pre_update_feed( self, request: asset_service.UpdateFeedRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[asset_service.UpdateFeedRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + asset_service.UpdateFeedRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_feed Override in a subclass to manipulate the request or metadata @@ -203,8 +219,10 @@ def post_update_feed(self, response: asset_service.Feed) -> asset_service.Feed: 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 @@ -345,7 +363,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.Feed: r"""Call the create feed method over HTTP. @@ -355,8 +373,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.asset_service.Feed: @@ -374,6 +394,7 @@ def __call__( http_options = ( _BaseAssetServiceRestTransport._BaseCreateFeed._get_http_options() ) + request, metadata = self._interceptor.pre_create_feed(request, metadata) transcoded_request = ( _BaseAssetServiceRestTransport._BaseCreateFeed._get_transcoded_request( @@ -394,6 +415,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.asset_v1p2beta1.AssetServiceClient.CreateFeed", + extra={ + "serviceName": "google.cloud.asset.v1p2beta1.AssetService", + "rpcName": "CreateFeed", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AssetServiceRestTransport._CreateFeed._get_response( self._host, @@ -415,7 +463,29 @@ def __call__( pb_resp = asset_service.Feed.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_feed(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = asset_service.Feed.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.asset_v1p2beta1.AssetServiceClient.create_feed", + extra={ + "serviceName": "google.cloud.asset.v1p2beta1.AssetService", + "rpcName": "CreateFeed", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteFeed( @@ -452,7 +522,7 @@ 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 feed method over HTTP. @@ -462,13 +532,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 = ( _BaseAssetServiceRestTransport._BaseDeleteFeed._get_http_options() ) + request, metadata = self._interceptor.pre_delete_feed(request, metadata) transcoded_request = ( _BaseAssetServiceRestTransport._BaseDeleteFeed._get_transcoded_request( @@ -483,6 +556,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.asset_v1p2beta1.AssetServiceClient.DeleteFeed", + extra={ + "serviceName": "google.cloud.asset.v1p2beta1.AssetService", + "rpcName": "DeleteFeed", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AssetServiceRestTransport._DeleteFeed._get_response( self._host, @@ -530,7 +630,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.Feed: r"""Call the get feed method over HTTP. @@ -540,8 +640,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.asset_service.Feed: @@ -559,6 +661,7 @@ def __call__( http_options = ( _BaseAssetServiceRestTransport._BaseGetFeed._get_http_options() ) + request, metadata = self._interceptor.pre_get_feed(request, metadata) transcoded_request = ( _BaseAssetServiceRestTransport._BaseGetFeed._get_transcoded_request( @@ -573,6 +676,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.asset_v1p2beta1.AssetServiceClient.GetFeed", + extra={ + "serviceName": "google.cloud.asset.v1p2beta1.AssetService", + "rpcName": "GetFeed", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AssetServiceRestTransport._GetFeed._get_response( self._host, @@ -593,7 +723,29 @@ def __call__( pb_resp = asset_service.Feed.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_feed(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = asset_service.Feed.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.asset_v1p2beta1.AssetServiceClient.get_feed", + extra={ + "serviceName": "google.cloud.asset.v1p2beta1.AssetService", + "rpcName": "GetFeed", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListFeeds( @@ -630,7 +782,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.ListFeedsResponse: r"""Call the list feeds method over HTTP. @@ -640,8 +792,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.asset_service.ListFeedsResponse: @@ -651,6 +805,7 @@ def __call__( http_options = ( _BaseAssetServiceRestTransport._BaseListFeeds._get_http_options() ) + request, metadata = self._interceptor.pre_list_feeds(request, metadata) transcoded_request = ( _BaseAssetServiceRestTransport._BaseListFeeds._get_transcoded_request( @@ -665,6 +820,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.asset_v1p2beta1.AssetServiceClient.ListFeeds", + extra={ + "serviceName": "google.cloud.asset.v1p2beta1.AssetService", + "rpcName": "ListFeeds", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AssetServiceRestTransport._ListFeeds._get_response( self._host, @@ -685,7 +867,29 @@ def __call__( pb_resp = asset_service.ListFeedsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_feeds(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = asset_service.ListFeedsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.asset_v1p2beta1.AssetServiceClient.list_feeds", + extra={ + "serviceName": "google.cloud.asset.v1p2beta1.AssetService", + "rpcName": "ListFeeds", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateFeed( @@ -723,7 +927,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.Feed: r"""Call the update feed method over HTTP. @@ -733,8 +937,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.asset_service.Feed: @@ -752,6 +958,7 @@ def __call__( http_options = ( _BaseAssetServiceRestTransport._BaseUpdateFeed._get_http_options() ) + request, metadata = self._interceptor.pre_update_feed(request, metadata) transcoded_request = ( _BaseAssetServiceRestTransport._BaseUpdateFeed._get_transcoded_request( @@ -772,6 +979,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.asset_v1p2beta1.AssetServiceClient.UpdateFeed", + extra={ + "serviceName": "google.cloud.asset.v1p2beta1.AssetService", + "rpcName": "UpdateFeed", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AssetServiceRestTransport._UpdateFeed._get_response( self._host, @@ -793,7 +1027,29 @@ def __call__( pb_resp = asset_service.Feed.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_feed(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = asset_service.Feed.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.asset_v1p2beta1.AssetServiceClient.update_feed", + extra={ + "serviceName": "google.cloud.asset.v1p2beta1.AssetService", + "rpcName": "UpdateFeed", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -872,7 +1128,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -882,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: Response from GetOperation method. @@ -892,6 +1150,7 @@ def __call__( http_options = ( _BaseAssetServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseAssetServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -904,6 +1163,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.asset_v1p2beta1.AssetServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.asset.v1p2beta1.AssetService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AssetServiceRestTransport._GetOperation._get_response( self._host, @@ -923,6 +1209,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.asset_v1p2beta1.AssetServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.asset.v1p2beta1.AssetService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-asset/google/cloud/asset_v1p5beta1/gapic_version.py b/packages/google-cloud-asset/google/cloud/asset_v1p5beta1/gapic_version.py index 7af2fa694463..558c8aab67c5 100644 --- a/packages/google-cloud-asset/google/cloud/asset_v1p5beta1/gapic_version.py +++ b/packages/google-cloud-asset/google/cloud/asset_v1p5beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "3.27.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-asset/google/cloud/asset_v1p5beta1/services/asset_service/async_client.py b/packages/google-cloud-asset/google/cloud/asset_v1p5beta1/services/asset_service/async_client.py index 0cbe928ee9ea..d702fd530ab8 100644 --- a/packages/google-cloud-asset/google/cloud/asset_v1p5beta1/services/asset_service/async_client.py +++ b/packages/google-cloud-asset/google/cloud/asset_v1p5beta1/services/asset_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, AssetServiceTransport from .transports.grpc_asyncio import AssetServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class AssetServiceAsyncClient: """Asset service definition.""" @@ -260,6 +270,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.asset_v1p5beta1.AssetServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.asset.v1p5beta1.AssetService", + "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.asset.v1p5beta1.AssetService", + "credentialsType": None, + }, + ) + async def list_assets( self, request: Optional[Union[asset_service.ListAssetsRequest, dict]] = None, @@ -267,7 +299,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 assets with time and resource types and returns paged results in response. @@ -315,8 +347,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.asset_v1p5beta1.services.asset_service.pagers.ListAssetsAsyncPager: diff --git a/packages/google-cloud-asset/google/cloud/asset_v1p5beta1/services/asset_service/client.py b/packages/google-cloud-asset/google/cloud/asset_v1p5beta1/services/asset_service/client.py index ce6688ec0ca9..d2ba26ca61ef 100644 --- a/packages/google-cloud-asset/google/cloud/asset_v1p5beta1/services/asset_service/client.py +++ b/packages/google-cloud-asset/google/cloud/asset_v1p5beta1/services/asset_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.longrunning import operations_pb2 # type: ignore from google.cloud.asset_v1p5beta1.services.asset_service import pagers @@ -622,6 +632,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -684,6 +698,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.asset_v1p5beta1.AssetServiceClient`.", + extra={ + "serviceName": "google.cloud.asset.v1p5beta1.AssetService", + "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.asset.v1p5beta1.AssetService", + "credentialsType": None, + }, + ) + def list_assets( self, request: Optional[Union[asset_service.ListAssetsRequest, dict]] = None, @@ -691,7 +728,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 assets with time and resource types and returns paged results in response. @@ -739,8 +776,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.asset_v1p5beta1.services.asset_service.pagers.ListAssetsPager: diff --git a/packages/google-cloud-asset/google/cloud/asset_v1p5beta1/services/asset_service/pagers.py b/packages/google-cloud-asset/google/cloud/asset_v1p5beta1/services/asset_service/pagers.py index e89c30292083..73466a761718 100644 --- a/packages/google-cloud-asset/google/cloud/asset_v1p5beta1/services/asset_service/pagers.py +++ b/packages/google-cloud-asset/google/cloud/asset_v1p5beta1/services/asset_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 = asset_service.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 = asset_service.ListAssetsRequest(request) diff --git a/packages/google-cloud-asset/google/cloud/asset_v1p5beta1/services/asset_service/transports/grpc.py b/packages/google-cloud-asset/google/cloud/asset_v1p5beta1/services/asset_service/transports/grpc.py index c8600596328d..149724cf5ac6 100644 --- a/packages/google-cloud-asset/google/cloud/asset_v1p5beta1/services/asset_service/transports/grpc.py +++ b/packages/google-cloud-asset/google/cloud/asset_v1p5beta1/services/asset_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.asset_v1p5beta1.types import asset_service from .base import DEFAULT_CLIENT_INFO, AssetServiceTransport +try: + from google.api_core import client_logging # 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.asset.v1p5beta1.AssetService", + "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.asset.v1p5beta1.AssetService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AssetServiceGrpcTransport(AssetServiceTransport): """gRPC backend transport for AssetService. @@ -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 @@ -255,7 +341,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.asset.v1p5beta1.AssetService/ListAssets", request_serializer=asset_service.ListAssetsRequest.serialize, response_deserializer=asset_service.ListAssetsResponse.deserialize, @@ -263,7 +349,7 @@ def list_assets( return self._stubs["list_assets"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-asset/google/cloud/asset_v1p5beta1/services/asset_service/transports/grpc_asyncio.py b/packages/google-cloud-asset/google/cloud/asset_v1p5beta1/services/asset_service/transports/grpc_asyncio.py index 860ba2104a66..fa23b129fde3 100644 --- a/packages/google-cloud-asset/google/cloud/asset_v1p5beta1/services/asset_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-asset/google/cloud/asset_v1p5beta1/services/asset_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.asset_v1p5beta1.types import asset_service from .base import DEFAULT_CLIENT_INFO, AssetServiceTransport from .grpc import AssetServiceGrpcTransport +try: + from google.api_core import client_logging # 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.asset.v1p5beta1.AssetService", + "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.asset.v1p5beta1.AssetService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AssetServiceGrpcAsyncIOTransport(AssetServiceTransport): """gRPC AsyncIO backend transport for AssetService. @@ -227,10 +309,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientAIOInterceptor() + self._grpc_channel._unary_unary_interceptors.append(self._interceptor) + self._logged_channel = self._grpc_channel self._wrap_with_kind = ( "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters ) + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @property @@ -265,7 +350,7 @@ def list_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.asset.v1p5beta1.AssetService/ListAssets", request_serializer=asset_service.ListAssetsRequest.serialize, response_deserializer=asset_service.ListAssetsResponse.deserialize, @@ -298,7 +383,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-asset/google/cloud/asset_v1p5beta1/services/asset_service/transports/rest.py b/packages/google-cloud-asset/google/cloud/asset_v1p5beta1/services/asset_service/transports/rest.py index bb7ba386feb7..0f27d605b35c 100644 --- a/packages/google-cloud-asset/google/cloud/asset_v1p5beta1/services/asset_service/transports/rest.py +++ b/packages/google-cloud-asset/google/cloud/asset_v1p5beta1/services/asset_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_list_assets(self, response): def pre_list_assets( self, request: asset_service.ListAssetsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[asset_service.ListAssetsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + asset_service.ListAssetsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_assets Override in a subclass to manipulate the request or metadata @@ -219,7 +229,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> asset_service.ListAssetsResponse: r"""Call the list assets method over HTTP. @@ -229,8 +239,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.asset_service.ListAssetsResponse: @@ -240,6 +252,7 @@ def __call__( http_options = ( _BaseAssetServiceRestTransport._BaseListAssets._get_http_options() ) + request, metadata = self._interceptor.pre_list_assets(request, metadata) transcoded_request = ( _BaseAssetServiceRestTransport._BaseListAssets._get_transcoded_request( @@ -254,6 +267,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.asset_v1p5beta1.AssetServiceClient.ListAssets", + extra={ + "serviceName": "google.cloud.asset.v1p5beta1.AssetService", + "rpcName": "ListAssets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AssetServiceRestTransport._ListAssets._get_response( self._host, @@ -274,7 +314,31 @@ def __call__( pb_resp = asset_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 = asset_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.asset_v1p5beta1.AssetServiceClient.list_assets", + extra={ + "serviceName": "google.cloud.asset.v1p5beta1.AssetService", + "rpcName": "ListAssets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-asset/samples/generated_samples/snippet_metadata_google.cloud.asset.v1.json b/packages/google-cloud-asset/samples/generated_samples/snippet_metadata_google.cloud.asset.v1.json index adaf8664d0c3..211efb19c2ad 100644 --- a/packages/google-cloud-asset/samples/generated_samples/snippet_metadata_google.cloud.asset.v1.json +++ b/packages/google-cloud-asset/samples/generated_samples/snippet_metadata_google.cloud.asset.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-asset", - "version": "3.27.1" + "version": "0.1.0" }, "snippets": [ { @@ -43,7 +43,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -196,7 +196,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.types.AnalyzeIamPolicyResponse", @@ -272,7 +272,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.types.AnalyzeIamPolicyResponse", @@ -349,7 +349,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.types.AnalyzeMoveResponse", @@ -425,7 +425,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.types.AnalyzeMoveResponse", @@ -514,7 +514,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.services.asset_service.pagers.AnalyzeOrgPoliciesAsyncPager", @@ -602,7 +602,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.services.asset_service.pagers.AnalyzeOrgPoliciesPager", @@ -691,7 +691,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.services.asset_service.pagers.AnalyzeOrgPolicyGovernedAssetsAsyncPager", @@ -779,7 +779,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.services.asset_service.pagers.AnalyzeOrgPolicyGovernedAssetsPager", @@ -868,7 +868,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.services.asset_service.pagers.AnalyzeOrgPolicyGovernedContainersAsyncPager", @@ -956,7 +956,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.services.asset_service.pagers.AnalyzeOrgPolicyGovernedContainersPager", @@ -1033,7 +1033,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.types.BatchGetAssetsHistoryResponse", @@ -1109,7 +1109,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.types.BatchGetAssetsHistoryResponse", @@ -1186,7 +1186,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.types.BatchGetEffectiveIamPoliciesResponse", @@ -1262,7 +1262,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.types.BatchGetEffectiveIamPoliciesResponse", @@ -1343,7 +1343,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.types.Feed", @@ -1423,7 +1423,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.types.Feed", @@ -1512,7 +1512,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.types.SavedQuery", @@ -1600,7 +1600,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.types.SavedQuery", @@ -1681,7 +1681,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_feed" @@ -1758,7 +1758,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_feed" @@ -1836,7 +1836,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_saved_query" @@ -1913,7 +1913,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_saved_query" @@ -1987,7 +1987,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2063,7 +2063,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2144,7 +2144,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.types.Feed", @@ -2224,7 +2224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.types.Feed", @@ -2305,7 +2305,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.types.SavedQuery", @@ -2385,7 +2385,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.types.SavedQuery", @@ -2466,7 +2466,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.services.asset_service.pagers.ListAssetsAsyncPager", @@ -2546,7 +2546,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.services.asset_service.pagers.ListAssetsPager", @@ -2627,7 +2627,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.types.ListFeedsResponse", @@ -2707,7 +2707,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.types.ListFeedsResponse", @@ -2788,7 +2788,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.services.asset_service.pagers.ListSavedQueriesAsyncPager", @@ -2868,7 +2868,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.services.asset_service.pagers.ListSavedQueriesPager", @@ -2945,7 +2945,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.types.QueryAssetsResponse", @@ -3021,7 +3021,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.types.QueryAssetsResponse", @@ -3106,7 +3106,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.services.asset_service.pagers.SearchAllIamPoliciesAsyncPager", @@ -3190,7 +3190,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.services.asset_service.pagers.SearchAllIamPoliciesPager", @@ -3279,7 +3279,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.services.asset_service.pagers.SearchAllResourcesAsyncPager", @@ -3367,7 +3367,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.services.asset_service.pagers.SearchAllResourcesPager", @@ -3448,7 +3448,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.types.Feed", @@ -3528,7 +3528,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.types.Feed", @@ -3613,7 +3613,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.types.SavedQuery", @@ -3697,7 +3697,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1.types.SavedQuery", diff --git a/packages/google-cloud-asset/samples/generated_samples/snippet_metadata_google.cloud.asset.v1p1beta1.json b/packages/google-cloud-asset/samples/generated_samples/snippet_metadata_google.cloud.asset.v1p1beta1.json index 2842e3347574..13d603d43770 100644 --- a/packages/google-cloud-asset/samples/generated_samples/snippet_metadata_google.cloud.asset.v1p1beta1.json +++ b/packages/google-cloud-asset/samples/generated_samples/snippet_metadata_google.cloud.asset.v1p1beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-asset", - "version": "3.27.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.asset_v1p1beta1.services.asset_service.pagers.SearchAllIamPoliciesAsyncPager", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1p1beta1.services.asset_service.pagers.SearchAllIamPoliciesPager", @@ -224,7 +224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1p1beta1.services.asset_service.pagers.SearchAllResourcesAsyncPager", @@ -312,7 +312,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1p1beta1.services.asset_service.pagers.SearchAllResourcesPager", diff --git a/packages/google-cloud-asset/samples/generated_samples/snippet_metadata_google.cloud.asset.v1p2beta1.json b/packages/google-cloud-asset/samples/generated_samples/snippet_metadata_google.cloud.asset.v1p2beta1.json index e542094192d6..abb0badfbf70 100644 --- a/packages/google-cloud-asset/samples/generated_samples/snippet_metadata_google.cloud.asset.v1p2beta1.json +++ b/packages/google-cloud-asset/samples/generated_samples/snippet_metadata_google.cloud.asset.v1p2beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-asset", - "version": "3.27.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.asset_v1p2beta1.types.Feed", @@ -127,7 +127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1p2beta1.types.Feed", @@ -208,7 +208,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_feed" @@ -285,7 +285,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_feed" @@ -363,7 +363,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1p2beta1.types.Feed", @@ -443,7 +443,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1p2beta1.types.Feed", @@ -524,7 +524,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1p2beta1.types.ListFeedsResponse", @@ -604,7 +604,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1p2beta1.types.ListFeedsResponse", @@ -685,7 +685,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1p2beta1.types.Feed", @@ -765,7 +765,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1p2beta1.types.Feed", diff --git a/packages/google-cloud-asset/samples/generated_samples/snippet_metadata_google.cloud.asset.v1p5beta1.json b/packages/google-cloud-asset/samples/generated_samples/snippet_metadata_google.cloud.asset.v1p5beta1.json index 902ea38b5ad3..2b27b5681d7c 100644 --- a/packages/google-cloud-asset/samples/generated_samples/snippet_metadata_google.cloud.asset.v1p5beta1.json +++ b/packages/google-cloud-asset/samples/generated_samples/snippet_metadata_google.cloud.asset.v1p5beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-asset", - "version": "3.27.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.asset_v1p5beta1.services.asset_service.pagers.ListAssetsAsyncPager", @@ -127,7 +127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.asset_v1p5beta1.services.asset_service.pagers.ListAssetsPager", diff --git a/packages/google-cloud-asset/tests/unit/gapic/asset_v1/test_asset_service.py b/packages/google-cloud-asset/tests/unit/gapic/asset_v1/test_asset_service.py index 1be19ffc7a4e..819d95e9e05f 100644 --- a/packages/google-cloud-asset/tests/unit/gapic/asset_v1/test_asset_service.py +++ b/packages/google-cloud-asset/tests/unit/gapic/asset_v1/test_asset_service.py @@ -9873,6 +9873,7 @@ def test_export_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.export_assets(request) @@ -10009,6 +10010,7 @@ def test_list_assets_rest_required_fields(request_type=asset_service.ListAssetsR response_value._content = json_return_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) @@ -10066,6 +10068,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) @@ -10270,6 +10273,7 @@ def test_batch_get_assets_history_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.batch_get_assets_history(request) @@ -10402,6 +10406,7 @@ def test_create_feed_rest_required_fields(request_type=asset_service.CreateFeedR response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_feed(request) @@ -10456,6 +10461,7 @@ def test_create_feed_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_feed(**mock_args) @@ -10583,6 +10589,7 @@ def test_get_feed_rest_required_fields(request_type=asset_service.GetFeedRequest response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_feed(request) @@ -10628,6 +10635,7 @@ def test_get_feed_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_feed(**mock_args) @@ -10755,6 +10763,7 @@ def test_list_feeds_rest_required_fields(request_type=asset_service.ListFeedsReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_feeds(request) @@ -10800,6 +10809,7 @@ def test_list_feeds_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_feeds(**mock_args) @@ -10923,6 +10933,7 @@ def test_update_feed_rest_required_fields(request_type=asset_service.UpdateFeedR response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_feed(request) @@ -10976,6 +10987,7 @@ def test_update_feed_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_feed(**mock_args) @@ -11100,6 +11112,7 @@ def test_delete_feed_rest_required_fields(request_type=asset_service.DeleteFeedR response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_feed(request) @@ -11143,6 +11156,7 @@ def test_delete_feed_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_feed(**mock_args) @@ -11287,6 +11301,7 @@ def test_search_all_resources_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.search_all_resources(request) @@ -11346,6 +11361,7 @@ def test_search_all_resources_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.search_all_resources(**mock_args) @@ -11555,6 +11571,7 @@ def test_search_all_iam_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.search_all_iam_policies(request) @@ -11612,6 +11629,7 @@ def test_search_all_iam_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.search_all_iam_policies(**mock_args) @@ -11812,6 +11830,7 @@ def test_analyze_iam_policy_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.analyze_iam_policy(request) @@ -11942,6 +11961,7 @@ def test_analyze_iam_policy_longrunning_rest_required_fields( response_value._content = json_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_iam_policy_longrunning(request) @@ -12085,6 +12105,7 @@ def test_analyze_move_rest_required_fields( response_value._content = json_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_move(request) @@ -12224,6 +12245,7 @@ def test_query_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.query_assets(request) @@ -12357,6 +12379,7 @@ def test_create_saved_query_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_saved_query(request) @@ -12419,6 +12442,7 @@ def test_create_saved_query_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_saved_query(**mock_args) @@ -12550,6 +12574,7 @@ def test_get_saved_query_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_saved_query(request) @@ -12595,6 +12620,7 @@ def test_get_saved_query_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_saved_query(**mock_args) @@ -12736,6 +12762,7 @@ def test_list_saved_queries_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_saved_queries(request) @@ -12790,6 +12817,7 @@ def test_list_saved_queries_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_saved_queries(**mock_args) @@ -12984,6 +13012,7 @@ def test_update_saved_query_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_saved_query(request) @@ -13040,6 +13069,7 @@ def test_update_saved_query_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_saved_query(**mock_args) @@ -13172,6 +13202,7 @@ def test_delete_saved_query_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_saved_query(request) @@ -13215,6 +13246,7 @@ def test_delete_saved_query_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_saved_query(**mock_args) @@ -13360,6 +13392,7 @@ def test_batch_get_effective_iam_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.batch_get_effective_iam_policies(request) @@ -13515,6 +13548,7 @@ def test_analyze_org_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.analyze_org_policies(request) @@ -13583,6 +13617,7 @@ def test_analyze_org_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.analyze_org_policies(**mock_args) @@ -13807,6 +13842,7 @@ def test_analyze_org_policy_governed_containers_rest_required_fields( response_value._content = json_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_org_policy_governed_containers(request) @@ -13879,6 +13915,7 @@ def test_analyze_org_policy_governed_containers_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.analyze_org_policy_governed_containers(**mock_args) @@ -14109,6 +14146,7 @@ def test_analyze_org_policy_governed_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.analyze_org_policy_governed_assets(request) @@ -14181,6 +14219,7 @@ def test_analyze_org_policy_governed_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.analyze_org_policy_governed_assets(**mock_args) @@ -15588,6 +15627,7 @@ def test_export_assets_rest_bad_request(request_type=asset_service.ExportAssetsR response_value.status_code = 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_assets(request) @@ -15618,6 +15658,7 @@ def test_export_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.export_assets(request) # Establish that the response is the type that we expect. @@ -15659,6 +15700,7 @@ def test_export_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 @@ -15701,6 +15743,7 @@ def test_list_assets_rest_bad_request(request_type=asset_service.ListAssetsReque response_value.status_code = 400 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) @@ -15736,6 +15779,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. @@ -15776,6 +15820,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 = asset_service.ListAssetsResponse.to_json( asset_service.ListAssetsResponse() ) @@ -15822,6 +15867,7 @@ def test_batch_get_assets_history_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.batch_get_assets_history(request) @@ -15855,6 +15901,7 @@ def test_batch_get_assets_history_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.batch_get_assets_history(request) # Establish that the response is the type that we expect. @@ -15894,6 +15941,7 @@ def test_batch_get_assets_history_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = asset_service.BatchGetAssetsHistoryResponse.to_json( asset_service.BatchGetAssetsHistoryResponse() ) @@ -15938,6 +15986,7 @@ def test_create_feed_rest_bad_request(request_type=asset_service.CreateFeedReque response_value.status_code = 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_feed(request) @@ -15977,6 +16026,7 @@ def test_create_feed_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_feed(request) # Establish that the response is the type that we expect. @@ -16021,6 +16071,7 @@ def test_create_feed_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = asset_service.Feed.to_json(asset_service.Feed()) req.return_value.content = return_value @@ -16063,6 +16114,7 @@ def test_get_feed_rest_bad_request(request_type=asset_service.GetFeedRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_feed(request) @@ -16102,6 +16154,7 @@ def test_get_feed_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_feed(request) # Establish that the response is the type that we expect. @@ -16144,6 +16197,7 @@ def test_get_feed_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = asset_service.Feed.to_json(asset_service.Feed()) req.return_value.content = return_value @@ -16186,6 +16240,7 @@ def test_list_feeds_rest_bad_request(request_type=asset_service.ListFeedsRequest response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_feeds(request) @@ -16219,6 +16274,7 @@ def test_list_feeds_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_feeds(request) # Establish that the response is the type that we expect. @@ -16256,6 +16312,7 @@ def test_list_feeds_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = asset_service.ListFeedsResponse.to_json( asset_service.ListFeedsResponse() ) @@ -16300,6 +16357,7 @@ def test_update_feed_rest_bad_request(request_type=asset_service.UpdateFeedReque response_value.status_code = 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_feed(request) @@ -16339,6 +16397,7 @@ def test_update_feed_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_feed(request) # Establish that the response is the type that we expect. @@ -16383,6 +16442,7 @@ def test_update_feed_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = asset_service.Feed.to_json(asset_service.Feed()) req.return_value.content = return_value @@ -16425,6 +16485,7 @@ def test_delete_feed_rest_bad_request(request_type=asset_service.DeleteFeedReque response_value.status_code = 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_feed(request) @@ -16455,6 +16516,7 @@ def test_delete_feed_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_feed(request) # Establish that the response is the type that we expect. @@ -16491,6 +16553,7 @@ def test_delete_feed_rest_interceptors(null_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 = asset_service.DeleteFeedRequest() metadata = [ @@ -16531,6 +16594,7 @@ def test_search_all_resources_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.search_all_resources(request) @@ -16566,6 +16630,7 @@ def test_search_all_resources_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.search_all_resources(request) # Establish that the response is the type that we expect. @@ -16606,6 +16671,7 @@ def test_search_all_resources_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = asset_service.SearchAllResourcesResponse.to_json( asset_service.SearchAllResourcesResponse() ) @@ -16652,6 +16718,7 @@ def test_search_all_iam_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.search_all_iam_policies(request) @@ -16687,6 +16754,7 @@ def test_search_all_iam_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.search_all_iam_policies(request) # Establish that the response is the type that we expect. @@ -16727,6 +16795,7 @@ def test_search_all_iam_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 = asset_service.SearchAllIamPoliciesResponse.to_json( asset_service.SearchAllIamPoliciesResponse() ) @@ -16773,6 +16842,7 @@ def test_analyze_iam_policy_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.analyze_iam_policy(request) @@ -16808,6 +16878,7 @@ def test_analyze_iam_policy_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.analyze_iam_policy(request) # Establish that the response is the type that we expect. @@ -16848,6 +16919,7 @@ def test_analyze_iam_policy_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = asset_service.AnalyzeIamPolicyResponse.to_json( asset_service.AnalyzeIamPolicyResponse() ) @@ -16894,6 +16966,7 @@ def test_analyze_iam_policy_longrunning_rest_bad_request( response_value.status_code = 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_iam_policy_longrunning(request) @@ -16924,6 +16997,7 @@ def test_analyze_iam_policy_longrunning_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_iam_policy_longrunning(request) # Establish that the response is the type that we expect. @@ -16965,6 +17039,7 @@ def test_analyze_iam_policy_longrunning_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -17007,6 +17082,7 @@ def test_analyze_move_rest_bad_request(request_type=asset_service.AnalyzeMoveReq response_value.status_code = 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_move(request) @@ -17040,6 +17116,7 @@ def test_analyze_move_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.analyze_move(request) # Establish that the response is the type that we expect. @@ -17079,6 +17156,7 @@ def test_analyze_move_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = asset_service.AnalyzeMoveResponse.to_json( asset_service.AnalyzeMoveResponse() ) @@ -17123,6 +17201,7 @@ def test_query_assets_rest_bad_request(request_type=asset_service.QueryAssetsReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.query_assets(request) @@ -17159,6 +17238,7 @@ def test_query_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.query_assets(request) # Establish that the response is the type that we expect. @@ -17200,6 +17280,7 @@ def test_query_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 = asset_service.QueryAssetsResponse.to_json( asset_service.QueryAssetsResponse() ) @@ -17246,6 +17327,7 @@ def test_create_saved_query_rest_bad_request( response_value.status_code = 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_saved_query(request) @@ -17380,6 +17462,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_saved_query(request) # Establish that the response is the type that we expect. @@ -17423,6 +17506,7 @@ def test_create_saved_query_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = asset_service.SavedQuery.to_json(asset_service.SavedQuery()) req.return_value.content = return_value @@ -17467,6 +17551,7 @@ def test_get_saved_query_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_saved_query(request) @@ -17505,6 +17590,7 @@ def test_get_saved_query_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_saved_query(request) # Establish that the response is the type that we expect. @@ -17548,6 +17634,7 @@ def test_get_saved_query_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = asset_service.SavedQuery.to_json(asset_service.SavedQuery()) req.return_value.content = return_value @@ -17592,6 +17679,7 @@ def test_list_saved_queries_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_saved_queries(request) @@ -17627,6 +17715,7 @@ def test_list_saved_queries_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_saved_queries(request) # Establish that the response is the type that we expect. @@ -17667,6 +17756,7 @@ def test_list_saved_queries_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = asset_service.ListSavedQueriesResponse.to_json( asset_service.ListSavedQueriesResponse() ) @@ -17713,6 +17803,7 @@ def test_update_saved_query_rest_bad_request( response_value.status_code = 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_saved_query(request) @@ -17847,6 +17938,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_saved_query(request) # Establish that the response is the type that we expect. @@ -17890,6 +17982,7 @@ def test_update_saved_query_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = asset_service.SavedQuery.to_json(asset_service.SavedQuery()) req.return_value.content = return_value @@ -17934,6 +18027,7 @@ def test_delete_saved_query_rest_bad_request( response_value.status_code = 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_saved_query(request) @@ -17964,6 +18058,7 @@ def test_delete_saved_query_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_saved_query(request) # Establish that the response is the type that we expect. @@ -18000,6 +18095,7 @@ def test_delete_saved_query_rest_interceptors(null_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 = asset_service.DeleteSavedQueryRequest() metadata = [ @@ -18040,6 +18136,7 @@ def test_batch_get_effective_iam_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.batch_get_effective_iam_policies(request) @@ -18075,6 +18172,7 @@ def test_batch_get_effective_iam_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.batch_get_effective_iam_policies(request) # Establish that the response is the type that we expect. @@ -18114,6 +18212,7 @@ def test_batch_get_effective_iam_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 = asset_service.BatchGetEffectiveIamPoliciesResponse.to_json( asset_service.BatchGetEffectiveIamPoliciesResponse() ) @@ -18160,6 +18259,7 @@ def test_analyze_org_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.analyze_org_policies(request) @@ -18195,6 +18295,7 @@ def test_analyze_org_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.analyze_org_policies(request) # Establish that the response is the type that we expect. @@ -18235,6 +18336,7 @@ def test_analyze_org_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 = asset_service.AnalyzeOrgPoliciesResponse.to_json( asset_service.AnalyzeOrgPoliciesResponse() ) @@ -18281,6 +18383,7 @@ def test_analyze_org_policy_governed_containers_rest_bad_request( response_value.status_code = 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_org_policy_governed_containers(request) @@ -18318,6 +18421,7 @@ def test_analyze_org_policy_governed_containers_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_org_policy_governed_containers(request) # Establish that the response is the type that we expect. @@ -18360,6 +18464,7 @@ def test_analyze_org_policy_governed_containers_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 = asset_service.AnalyzeOrgPolicyGovernedContainersResponse.to_json( asset_service.AnalyzeOrgPolicyGovernedContainersResponse() ) @@ -18406,6 +18511,7 @@ def test_analyze_org_policy_governed_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.analyze_org_policy_governed_assets(request) @@ -18443,6 +18549,7 @@ def test_analyze_org_policy_governed_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.analyze_org_policy_governed_assets(request) # Establish that the response is the type that we expect. @@ -18484,6 +18591,7 @@ def test_analyze_org_policy_governed_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 = asset_service.AnalyzeOrgPolicyGovernedAssetsResponse.to_json( asset_service.AnalyzeOrgPolicyGovernedAssetsResponse() ) @@ -18532,6 +18640,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) @@ -18562,6 +18671,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-asset/tests/unit/gapic/asset_v1p1beta1/test_asset_service.py b/packages/google-cloud-asset/tests/unit/gapic/asset_v1p1beta1/test_asset_service.py index 186e045cb8ba..a56eea16909f 100644 --- a/packages/google-cloud-asset/tests/unit/gapic/asset_v1p1beta1/test_asset_service.py +++ b/packages/google-cloud-asset/tests/unit/gapic/asset_v1p1beta1/test_asset_service.py @@ -2283,6 +2283,7 @@ def test_search_all_resources_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.search_all_resources(request) @@ -2341,6 +2342,7 @@ def test_search_all_resources_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.search_all_resources(**mock_args) @@ -2549,6 +2551,7 @@ def test_search_all_iam_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.search_all_iam_policies(request) @@ -2604,6 +2607,7 @@ def test_search_all_iam_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.search_all_iam_policies(**mock_args) @@ -2948,6 +2952,7 @@ def test_search_all_resources_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.search_all_resources(request) @@ -2983,6 +2988,7 @@ def test_search_all_resources_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.search_all_resources(request) # Establish that the response is the type that we expect. @@ -3023,6 +3029,7 @@ def test_search_all_resources_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = asset_service.SearchAllResourcesResponse.to_json( asset_service.SearchAllResourcesResponse() ) @@ -3069,6 +3076,7 @@ def test_search_all_iam_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.search_all_iam_policies(request) @@ -3104,6 +3112,7 @@ def test_search_all_iam_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.search_all_iam_policies(request) # Establish that the response is the type that we expect. @@ -3144,6 +3153,7 @@ def test_search_all_iam_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 = asset_service.SearchAllIamPoliciesResponse.to_json( asset_service.SearchAllIamPoliciesResponse() ) diff --git a/packages/google-cloud-asset/tests/unit/gapic/asset_v1p2beta1/test_asset_service.py b/packages/google-cloud-asset/tests/unit/gapic/asset_v1p2beta1/test_asset_service.py index b37fea78b51c..fabc04732970 100644 --- a/packages/google-cloud-asset/tests/unit/gapic/asset_v1p2beta1/test_asset_service.py +++ b/packages/google-cloud-asset/tests/unit/gapic/asset_v1p2beta1/test_asset_service.py @@ -2758,6 +2758,7 @@ def test_create_feed_rest_required_fields(request_type=asset_service.CreateFeedR response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_feed(request) @@ -2812,6 +2813,7 @@ def test_create_feed_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_feed(**mock_args) @@ -2939,6 +2941,7 @@ def test_get_feed_rest_required_fields(request_type=asset_service.GetFeedRequest response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_feed(request) @@ -2984,6 +2987,7 @@ def test_get_feed_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_feed(**mock_args) @@ -3111,6 +3115,7 @@ def test_list_feeds_rest_required_fields(request_type=asset_service.ListFeedsReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_feeds(request) @@ -3156,6 +3161,7 @@ def test_list_feeds_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_feeds(**mock_args) @@ -3279,6 +3285,7 @@ def test_update_feed_rest_required_fields(request_type=asset_service.UpdateFeedR response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_feed(request) @@ -3332,6 +3339,7 @@ def test_update_feed_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_feed(**mock_args) @@ -3456,6 +3464,7 @@ def test_delete_feed_rest_required_fields(request_type=asset_service.DeleteFeedR response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_feed(request) @@ -3499,6 +3508,7 @@ def test_delete_feed_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_feed(**mock_args) @@ -3915,6 +3925,7 @@ def test_create_feed_rest_bad_request(request_type=asset_service.CreateFeedReque response_value.status_code = 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_feed(request) @@ -3953,6 +3964,7 @@ def test_create_feed_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_feed(request) # Establish that the response is the type that we expect. @@ -3996,6 +4008,7 @@ def test_create_feed_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = asset_service.Feed.to_json(asset_service.Feed()) req.return_value.content = return_value @@ -4038,6 +4051,7 @@ def test_get_feed_rest_bad_request(request_type=asset_service.GetFeedRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_feed(request) @@ -4076,6 +4090,7 @@ def test_get_feed_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_feed(request) # Establish that the response is the type that we expect. @@ -4117,6 +4132,7 @@ def test_get_feed_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = asset_service.Feed.to_json(asset_service.Feed()) req.return_value.content = return_value @@ -4159,6 +4175,7 @@ def test_list_feeds_rest_bad_request(request_type=asset_service.ListFeedsRequest response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_feeds(request) @@ -4192,6 +4209,7 @@ def test_list_feeds_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_feeds(request) # Establish that the response is the type that we expect. @@ -4229,6 +4247,7 @@ def test_list_feeds_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = asset_service.ListFeedsResponse.to_json( asset_service.ListFeedsResponse() ) @@ -4273,6 +4292,7 @@ def test_update_feed_rest_bad_request(request_type=asset_service.UpdateFeedReque response_value.status_code = 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_feed(request) @@ -4311,6 +4331,7 @@ def test_update_feed_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_feed(request) # Establish that the response is the type that we expect. @@ -4354,6 +4375,7 @@ def test_update_feed_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = asset_service.Feed.to_json(asset_service.Feed()) req.return_value.content = return_value @@ -4396,6 +4418,7 @@ def test_delete_feed_rest_bad_request(request_type=asset_service.DeleteFeedReque response_value.status_code = 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_feed(request) @@ -4426,6 +4449,7 @@ def test_delete_feed_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_feed(request) # Establish that the response is the type that we expect. @@ -4462,6 +4486,7 @@ def test_delete_feed_rest_interceptors(null_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 = asset_service.DeleteFeedRequest() metadata = [ @@ -4504,6 +4529,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) @@ -4534,6 +4560,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-asset/tests/unit/gapic/asset_v1p5beta1/test_asset_service.py b/packages/google-cloud-asset/tests/unit/gapic/asset_v1p5beta1/test_asset_service.py index 016ff1d1040d..80019a17117e 100644 --- a/packages/google-cloud-asset/tests/unit/gapic/asset_v1p5beta1/test_asset_service.py +++ b/packages/google-cloud-asset/tests/unit/gapic/asset_v1p5beta1/test_asset_service.py @@ -1668,6 +1668,7 @@ def test_list_assets_rest_required_fields(request_type=asset_service.ListAssetsR response_value._content = json_return_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) @@ -1724,6 +1725,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) @@ -2006,6 +2008,7 @@ def test_list_assets_rest_bad_request(request_type=asset_service.ListAssetsReque response_value.status_code = 400 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) @@ -2041,6 +2044,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. @@ -2081,6 +2085,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 = asset_service.ListAssetsResponse.to_json( asset_service.ListAssetsResponse() ) diff --git a/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads/gapic_version.py b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads/gapic_version.py index 0b9427f4e8a5..558c8aab67c5 100644 --- a/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads/gapic_version.py +++ b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads/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-assured-workloads/google/cloud/assuredworkloads_v1/gapic_version.py b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/gapic_version.py index 0b9427f4e8a5..558c8aab67c5 100644 --- a/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/gapic_version.py +++ b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_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-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_service/async_client.py b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_service/async_client.py index 2b9687f8fb81..e5730427ae41 100644 --- a/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_service/async_client.py +++ b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_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, AssuredWorkloadsServiceTransport from .transports.grpc_asyncio import AssuredWorkloadsServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class AssuredWorkloadsServiceAsyncClient: """Service to manage AssuredWorkloads.""" @@ -276,6 +286,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.assuredworkloads_v1.AssuredWorkloadsServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.assuredworkloads.v1.AssuredWorkloadsService", + "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.assuredworkloads.v1.AssuredWorkloadsService", + "credentialsType": None, + }, + ) + async def create_workload( self, request: Optional[Union[assuredworkloads.CreateWorkloadRequest, dict]] = None, @@ -284,7 +316,7 @@ async def create_workload( workload: Optional[assuredworkloads.Workload] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 Assured Workload. @@ -342,8 +374,10 @@ async def sample_create_workload(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -417,7 +451,7 @@ async def update_workload( 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]]] = (), ) -> assuredworkloads.Workload: r"""Updates an existing workload. Currently allows updating of workload display_name and labels. For force updates don't set @@ -476,8 +510,10 @@ async def sample_update_workload(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.assuredworkloads_v1.types.Workload: @@ -543,7 +579,7 @@ async def restrict_allowed_resources( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> assuredworkloads.RestrictAllowedResourcesResponse: r"""Restrict the list of resources allowed in the Workload environment. The current list of allowed @@ -589,8 +625,10 @@ async def sample_restrict_allowed_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.assuredworkloads_v1.types.RestrictAllowedResourcesResponse: @@ -637,7 +675,7 @@ async def delete_workload( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 workload. Make sure that workload's direct children are already in a deleted state, otherwise the request will fail @@ -680,8 +718,10 @@ async def sample_delete_workload(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -733,7 +773,7 @@ async def get_workload( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> assuredworkloads.Workload: r"""Gets Assured Workload associated with a CRM Node @@ -780,8 +820,10 @@ async def sample_get_workload(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.assuredworkloads_v1.types.Workload: @@ -842,7 +884,7 @@ async def list_workloads( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListWorkloadsAsyncPager: r"""Lists Assured Workloads under a CRM Node. @@ -888,8 +930,10 @@ async def sample_list_workloads(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.assuredworkloads_v1.services.assured_workloads_service.pagers.ListWorkloadsAsyncPager: @@ -964,7 +1008,7 @@ async def list_violations( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListViolationsAsyncPager: r"""Lists the Violations in the AssuredWorkload Environment. Callers may also choose to read across multiple Workloads as per @@ -1014,8 +1058,10 @@ async def sample_list_violations(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.assuredworkloads_v1.services.assured_workloads_service.pagers.ListViolationsAsyncPager: @@ -1084,7 +1130,7 @@ async def get_violation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> assuredworkloads.Violation: r"""Retrieves Assured Workload Violation based on ID. @@ -1131,8 +1177,10 @@ async def sample_get_violation(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.assuredworkloads_v1.types.Violation: @@ -1186,7 +1234,7 @@ async def acknowledge_violation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> assuredworkloads.AcknowledgeViolationResponse: r"""Acknowledges an existing violation. By acknowledging a violation, users acknowledge the existence of a @@ -1229,8 +1277,10 @@ async def sample_acknowledge_violation(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.assuredworkloads_v1.types.AcknowledgeViolationResponse: @@ -1270,7 +1320,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. @@ -1281,8 +1331,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. @@ -1323,7 +1375,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. @@ -1334,8 +1386,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-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_service/client.py b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_service/client.py index 9e181474c909..37bbd45cf1ac 100644 --- a/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_service/client.py +++ b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_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 @@ -616,6 +626,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( @@ -682,6 +696,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.assuredworkloads_v1.AssuredWorkloadsServiceClient`.", + extra={ + "serviceName": "google.cloud.assuredworkloads.v1.AssuredWorkloadsService", + "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.assuredworkloads.v1.AssuredWorkloadsService", + "credentialsType": None, + }, + ) + def create_workload( self, request: Optional[Union[assuredworkloads.CreateWorkloadRequest, dict]] = None, @@ -690,7 +727,7 @@ def create_workload( workload: Optional[assuredworkloads.Workload] = None, retry: OptionalRetry = gapic_v1.method.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 Assured Workload. @@ -748,8 +785,10 @@ def sample_create_workload(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -820,7 +859,7 @@ def update_workload( 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]]] = (), ) -> assuredworkloads.Workload: r"""Updates an existing workload. Currently allows updating of workload display_name and labels. For force updates don't set @@ -879,8 +918,10 @@ def sample_update_workload(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.assuredworkloads_v1.types.Workload: @@ -943,7 +984,7 @@ def restrict_allowed_resources( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> assuredworkloads.RestrictAllowedResourcesResponse: r"""Restrict the list of resources allowed in the Workload environment. The current list of allowed @@ -989,8 +1030,10 @@ def sample_restrict_allowed_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.assuredworkloads_v1.types.RestrictAllowedResourcesResponse: @@ -1037,7 +1080,7 @@ def delete_workload( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 workload. Make sure that workload's direct children are already in a deleted state, otherwise the request will fail @@ -1080,8 +1123,10 @@ def sample_delete_workload(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -1130,7 +1175,7 @@ def get_workload( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> assuredworkloads.Workload: r"""Gets Assured Workload associated with a CRM Node @@ -1177,8 +1222,10 @@ def sample_get_workload(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.assuredworkloads_v1.types.Workload: @@ -1236,7 +1283,7 @@ def list_workloads( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListWorkloadsPager: r"""Lists Assured Workloads under a CRM Node. @@ -1282,8 +1329,10 @@ def sample_list_workloads(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.assuredworkloads_v1.services.assured_workloads_service.pagers.ListWorkloadsPager: @@ -1355,7 +1404,7 @@ def list_violations( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListViolationsPager: r"""Lists the Violations in the AssuredWorkload Environment. Callers may also choose to read across multiple Workloads as per @@ -1405,8 +1454,10 @@ def sample_list_violations(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.assuredworkloads_v1.services.assured_workloads_service.pagers.ListViolationsPager: @@ -1472,7 +1523,7 @@ def get_violation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> assuredworkloads.Violation: r"""Retrieves Assured Workload Violation based on ID. @@ -1519,8 +1570,10 @@ def sample_get_violation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.assuredworkloads_v1.types.Violation: @@ -1571,7 +1624,7 @@ def acknowledge_violation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> assuredworkloads.AcknowledgeViolationResponse: r"""Acknowledges an existing violation. By acknowledging a violation, users acknowledge the existence of a @@ -1614,8 +1667,10 @@ def sample_acknowledge_violation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.assuredworkloads_v1.types.AcknowledgeViolationResponse: @@ -1666,7 +1721,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. @@ -1677,8 +1732,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. @@ -1719,7 +1776,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. @@ -1730,8 +1787,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-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_service/pagers.py b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_service/pagers.py index 253be643a8a1..a1340746c837 100644 --- a/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_service/pagers.py +++ b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_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 = assuredworkloads.ListWorkloadsRequest(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 = assuredworkloads.ListWorkloadsRequest(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 = assuredworkloads.ListViolationsRequest(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 = assuredworkloads.ListViolationsRequest(request) diff --git a/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_service/transports/grpc.py b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_service/transports/grpc.py index 24d0519b8436..c7231e5c5dd8 100644 --- a/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_service/transports/grpc.py +++ b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_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.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.assuredworkloads_v1.types import assuredworkloads from .base import DEFAULT_CLIENT_INFO, AssuredWorkloadsServiceTransport +try: + from google.api_core import client_logging # 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.assuredworkloads.v1.AssuredWorkloadsService", + "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.assuredworkloads.v1.AssuredWorkloadsService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AssuredWorkloadsServiceGrpcTransport(AssuredWorkloadsServiceTransport): """gRPC backend transport for AssuredWorkloadsService. @@ -182,7 +263,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientInterceptor() + self._logged_channel = grpc.intercept_channel( + self._grpc_channel, self._interceptor + ) + + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @classmethod @@ -246,7 +332,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -270,7 +358,7 @@ def create_workload( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workload" not in self._stubs: - self._stubs["create_workload"] = self.grpc_channel.unary_unary( + self._stubs["create_workload"] = self._logged_channel.unary_unary( "/google.cloud.assuredworkloads.v1.AssuredWorkloadsService/CreateWorkload", request_serializer=assuredworkloads.CreateWorkloadRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -299,7 +387,7 @@ def update_workload( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workload" not in self._stubs: - self._stubs["update_workload"] = self.grpc_channel.unary_unary( + self._stubs["update_workload"] = self._logged_channel.unary_unary( "/google.cloud.assuredworkloads.v1.AssuredWorkloadsService/UpdateWorkload", request_serializer=assuredworkloads.UpdateWorkloadRequest.serialize, response_deserializer=assuredworkloads.Workload.deserialize, @@ -335,7 +423,9 @@ def restrict_allowed_resources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "restrict_allowed_resources" not in self._stubs: - self._stubs["restrict_allowed_resources"] = self.grpc_channel.unary_unary( + self._stubs[ + "restrict_allowed_resources" + ] = self._logged_channel.unary_unary( "/google.cloud.assuredworkloads.v1.AssuredWorkloadsService/RestrictAllowedResources", request_serializer=assuredworkloads.RestrictAllowedResourcesRequest.serialize, response_deserializer=assuredworkloads.RestrictAllowedResourcesResponse.deserialize, @@ -363,7 +453,7 @@ def delete_workload( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workload" not in self._stubs: - self._stubs["delete_workload"] = self.grpc_channel.unary_unary( + self._stubs["delete_workload"] = self._logged_channel.unary_unary( "/google.cloud.assuredworkloads.v1.AssuredWorkloadsService/DeleteWorkload", request_serializer=assuredworkloads.DeleteWorkloadRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -389,7 +479,7 @@ def get_workload( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workload" not in self._stubs: - self._stubs["get_workload"] = self.grpc_channel.unary_unary( + self._stubs["get_workload"] = self._logged_channel.unary_unary( "/google.cloud.assuredworkloads.v1.AssuredWorkloadsService/GetWorkload", request_serializer=assuredworkloads.GetWorkloadRequest.serialize, response_deserializer=assuredworkloads.Workload.deserialize, @@ -417,7 +507,7 @@ def list_workloads( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workloads" not in self._stubs: - self._stubs["list_workloads"] = self.grpc_channel.unary_unary( + self._stubs["list_workloads"] = self._logged_channel.unary_unary( "/google.cloud.assuredworkloads.v1.AssuredWorkloadsService/ListWorkloads", request_serializer=assuredworkloads.ListWorkloadsRequest.serialize, response_deserializer=assuredworkloads.ListWorkloadsResponse.deserialize, @@ -451,7 +541,7 @@ def list_violations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_violations" not in self._stubs: - self._stubs["list_violations"] = self.grpc_channel.unary_unary( + self._stubs["list_violations"] = self._logged_channel.unary_unary( "/google.cloud.assuredworkloads.v1.AssuredWorkloadsService/ListViolations", request_serializer=assuredworkloads.ListViolationsRequest.serialize, response_deserializer=assuredworkloads.ListViolationsResponse.deserialize, @@ -477,7 +567,7 @@ def get_violation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_violation" not in self._stubs: - self._stubs["get_violation"] = self.grpc_channel.unary_unary( + self._stubs["get_violation"] = self._logged_channel.unary_unary( "/google.cloud.assuredworkloads.v1.AssuredWorkloadsService/GetViolation", request_serializer=assuredworkloads.GetViolationRequest.serialize, response_deserializer=assuredworkloads.Violation.deserialize, @@ -511,7 +601,7 @@ def acknowledge_violation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "acknowledge_violation" not in self._stubs: - self._stubs["acknowledge_violation"] = self.grpc_channel.unary_unary( + self._stubs["acknowledge_violation"] = self._logged_channel.unary_unary( "/google.cloud.assuredworkloads.v1.AssuredWorkloadsService/AcknowledgeViolation", request_serializer=assuredworkloads.AcknowledgeViolationRequest.serialize, response_deserializer=assuredworkloads.AcknowledgeViolationResponse.deserialize, @@ -519,7 +609,7 @@ def acknowledge_violation( return self._stubs["acknowledge_violation"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -531,7 +621,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, @@ -550,7 +640,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-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_service/transports/grpc_asyncio.py b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_service/transports/grpc_asyncio.py index 597548059978..0b6c7776ca26 100644 --- a/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_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.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.assuredworkloads_v1.types import assuredworkloads from .base import DEFAULT_CLIENT_INFO, AssuredWorkloadsServiceTransport from .grpc import AssuredWorkloadsServiceGrpcTransport +try: + from google.api_core import client_logging # 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.assuredworkloads.v1.AssuredWorkloadsService", + "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.assuredworkloads.v1.AssuredWorkloadsService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AssuredWorkloadsServiceGrpcAsyncIOTransport(AssuredWorkloadsServiceTransport): """gRPC AsyncIO backend transport for AssuredWorkloadsService. @@ -229,10 +311,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientAIOInterceptor() + self._grpc_channel._unary_unary_interceptors.append(self._interceptor) + self._logged_channel = self._grpc_channel self._wrap_with_kind = ( "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters ) + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @property @@ -255,7 +340,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -282,7 +367,7 @@ def create_workload( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workload" not in self._stubs: - self._stubs["create_workload"] = self.grpc_channel.unary_unary( + self._stubs["create_workload"] = self._logged_channel.unary_unary( "/google.cloud.assuredworkloads.v1.AssuredWorkloadsService/CreateWorkload", request_serializer=assuredworkloads.CreateWorkloadRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -313,7 +398,7 @@ def update_workload( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workload" not in self._stubs: - self._stubs["update_workload"] = self.grpc_channel.unary_unary( + self._stubs["update_workload"] = self._logged_channel.unary_unary( "/google.cloud.assuredworkloads.v1.AssuredWorkloadsService/UpdateWorkload", request_serializer=assuredworkloads.UpdateWorkloadRequest.serialize, response_deserializer=assuredworkloads.Workload.deserialize, @@ -349,7 +434,9 @@ def restrict_allowed_resources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "restrict_allowed_resources" not in self._stubs: - self._stubs["restrict_allowed_resources"] = self.grpc_channel.unary_unary( + self._stubs[ + "restrict_allowed_resources" + ] = self._logged_channel.unary_unary( "/google.cloud.assuredworkloads.v1.AssuredWorkloadsService/RestrictAllowedResources", request_serializer=assuredworkloads.RestrictAllowedResourcesRequest.serialize, response_deserializer=assuredworkloads.RestrictAllowedResourcesResponse.deserialize, @@ -377,7 +464,7 @@ def delete_workload( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workload" not in self._stubs: - self._stubs["delete_workload"] = self.grpc_channel.unary_unary( + self._stubs["delete_workload"] = self._logged_channel.unary_unary( "/google.cloud.assuredworkloads.v1.AssuredWorkloadsService/DeleteWorkload", request_serializer=assuredworkloads.DeleteWorkloadRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -405,7 +492,7 @@ def get_workload( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workload" not in self._stubs: - self._stubs["get_workload"] = self.grpc_channel.unary_unary( + self._stubs["get_workload"] = self._logged_channel.unary_unary( "/google.cloud.assuredworkloads.v1.AssuredWorkloadsService/GetWorkload", request_serializer=assuredworkloads.GetWorkloadRequest.serialize, response_deserializer=assuredworkloads.Workload.deserialize, @@ -434,7 +521,7 @@ def list_workloads( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workloads" not in self._stubs: - self._stubs["list_workloads"] = self.grpc_channel.unary_unary( + self._stubs["list_workloads"] = self._logged_channel.unary_unary( "/google.cloud.assuredworkloads.v1.AssuredWorkloadsService/ListWorkloads", request_serializer=assuredworkloads.ListWorkloadsRequest.serialize, response_deserializer=assuredworkloads.ListWorkloadsResponse.deserialize, @@ -468,7 +555,7 @@ def list_violations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_violations" not in self._stubs: - self._stubs["list_violations"] = self.grpc_channel.unary_unary( + self._stubs["list_violations"] = self._logged_channel.unary_unary( "/google.cloud.assuredworkloads.v1.AssuredWorkloadsService/ListViolations", request_serializer=assuredworkloads.ListViolationsRequest.serialize, response_deserializer=assuredworkloads.ListViolationsResponse.deserialize, @@ -496,7 +583,7 @@ def get_violation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_violation" not in self._stubs: - self._stubs["get_violation"] = self.grpc_channel.unary_unary( + self._stubs["get_violation"] = self._logged_channel.unary_unary( "/google.cloud.assuredworkloads.v1.AssuredWorkloadsService/GetViolation", request_serializer=assuredworkloads.GetViolationRequest.serialize, response_deserializer=assuredworkloads.Violation.deserialize, @@ -530,7 +617,7 @@ def acknowledge_violation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "acknowledge_violation" not in self._stubs: - self._stubs["acknowledge_violation"] = self.grpc_channel.unary_unary( + self._stubs["acknowledge_violation"] = self._logged_channel.unary_unary( "/google.cloud.assuredworkloads.v1.AssuredWorkloadsService/AcknowledgeViolation", request_serializer=assuredworkloads.AcknowledgeViolationRequest.serialize, response_deserializer=assuredworkloads.AcknowledgeViolationResponse.deserialize, @@ -603,7 +690,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: @@ -619,7 +706,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, @@ -638,7 +725,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-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_service/transports/rest.py b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_service/transports/rest.py index c0961d324e07..37fba2a15379 100644 --- a/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_service/transports/rest.py +++ b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1/services/assured_workloads_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, @@ -139,8 +147,10 @@ def post_update_workload(self, response): def pre_create_workload( self, request: assuredworkloads.CreateWorkloadRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[assuredworkloads.CreateWorkloadRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + assuredworkloads.CreateWorkloadRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_workload Override in a subclass to manipulate the request or metadata @@ -162,8 +172,10 @@ def post_create_workload( def pre_delete_workload( self, request: assuredworkloads.DeleteWorkloadRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[assuredworkloads.DeleteWorkloadRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + assuredworkloads.DeleteWorkloadRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_workload Override in a subclass to manipulate the request or metadata @@ -174,8 +186,10 @@ def pre_delete_workload( def pre_get_workload( self, request: assuredworkloads.GetWorkloadRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[assuredworkloads.GetWorkloadRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + assuredworkloads.GetWorkloadRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_workload Override in a subclass to manipulate the request or metadata @@ -197,8 +211,10 @@ def post_get_workload( def pre_list_workloads( self, request: assuredworkloads.ListWorkloadsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[assuredworkloads.ListWorkloadsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + assuredworkloads.ListWorkloadsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_workloads Override in a subclass to manipulate the request or metadata @@ -220,9 +236,10 @@ def post_list_workloads( def pre_restrict_allowed_resources( self, request: assuredworkloads.RestrictAllowedResourcesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - assuredworkloads.RestrictAllowedResourcesRequest, Sequence[Tuple[str, str]] + assuredworkloads.RestrictAllowedResourcesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for restrict_allowed_resources @@ -245,8 +262,10 @@ def post_restrict_allowed_resources( def pre_update_workload( self, request: assuredworkloads.UpdateWorkloadRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[assuredworkloads.UpdateWorkloadRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + assuredworkloads.UpdateWorkloadRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_workload Override in a subclass to manipulate the request or metadata @@ -268,8 +287,10 @@ def post_update_workload( def pre_get_operation( self, request: operations_pb2.GetOperationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.GetOperationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -291,8 +312,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 @@ -452,7 +475,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> assuredworkloads.AcknowledgeViolationResponse: raise NotImplementedError( "Method AcknowledgeViolation is not available over REST transport" @@ -494,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create workload method over HTTP. @@ -504,8 +527,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -518,6 +543,7 @@ def __call__( http_options = ( _BaseAssuredWorkloadsServiceRestTransport._BaseCreateWorkload._get_http_options() ) + request, metadata = self._interceptor.pre_create_workload(request, metadata) transcoded_request = _BaseAssuredWorkloadsServiceRestTransport._BaseCreateWorkload._get_transcoded_request( http_options, request @@ -532,6 +558,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.assuredworkloads_v1.AssuredWorkloadsServiceClient.CreateWorkload", + extra={ + "serviceName": "google.cloud.assuredworkloads.v1.AssuredWorkloadsService", + "rpcName": "CreateWorkload", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AssuredWorkloadsServiceRestTransport._CreateWorkload._get_response( @@ -553,7 +606,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_workload(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.assuredworkloads_v1.AssuredWorkloadsServiceClient.create_workload", + extra={ + "serviceName": "google.cloud.assuredworkloads.v1.AssuredWorkloadsService", + "rpcName": "CreateWorkload", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteWorkload( @@ -591,7 +666,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete workload method over HTTP. @@ -601,13 +676,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 = ( _BaseAssuredWorkloadsServiceRestTransport._BaseDeleteWorkload._get_http_options() ) + request, metadata = self._interceptor.pre_delete_workload(request, metadata) transcoded_request = _BaseAssuredWorkloadsServiceRestTransport._BaseDeleteWorkload._get_transcoded_request( http_options, request @@ -618,6 +696,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.assuredworkloads_v1.AssuredWorkloadsServiceClient.DeleteWorkload", + extra={ + "serviceName": "google.cloud.assuredworkloads.v1.AssuredWorkloadsService", + "rpcName": "DeleteWorkload", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AssuredWorkloadsServiceRestTransport._DeleteWorkload._get_response( @@ -648,7 +753,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> assuredworkloads.Violation: raise NotImplementedError( "Method GetViolation is not available over REST transport" @@ -689,7 +794,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> assuredworkloads.Workload: r"""Call the get workload method over HTTP. @@ -699,8 +804,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.assuredworkloads.Workload: @@ -712,6 +819,7 @@ def __call__( http_options = ( _BaseAssuredWorkloadsServiceRestTransport._BaseGetWorkload._get_http_options() ) + request, metadata = self._interceptor.pre_get_workload(request, metadata) transcoded_request = _BaseAssuredWorkloadsServiceRestTransport._BaseGetWorkload._get_transcoded_request( http_options, request @@ -722,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 = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.assuredworkloads_v1.AssuredWorkloadsServiceClient.GetWorkload", + extra={ + "serviceName": "google.cloud.assuredworkloads.v1.AssuredWorkloadsService", + "rpcName": "GetWorkload", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AssuredWorkloadsServiceRestTransport._GetWorkload._get_response( self._host, @@ -742,7 +877,29 @@ def __call__( pb_resp = assuredworkloads.Workload.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_workload(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = assuredworkloads.Workload.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.assuredworkloads_v1.AssuredWorkloadsServiceClient.get_workload", + extra={ + "serviceName": "google.cloud.assuredworkloads.v1.AssuredWorkloadsService", + "rpcName": "GetWorkload", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListViolations( @@ -758,7 +915,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> assuredworkloads.ListViolationsResponse: raise NotImplementedError( "Method ListViolations is not available over REST transport" @@ -799,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]]] = (), ) -> assuredworkloads.ListWorkloadsResponse: r"""Call the list workloads method over HTTP. @@ -810,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: ~.assuredworkloads.ListWorkloadsResponse: @@ -821,6 +980,7 @@ def __call__( http_options = ( _BaseAssuredWorkloadsServiceRestTransport._BaseListWorkloads._get_http_options() ) + request, metadata = self._interceptor.pre_list_workloads(request, metadata) transcoded_request = _BaseAssuredWorkloadsServiceRestTransport._BaseListWorkloads._get_transcoded_request( http_options, request @@ -831,6 +991,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.assuredworkloads_v1.AssuredWorkloadsServiceClient.ListWorkloads", + extra={ + "serviceName": "google.cloud.assuredworkloads.v1.AssuredWorkloadsService", + "rpcName": "ListWorkloads", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AssuredWorkloadsServiceRestTransport._ListWorkloads._get_response( @@ -853,7 +1040,31 @@ def __call__( pb_resp = assuredworkloads.ListWorkloadsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_workloads(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = assuredworkloads.ListWorkloadsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.assuredworkloads_v1.AssuredWorkloadsServiceClient.list_workloads", + extra={ + "serviceName": "google.cloud.assuredworkloads.v1.AssuredWorkloadsService", + "rpcName": "ListWorkloads", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RestrictAllowedResources( @@ -892,7 +1103,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> assuredworkloads.RestrictAllowedResourcesResponse: r"""Call the restrict allowed resources method over HTTP. @@ -905,8 +1116,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.assuredworkloads.RestrictAllowedResourcesResponse: @@ -918,6 +1131,7 @@ def __call__( http_options = ( _BaseAssuredWorkloadsServiceRestTransport._BaseRestrictAllowedResources._get_http_options() ) + request, metadata = self._interceptor.pre_restrict_allowed_resources( request, metadata ) @@ -934,6 +1148,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.assuredworkloads_v1.AssuredWorkloadsServiceClient.RestrictAllowedResources", + extra={ + "serviceName": "google.cloud.assuredworkloads.v1.AssuredWorkloadsService", + "rpcName": "RestrictAllowedResources", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AssuredWorkloadsServiceRestTransport._RestrictAllowedResources._get_response( self._host, @@ -955,7 +1196,33 @@ def __call__( pb_resp = assuredworkloads.RestrictAllowedResourcesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_restrict_allowed_resources(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + assuredworkloads.RestrictAllowedResourcesResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.assuredworkloads_v1.AssuredWorkloadsServiceClient.restrict_allowed_resources", + extra={ + "serviceName": "google.cloud.assuredworkloads.v1.AssuredWorkloadsService", + "rpcName": "RestrictAllowedResources", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateWorkload( @@ -994,7 +1261,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> assuredworkloads.Workload: r"""Call the update workload method over HTTP. @@ -1004,8 +1271,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.assuredworkloads.Workload: @@ -1017,6 +1286,7 @@ def __call__( http_options = ( _BaseAssuredWorkloadsServiceRestTransport._BaseUpdateWorkload._get_http_options() ) + request, metadata = self._interceptor.pre_update_workload(request, metadata) transcoded_request = _BaseAssuredWorkloadsServiceRestTransport._BaseUpdateWorkload._get_transcoded_request( http_options, request @@ -1031,6 +1301,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.assuredworkloads_v1.AssuredWorkloadsServiceClient.UpdateWorkload", + extra={ + "serviceName": "google.cloud.assuredworkloads.v1.AssuredWorkloadsService", + "rpcName": "UpdateWorkload", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AssuredWorkloadsServiceRestTransport._UpdateWorkload._get_response( @@ -1054,7 +1351,29 @@ def __call__( pb_resp = assuredworkloads.Workload.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_workload(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = assuredworkloads.Workload.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.assuredworkloads_v1.AssuredWorkloadsServiceClient.update_workload", + extra={ + "serviceName": "google.cloud.assuredworkloads.v1.AssuredWorkloadsService", + "rpcName": "UpdateWorkload", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1179,7 +1498,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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. @@ -1189,8 +1508,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -1199,6 +1520,7 @@ def __call__( http_options = ( _BaseAssuredWorkloadsServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseAssuredWorkloadsServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1209,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.assuredworkloads_v1.AssuredWorkloadsServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.assuredworkloads.v1.AssuredWorkloadsService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AssuredWorkloadsServiceRestTransport._GetOperation._get_response( self._host, @@ -1228,6 +1577,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.assuredworkloads_v1.AssuredWorkloadsServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.assuredworkloads.v1.AssuredWorkloadsService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1269,7 +1639,7 @@ def __call__( *, 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. @@ -1279,8 +1649,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must 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. @@ -1289,6 +1661,7 @@ def __call__( http_options = ( _BaseAssuredWorkloadsServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseAssuredWorkloadsServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1299,6 +1672,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.assuredworkloads_v1.AssuredWorkloadsServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.assuredworkloads.v1.AssuredWorkloadsService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AssuredWorkloadsServiceRestTransport._ListOperations._get_response( @@ -1320,6 +1720,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.assuredworkloads_v1.AssuredWorkloadsServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.assuredworkloads.v1.AssuredWorkloadsService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/gapic_version.py b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/gapic_version.py index 0b9427f4e8a5..558c8aab67c5 100644 --- a/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/gapic_version.py +++ b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/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-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_service/async_client.py b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_service/async_client.py index 788cf820de78..17438ddb1c9e 100644 --- a/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_service/async_client.py +++ b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -57,6 +58,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, AssuredWorkloadsServiceTransport from .transports.grpc_asyncio import AssuredWorkloadsServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class AssuredWorkloadsServiceAsyncClient: """Service to manage AssuredWorkloads.""" @@ -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.assuredworkloads_v1beta1.AssuredWorkloadsServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.assuredworkloads.v1beta1.AssuredWorkloadsService", + "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.assuredworkloads.v1beta1.AssuredWorkloadsService", + "credentialsType": None, + }, + ) + async def create_workload( self, request: Optional[Union[assuredworkloads.CreateWorkloadRequest, dict]] = None, @@ -282,7 +314,7 @@ async def create_workload( workload: Optional[assuredworkloads.Workload] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 Assured Workload. @@ -340,8 +372,10 @@ async def sample_create_workload(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -415,7 +449,7 @@ async def update_workload( 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]]] = (), ) -> assuredworkloads.Workload: r"""Updates an existing workload. Currently allows updating of workload display_name and labels. For force updates don't set @@ -474,8 +508,10 @@ async def sample_update_workload(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.assuredworkloads_v1beta1.types.Workload: @@ -534,7 +570,7 @@ async def restrict_allowed_resources( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> assuredworkloads.RestrictAllowedResourcesResponse: r"""Restrict the list of resources allowed in the Workload environment. The current list of allowed @@ -580,8 +616,10 @@ async def sample_restrict_allowed_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.assuredworkloads_v1beta1.types.RestrictAllowedResourcesResponse: @@ -628,7 +666,7 @@ async def delete_workload( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 workload. Make sure that workload's direct children are already in a deleted state, otherwise the request will fail @@ -674,8 +712,10 @@ async def sample_delete_workload(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -727,7 +767,7 @@ async def get_workload( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> assuredworkloads.Workload: r"""Gets Assured Workload associated with a CRM Node @@ -774,8 +814,10 @@ async def sample_get_workload(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.assuredworkloads_v1beta1.types.Workload: @@ -834,7 +876,7 @@ async def analyze_workload_move( target: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> assuredworkloads.AnalyzeWorkloadMoveResponse: r"""Analyze if the source Assured Workloads can be moved to the target Assured Workload @@ -899,8 +941,10 @@ async def sample_analyze_workload_move(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.assuredworkloads_v1beta1.types.AnalyzeWorkloadMoveResponse: @@ -957,7 +1001,7 @@ async def list_workloads( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListWorkloadsAsyncPager: r"""Lists Assured Workloads under a CRM Node. @@ -1003,8 +1047,10 @@ async def sample_list_workloads(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.assuredworkloads_v1beta1.services.assured_workloads_service.pagers.ListWorkloadsAsyncPager: @@ -1072,7 +1118,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. @@ -1083,8 +1129,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. @@ -1125,7 +1173,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. @@ -1136,8 +1184,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-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_service/client.py b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_service/client.py index 49d2dac8051e..22d4c1f3af26 100644 --- a/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_service/client.py +++ b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_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 @@ -594,6 +604,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -660,6 +674,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.assuredworkloads_v1beta1.AssuredWorkloadsServiceClient`.", + extra={ + "serviceName": "google.cloud.assuredworkloads.v1beta1.AssuredWorkloadsService", + "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.assuredworkloads.v1beta1.AssuredWorkloadsService", + "credentialsType": None, + }, + ) + def create_workload( self, request: Optional[Union[assuredworkloads.CreateWorkloadRequest, dict]] = None, @@ -668,7 +705,7 @@ def create_workload( workload: Optional[assuredworkloads.Workload] = None, retry: OptionalRetry = gapic_v1.method.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 Assured Workload. @@ -726,8 +763,10 @@ def sample_create_workload(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -798,7 +837,7 @@ def update_workload( 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]]] = (), ) -> assuredworkloads.Workload: r"""Updates an existing workload. Currently allows updating of workload display_name and labels. For force updates don't set @@ -857,8 +896,10 @@ def sample_update_workload(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.assuredworkloads_v1beta1.types.Workload: @@ -914,7 +955,7 @@ def restrict_allowed_resources( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> assuredworkloads.RestrictAllowedResourcesResponse: r"""Restrict the list of resources allowed in the Workload environment. The current list of allowed @@ -960,8 +1001,10 @@ def sample_restrict_allowed_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.assuredworkloads_v1beta1.types.RestrictAllowedResourcesResponse: @@ -1008,7 +1051,7 @@ def delete_workload( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.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 workload. Make sure that workload's direct children are already in a deleted state, otherwise the request will fail @@ -1054,8 +1097,10 @@ def sample_delete_workload(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, 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 @@ -1104,7 +1149,7 @@ def get_workload( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> assuredworkloads.Workload: r"""Gets Assured Workload associated with a CRM Node @@ -1151,8 +1196,10 @@ def sample_get_workload(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.assuredworkloads_v1beta1.types.Workload: @@ -1208,7 +1255,7 @@ def analyze_workload_move( target: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> assuredworkloads.AnalyzeWorkloadMoveResponse: r"""Analyze if the source Assured Workloads can be moved to the target Assured Workload @@ -1273,8 +1320,10 @@ def sample_analyze_workload_move(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.assuredworkloads_v1beta1.types.AnalyzeWorkloadMoveResponse: @@ -1328,7 +1377,7 @@ def list_workloads( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListWorkloadsPager: r"""Lists Assured Workloads under a CRM Node. @@ -1374,8 +1423,10 @@ def sample_list_workloads(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.assuredworkloads_v1beta1.services.assured_workloads_service.pagers.ListWorkloadsPager: @@ -1453,7 +1504,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. @@ -1464,8 +1515,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. @@ -1506,7 +1559,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. @@ -1517,8 +1570,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-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_service/pagers.py b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_service/pagers.py index 2da964249db8..679f2893589c 100644 --- a/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_service/pagers.py +++ b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_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 = assuredworkloads.ListWorkloadsRequest(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 = assuredworkloads.ListWorkloadsRequest(request) diff --git a/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_service/transports/grpc.py b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_service/transports/grpc.py index 7b9c39677387..9b677dee69be 100644 --- a/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_service/transports/grpc.py +++ b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_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.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.assuredworkloads_v1beta1.types import assuredworkloads from .base import DEFAULT_CLIENT_INFO, AssuredWorkloadsServiceTransport +try: + from google.api_core import client_logging # 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.assuredworkloads.v1beta1.AssuredWorkloadsService", + "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.assuredworkloads.v1beta1.AssuredWorkloadsService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AssuredWorkloadsServiceGrpcTransport(AssuredWorkloadsServiceTransport): """gRPC backend transport for AssuredWorkloadsService. @@ -182,7 +263,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientInterceptor() + self._logged_channel = grpc.intercept_channel( + self._grpc_channel, self._interceptor + ) + + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @classmethod @@ -246,7 +332,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -270,7 +358,7 @@ def create_workload( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workload" not in self._stubs: - self._stubs["create_workload"] = self.grpc_channel.unary_unary( + self._stubs["create_workload"] = self._logged_channel.unary_unary( "/google.cloud.assuredworkloads.v1beta1.AssuredWorkloadsService/CreateWorkload", request_serializer=assuredworkloads.CreateWorkloadRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -299,7 +387,7 @@ def update_workload( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workload" not in self._stubs: - self._stubs["update_workload"] = self.grpc_channel.unary_unary( + self._stubs["update_workload"] = self._logged_channel.unary_unary( "/google.cloud.assuredworkloads.v1beta1.AssuredWorkloadsService/UpdateWorkload", request_serializer=assuredworkloads.UpdateWorkloadRequest.serialize, response_deserializer=assuredworkloads.Workload.deserialize, @@ -335,7 +423,9 @@ def restrict_allowed_resources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "restrict_allowed_resources" not in self._stubs: - self._stubs["restrict_allowed_resources"] = self.grpc_channel.unary_unary( + self._stubs[ + "restrict_allowed_resources" + ] = self._logged_channel.unary_unary( "/google.cloud.assuredworkloads.v1beta1.AssuredWorkloadsService/RestrictAllowedResources", request_serializer=assuredworkloads.RestrictAllowedResourcesRequest.serialize, response_deserializer=assuredworkloads.RestrictAllowedResourcesResponse.deserialize, @@ -366,7 +456,7 @@ def delete_workload( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workload" not in self._stubs: - self._stubs["delete_workload"] = self.grpc_channel.unary_unary( + self._stubs["delete_workload"] = self._logged_channel.unary_unary( "/google.cloud.assuredworkloads.v1beta1.AssuredWorkloadsService/DeleteWorkload", request_serializer=assuredworkloads.DeleteWorkloadRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -392,7 +482,7 @@ def get_workload( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workload" not in self._stubs: - self._stubs["get_workload"] = self.grpc_channel.unary_unary( + self._stubs["get_workload"] = self._logged_channel.unary_unary( "/google.cloud.assuredworkloads.v1beta1.AssuredWorkloadsService/GetWorkload", request_serializer=assuredworkloads.GetWorkloadRequest.serialize, response_deserializer=assuredworkloads.Workload.deserialize, @@ -422,7 +512,7 @@ def analyze_workload_move( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "analyze_workload_move" not in self._stubs: - self._stubs["analyze_workload_move"] = self.grpc_channel.unary_unary( + self._stubs["analyze_workload_move"] = self._logged_channel.unary_unary( "/google.cloud.assuredworkloads.v1beta1.AssuredWorkloadsService/AnalyzeWorkloadMove", request_serializer=assuredworkloads.AnalyzeWorkloadMoveRequest.serialize, response_deserializer=assuredworkloads.AnalyzeWorkloadMoveResponse.deserialize, @@ -450,7 +540,7 @@ def list_workloads( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workloads" not in self._stubs: - self._stubs["list_workloads"] = self.grpc_channel.unary_unary( + self._stubs["list_workloads"] = self._logged_channel.unary_unary( "/google.cloud.assuredworkloads.v1beta1.AssuredWorkloadsService/ListWorkloads", request_serializer=assuredworkloads.ListWorkloadsRequest.serialize, response_deserializer=assuredworkloads.ListWorkloadsResponse.deserialize, @@ -458,7 +548,7 @@ def list_workloads( return self._stubs["list_workloads"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def get_operation( @@ -470,7 +560,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, @@ -489,7 +579,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-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_service/transports/grpc_asyncio.py b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_service/transports/grpc_asyncio.py index 2564f27764d1..0b00b6e1887d 100644 --- a/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_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.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.assuredworkloads_v1beta1.types import assuredworkloads from .base import DEFAULT_CLIENT_INFO, AssuredWorkloadsServiceTransport from .grpc import AssuredWorkloadsServiceGrpcTransport +try: + from google.api_core import client_logging # 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.assuredworkloads.v1beta1.AssuredWorkloadsService", + "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.assuredworkloads.v1beta1.AssuredWorkloadsService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AssuredWorkloadsServiceGrpcAsyncIOTransport(AssuredWorkloadsServiceTransport): """gRPC AsyncIO backend transport for AssuredWorkloadsService. @@ -229,10 +311,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientAIOInterceptor() + self._grpc_channel._unary_unary_interceptors.append(self._interceptor) + self._logged_channel = self._grpc_channel self._wrap_with_kind = ( "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters ) + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @property @@ -255,7 +340,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -282,7 +367,7 @@ def create_workload( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_workload" not in self._stubs: - self._stubs["create_workload"] = self.grpc_channel.unary_unary( + self._stubs["create_workload"] = self._logged_channel.unary_unary( "/google.cloud.assuredworkloads.v1beta1.AssuredWorkloadsService/CreateWorkload", request_serializer=assuredworkloads.CreateWorkloadRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -313,7 +398,7 @@ def update_workload( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_workload" not in self._stubs: - self._stubs["update_workload"] = self.grpc_channel.unary_unary( + self._stubs["update_workload"] = self._logged_channel.unary_unary( "/google.cloud.assuredworkloads.v1beta1.AssuredWorkloadsService/UpdateWorkload", request_serializer=assuredworkloads.UpdateWorkloadRequest.serialize, response_deserializer=assuredworkloads.Workload.deserialize, @@ -349,7 +434,9 @@ def restrict_allowed_resources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "restrict_allowed_resources" not in self._stubs: - self._stubs["restrict_allowed_resources"] = self.grpc_channel.unary_unary( + self._stubs[ + "restrict_allowed_resources" + ] = self._logged_channel.unary_unary( "/google.cloud.assuredworkloads.v1beta1.AssuredWorkloadsService/RestrictAllowedResources", request_serializer=assuredworkloads.RestrictAllowedResourcesRequest.serialize, response_deserializer=assuredworkloads.RestrictAllowedResourcesResponse.deserialize, @@ -380,7 +467,7 @@ def delete_workload( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_workload" not in self._stubs: - self._stubs["delete_workload"] = self.grpc_channel.unary_unary( + self._stubs["delete_workload"] = self._logged_channel.unary_unary( "/google.cloud.assuredworkloads.v1beta1.AssuredWorkloadsService/DeleteWorkload", request_serializer=assuredworkloads.DeleteWorkloadRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -408,7 +495,7 @@ def get_workload( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_workload" not in self._stubs: - self._stubs["get_workload"] = self.grpc_channel.unary_unary( + self._stubs["get_workload"] = self._logged_channel.unary_unary( "/google.cloud.assuredworkloads.v1beta1.AssuredWorkloadsService/GetWorkload", request_serializer=assuredworkloads.GetWorkloadRequest.serialize, response_deserializer=assuredworkloads.Workload.deserialize, @@ -438,7 +525,7 @@ def analyze_workload_move( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "analyze_workload_move" not in self._stubs: - self._stubs["analyze_workload_move"] = self.grpc_channel.unary_unary( + self._stubs["analyze_workload_move"] = self._logged_channel.unary_unary( "/google.cloud.assuredworkloads.v1beta1.AssuredWorkloadsService/AnalyzeWorkloadMove", request_serializer=assuredworkloads.AnalyzeWorkloadMoveRequest.serialize, response_deserializer=assuredworkloads.AnalyzeWorkloadMoveResponse.deserialize, @@ -467,7 +554,7 @@ def list_workloads( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_workloads" not in self._stubs: - self._stubs["list_workloads"] = self.grpc_channel.unary_unary( + self._stubs["list_workloads"] = self._logged_channel.unary_unary( "/google.cloud.assuredworkloads.v1beta1.AssuredWorkloadsService/ListWorkloads", request_serializer=assuredworkloads.ListWorkloadsRequest.serialize, response_deserializer=assuredworkloads.ListWorkloadsResponse.deserialize, @@ -566,7 +653,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: @@ -582,7 +669,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, @@ -601,7 +688,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-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_service/transports/rest.py b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_service/transports/rest.py index 042810e877de..ae5506592ef0 100644 --- a/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_service/transports/rest.py +++ b/packages/google-cloud-assured-workloads/google/cloud/assuredworkloads_v1beta1/services/assured_workloads_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, @@ -123,8 +131,10 @@ def post_update_workload(self, response): def pre_create_workload( self, request: assuredworkloads.CreateWorkloadRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[assuredworkloads.CreateWorkloadRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + assuredworkloads.CreateWorkloadRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_workload Override in a subclass to manipulate the request or metadata @@ -146,8 +156,10 @@ def post_create_workload( def pre_delete_workload( self, request: assuredworkloads.DeleteWorkloadRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[assuredworkloads.DeleteWorkloadRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + assuredworkloads.DeleteWorkloadRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_workload Override in a subclass to manipulate the request or metadata @@ -158,9 +170,10 @@ def pre_delete_workload( def pre_restrict_allowed_resources( self, request: assuredworkloads.RestrictAllowedResourcesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - assuredworkloads.RestrictAllowedResourcesRequest, Sequence[Tuple[str, str]] + assuredworkloads.RestrictAllowedResourcesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for restrict_allowed_resources @@ -183,8 +196,10 @@ def post_restrict_allowed_resources( 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 @@ -206,8 +221,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 @@ -367,7 +384,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> assuredworkloads.AnalyzeWorkloadMoveResponse: raise NotImplementedError( "Method AnalyzeWorkloadMove is not available over REST transport" @@ -409,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create workload method over HTTP. @@ -419,8 +436,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -433,6 +452,7 @@ def __call__( http_options = ( _BaseAssuredWorkloadsServiceRestTransport._BaseCreateWorkload._get_http_options() ) + request, metadata = self._interceptor.pre_create_workload(request, metadata) transcoded_request = _BaseAssuredWorkloadsServiceRestTransport._BaseCreateWorkload._get_transcoded_request( http_options, request @@ -447,6 +467,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.assuredworkloads_v1beta1.AssuredWorkloadsServiceClient.CreateWorkload", + extra={ + "serviceName": "google.cloud.assuredworkloads.v1beta1.AssuredWorkloadsService", + "rpcName": "CreateWorkload", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AssuredWorkloadsServiceRestTransport._CreateWorkload._get_response( @@ -468,7 +515,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_workload(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.assuredworkloads_v1beta1.AssuredWorkloadsServiceClient.create_workload", + extra={ + "serviceName": "google.cloud.assuredworkloads.v1beta1.AssuredWorkloadsService", + "rpcName": "CreateWorkload", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteWorkload( @@ -506,7 +575,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete workload method over HTTP. @@ -516,13 +585,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 = ( _BaseAssuredWorkloadsServiceRestTransport._BaseDeleteWorkload._get_http_options() ) + request, metadata = self._interceptor.pre_delete_workload(request, metadata) transcoded_request = _BaseAssuredWorkloadsServiceRestTransport._BaseDeleteWorkload._get_transcoded_request( http_options, request @@ -533,6 +605,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.assuredworkloads_v1beta1.AssuredWorkloadsServiceClient.DeleteWorkload", + extra={ + "serviceName": "google.cloud.assuredworkloads.v1beta1.AssuredWorkloadsService", + "rpcName": "DeleteWorkload", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AssuredWorkloadsServiceRestTransport._DeleteWorkload._get_response( @@ -563,7 +662,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> assuredworkloads.Workload: raise NotImplementedError( "Method GetWorkload is not available over REST transport" @@ -582,7 +681,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> assuredworkloads.ListWorkloadsResponse: raise NotImplementedError( "Method ListWorkloads is not available over REST transport" @@ -624,7 +723,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> assuredworkloads.RestrictAllowedResourcesResponse: r"""Call the restrict allowed resources method over HTTP. @@ -637,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: ~.assuredworkloads.RestrictAllowedResourcesResponse: @@ -650,6 +751,7 @@ def __call__( http_options = ( _BaseAssuredWorkloadsServiceRestTransport._BaseRestrictAllowedResources._get_http_options() ) + request, metadata = self._interceptor.pre_restrict_allowed_resources( request, metadata ) @@ -666,6 +768,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.assuredworkloads_v1beta1.AssuredWorkloadsServiceClient.RestrictAllowedResources", + extra={ + "serviceName": "google.cloud.assuredworkloads.v1beta1.AssuredWorkloadsService", + "rpcName": "RestrictAllowedResources", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AssuredWorkloadsServiceRestTransport._RestrictAllowedResources._get_response( self._host, @@ -687,7 +816,33 @@ def __call__( pb_resp = assuredworkloads.RestrictAllowedResourcesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_restrict_allowed_resources(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + assuredworkloads.RestrictAllowedResourcesResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.assuredworkloads_v1beta1.AssuredWorkloadsServiceClient.restrict_allowed_resources", + extra={ + "serviceName": "google.cloud.assuredworkloads.v1beta1.AssuredWorkloadsService", + "rpcName": "RestrictAllowedResources", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateWorkload( @@ -703,7 +858,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> assuredworkloads.Workload: raise NotImplementedError( "Method UpdateWorkload is not available over REST transport" @@ -812,7 +967,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -822,8 +977,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -832,6 +989,7 @@ def __call__( http_options = ( _BaseAssuredWorkloadsServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseAssuredWorkloadsServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -842,6 +1000,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.assuredworkloads_v1beta1.AssuredWorkloadsServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.assuredworkloads.v1beta1.AssuredWorkloadsService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AssuredWorkloadsServiceRestTransport._GetOperation._get_response( self._host, @@ -861,6 +1046,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.assuredworkloads_v1beta1.AssuredWorkloadsServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.assuredworkloads.v1beta1.AssuredWorkloadsService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -902,7 +1108,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -912,8 +1118,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must 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. @@ -922,6 +1130,7 @@ def __call__( http_options = ( _BaseAssuredWorkloadsServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseAssuredWorkloadsServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -932,6 +1141,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.assuredworkloads_v1beta1.AssuredWorkloadsServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.assuredworkloads.v1beta1.AssuredWorkloadsService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AssuredWorkloadsServiceRestTransport._ListOperations._get_response( @@ -953,6 +1189,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.assuredworkloads_v1beta1.AssuredWorkloadsServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.assuredworkloads.v1beta1.AssuredWorkloadsService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-assured-workloads/samples/generated_samples/snippet_metadata_google.cloud.assuredworkloads.v1.json b/packages/google-cloud-assured-workloads/samples/generated_samples/snippet_metadata_google.cloud.assuredworkloads.v1.json index 329203fab093..15061dde8248 100644 --- a/packages/google-cloud-assured-workloads/samples/generated_samples/snippet_metadata_google.cloud.assuredworkloads.v1.json +++ b/packages/google-cloud-assured-workloads/samples/generated_samples/snippet_metadata_google.cloud.assuredworkloads.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-assured-workloads", - "version": "1.13.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.assuredworkloads_v1.types.AcknowledgeViolationResponse", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.assuredworkloads_v1.types.AcknowledgeViolationResponse", @@ -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", @@ -369,7 +369,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_workload" @@ -446,7 +446,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_workload" @@ -524,7 +524,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.assuredworkloads_v1.types.Violation", @@ -604,7 +604,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.assuredworkloads_v1.types.Violation", @@ -685,7 +685,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.assuredworkloads_v1.types.Workload", @@ -765,7 +765,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.assuredworkloads_v1.types.Workload", @@ -846,7 +846,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.assuredworkloads_v1.services.assured_workloads_service.pagers.ListViolationsAsyncPager", @@ -926,7 +926,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.assuredworkloads_v1.services.assured_workloads_service.pagers.ListViolationsPager", @@ -1007,7 +1007,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.assuredworkloads_v1.services.assured_workloads_service.pagers.ListWorkloadsAsyncPager", @@ -1087,7 +1087,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.assuredworkloads_v1.services.assured_workloads_service.pagers.ListWorkloadsPager", @@ -1164,7 +1164,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.assuredworkloads_v1.types.RestrictAllowedResourcesResponse", @@ -1240,7 +1240,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.assuredworkloads_v1.types.RestrictAllowedResourcesResponse", @@ -1325,7 +1325,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.assuredworkloads_v1.types.Workload", @@ -1409,7 +1409,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.assuredworkloads_v1.types.Workload", diff --git a/packages/google-cloud-assured-workloads/samples/generated_samples/snippet_metadata_google.cloud.assuredworkloads.v1beta1.json b/packages/google-cloud-assured-workloads/samples/generated_samples/snippet_metadata_google.cloud.assuredworkloads.v1beta1.json index f857c8897b0f..d4f3e3793a9e 100644 --- a/packages/google-cloud-assured-workloads/samples/generated_samples/snippet_metadata_google.cloud.assuredworkloads.v1beta1.json +++ b/packages/google-cloud-assured-workloads/samples/generated_samples/snippet_metadata_google.cloud.assuredworkloads.v1beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-assured-workloads", - "version": "1.13.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.assuredworkloads_v1beta1.types.AnalyzeWorkloadMoveResponse", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.assuredworkloads_v1beta1.types.AnalyzeWorkloadMoveResponse", @@ -220,7 +220,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -304,7 +304,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -385,7 +385,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_workload" @@ -462,7 +462,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_workload" @@ -540,7 +540,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.assuredworkloads_v1beta1.types.Workload", @@ -620,7 +620,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.assuredworkloads_v1beta1.types.Workload", @@ -701,7 +701,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.assuredworkloads_v1beta1.services.assured_workloads_service.pagers.ListWorkloadsAsyncPager", @@ -781,7 +781,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.assuredworkloads_v1beta1.services.assured_workloads_service.pagers.ListWorkloadsPager", @@ -858,7 +858,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.assuredworkloads_v1beta1.types.RestrictAllowedResourcesResponse", @@ -934,7 +934,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.assuredworkloads_v1beta1.types.RestrictAllowedResourcesResponse", @@ -1019,7 +1019,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.assuredworkloads_v1beta1.types.Workload", @@ -1103,7 +1103,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.assuredworkloads_v1beta1.types.Workload", diff --git a/packages/google-cloud-assured-workloads/tests/unit/gapic/assuredworkloads_v1/test_assured_workloads_service.py b/packages/google-cloud-assured-workloads/tests/unit/gapic/assuredworkloads_v1/test_assured_workloads_service.py index 7ba335b1db84..8d3f85d46859 100644 --- a/packages/google-cloud-assured-workloads/tests/unit/gapic/assuredworkloads_v1/test_assured_workloads_service.py +++ b/packages/google-cloud-assured-workloads/tests/unit/gapic/assuredworkloads_v1/test_assured_workloads_service.py @@ -4360,6 +4360,7 @@ def test_create_workload_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_workload(request) @@ -4412,6 +4413,7 @@ def test_create_workload_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_workload(**mock_args) @@ -4542,6 +4544,7 @@ def test_update_workload_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_workload(request) @@ -4600,6 +4603,7 @@ def test_update_workload_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_workload(**mock_args) @@ -4740,6 +4744,7 @@ def test_restrict_allowed_resources_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.restrict_allowed_resources(request) @@ -4866,6 +4871,7 @@ def test_delete_workload_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_workload(request) @@ -4911,6 +4917,7 @@ def test_delete_workload_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_workload(**mock_args) @@ -5042,6 +5049,7 @@ def test_get_workload_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_workload(request) @@ -5089,6 +5097,7 @@ def test_get_workload_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_workload(**mock_args) @@ -5228,6 +5237,7 @@ def test_list_workloads_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_workloads(request) @@ -5282,6 +5292,7 @@ def test_list_workloads_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_workloads(**mock_args) @@ -6051,6 +6062,7 @@ def test_create_workload_rest_bad_request( response_value.status_code = 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_workload(request) @@ -6178,6 +6190,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_workload(request) # Establish that the response is the type that we expect. @@ -6219,6 +6232,7 @@ def test_create_workload_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -6267,6 +6281,7 @@ def test_update_workload_rest_bad_request( response_value.status_code = 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_workload(request) @@ -6414,6 +6429,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_workload(request) # Establish that the response is the type that we expect. @@ -6468,6 +6484,7 @@ def test_update_workload_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = assuredworkloads.Workload.to_json(assuredworkloads.Workload()) req.return_value.content = return_value @@ -6512,6 +6529,7 @@ def test_restrict_allowed_resources_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.restrict_allowed_resources(request) @@ -6547,6 +6565,7 @@ def test_restrict_allowed_resources_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.restrict_allowed_resources(request) # Establish that the response is the type that we expect. @@ -6588,6 +6607,7 @@ def test_restrict_allowed_resources_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = assuredworkloads.RestrictAllowedResourcesResponse.to_json( assuredworkloads.RestrictAllowedResourcesResponse() ) @@ -6634,6 +6654,7 @@ def test_delete_workload_rest_bad_request( response_value.status_code = 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_workload(request) @@ -6664,6 +6685,7 @@ def test_delete_workload_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_workload(request) # Establish that the response is the type that we expect. @@ -6700,6 +6722,7 @@ def test_delete_workload_rest_interceptors(null_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 = assuredworkloads.DeleteWorkloadRequest() metadata = [ @@ -6740,6 +6763,7 @@ def test_get_workload_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_workload(request) @@ -6786,6 +6810,7 @@ def test_get_workload_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_workload(request) # Establish that the response is the type that we expect. @@ -6840,6 +6865,7 @@ def test_get_workload_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = assuredworkloads.Workload.to_json(assuredworkloads.Workload()) req.return_value.content = return_value @@ -6884,6 +6910,7 @@ def test_list_workloads_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_workloads(request) @@ -6919,6 +6946,7 @@ def test_list_workloads_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_workloads(request) # Establish that the response is the type that we expect. @@ -6959,6 +6987,7 @@ def test_list_workloads_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = assuredworkloads.ListWorkloadsResponse.to_json( assuredworkloads.ListWorkloadsResponse() ) @@ -7043,6 +7072,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) @@ -7075,6 +7105,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) @@ -7105,6 +7136,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) @@ -7135,6 +7167,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-assured-workloads/tests/unit/gapic/assuredworkloads_v1beta1/test_assured_workloads_service.py b/packages/google-cloud-assured-workloads/tests/unit/gapic/assuredworkloads_v1beta1/test_assured_workloads_service.py index 94166e9a5540..e26d44ea87c0 100644 --- a/packages/google-cloud-assured-workloads/tests/unit/gapic/assuredworkloads_v1beta1/test_assured_workloads_service.py +++ b/packages/google-cloud-assured-workloads/tests/unit/gapic/assuredworkloads_v1beta1/test_assured_workloads_service.py @@ -3513,6 +3513,7 @@ def test_create_workload_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_workload(request) @@ -3565,6 +3566,7 @@ def test_create_workload_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_workload(**mock_args) @@ -3715,6 +3717,7 @@ def test_restrict_allowed_resources_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.restrict_allowed_resources(request) @@ -3841,6 +3844,7 @@ def test_delete_workload_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_workload(request) @@ -3886,6 +3890,7 @@ def test_delete_workload_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_workload(**mock_args) @@ -4501,6 +4506,7 @@ def test_create_workload_rest_bad_request( response_value.status_code = 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_workload(request) @@ -4633,6 +4639,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_workload(request) # Establish that the response is the type that we expect. @@ -4674,6 +4681,7 @@ def test_create_workload_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -4730,6 +4738,7 @@ def test_restrict_allowed_resources_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.restrict_allowed_resources(request) @@ -4765,6 +4774,7 @@ def test_restrict_allowed_resources_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.restrict_allowed_resources(request) # Establish that the response is the type that we expect. @@ -4806,6 +4816,7 @@ def test_restrict_allowed_resources_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = assuredworkloads.RestrictAllowedResourcesResponse.to_json( assuredworkloads.RestrictAllowedResourcesResponse() ) @@ -4852,6 +4863,7 @@ def test_delete_workload_rest_bad_request( response_value.status_code = 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_workload(request) @@ -4882,6 +4894,7 @@ def test_delete_workload_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_workload(request) # Establish that the response is the type that we expect. @@ -4918,6 +4931,7 @@ def test_delete_workload_rest_interceptors(null_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 = assuredworkloads.DeleteWorkloadRequest() metadata = [ @@ -4996,6 +5010,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) @@ -5028,6 +5043,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) @@ -5058,6 +5074,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) @@ -5088,6 +5105,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)